Changelog history

Versions follow Semantic Versioning (<major>.<minor>.<patch>).

Backward incompatible (breaking) changes will only be introduced in major versions with advance notice in the Deprecations section of releases.

pytest 4.6.11 (2020-06-04)

Bug Fixes

  • #6334: Fix summary entries appearing twice when f/F and s/S report chars were used at the same time in the -r command-line option (for example -rFf).

    The upper case variants were never documented and the preferred form should be the lower case.

  • #7310: Fix UnboundLocalError: local variable 'letter' referenced before assignment in _pytest.terminal.pytest_report_teststatus() when plugins return report objects in an unconventional state.

    This was making pytest_report_teststatus() skip entering if-block branches that declare the letter variable.

    The fix was to set the initial value of the letter before the if-block cascade so that it always has a value.

pytest 4.6.10 (2020-05-08)

Features

  • #6870: New Config.invocation_args attribute containing the unchanged arguments passed to pytest.main().

    Remark: while this is technically a new feature and according to our policy it should not have been backported, we have opened an exception in this particular case because it fixes a serious interaction with pytest-xdist, so it can also be considered a bugfix.

Trivial/Internal Changes

  • #6404: Remove usage of parser module, deprecated in Python 3.9.

pytest 4.6.9 (2020-01-04)

Bug Fixes

  • #6301: Fix assertion rewriting for egg-based distributions and editable installs (pip install --editable).

pytest 4.6.8 (2019-12-19)

Features

  • #5471: JUnit XML now includes a timestamp and hostname in the testsuite tag.

Bug Fixes

  • #5430: junitxml: Logs for failed test are now passed to junit report in case the test fails during call phase.

Trivial/Internal Changes

  • #6345: Pin colorama to 0.4.1 only for Python 3.4 so newer Python versions can still receive colorama updates.

pytest 4.6.7 (2019-12-05)

Bug Fixes

  • #5477: The XML file produced by --junitxml now correctly contain a <testsuites> root element.
  • #6044: Properly ignore FileNotFoundError (OSError.errno == NOENT in Python 2) exceptions when trying to remove old temporary directories, for instance when multiple processes try to remove the same directory (common with pytest-xdist for example).

pytest 4.6.6 (2019-10-11)

Bug Fixes

  • #5523: Fixed using multiple short options together in the command-line (for example -vs) in Python 3.8+.
  • #5537: Replace importlib_metadata backport with importlib.metadata from the standard library on Python 3.8+.
  • #5806: Fix "lexer" being used when uploading to bpaste.net from --pastebin to "text".
  • #5902: Fix warnings about deprecated cmp attribute in attrs>=19.2.

Trivial/Internal Changes

  • #5801: Fixes python version checks (detected by flake8-2020) in case python4 becomes a thing.

pytest 4.6.5 (2019-08-05)

Bug Fixes

  • #4344: Fix RuntimeError/StopIteration when trying to collect package with "__init__.py" only.
  • #5478: Fix encode error when using unicode strings in exceptions with pytest.raises.
  • #5524: Fix issue where tmp_path and tmpdir would not remove directories containing files marked as read-only, which could lead to pytest crashing when executed a second time with the --basetemp option.
  • #5547: --step-wise now handles xfail(strict=True) markers properly.
  • #5650: Improved output when parsing an ini configuration file fails.

pytest 4.6.4 (2019-06-28)

Bug Fixes

  • #5404: Emit a warning when attempting to unwrap a broken object raises an exception, for easier debugging (#5080).
  • #5444: Fix --stepwise mode when the first file passed on the command-line fails to collect.
  • #5482: Fix bug introduced in 4.6.0 causing collection errors when passing more than 2 positional arguments to pytest.mark.parametrize.
  • #5505: Fix crash when discovery fails while using -p no:terminal.

pytest 4.6.3 (2019-06-11)

Bug Fixes

  • #5383: -q has again an impact on the style of the collected items (--collect-only) when --log-cli-level is used.
  • #5389: Fix regressions of #5063 for importlib_metadata.PathDistribution which have their files attribute being None.
  • #5390: Fix regression where the obj attribute of TestCase items was no longer bound to methods.

pytest 4.6.2 (2019-06-03)

Bug Fixes

  • #5370: Revert unrolling of all() to fix NameError on nested comprehensions.
  • #5371: Revert unrolling of all() to fix incorrect handling of generators with if.
  • #5372: Revert unrolling of all() to fix incorrect assertion when using all() in an expression.

pytest 4.6.1 (2019-06-02)

Bug Fixes

  • #5354: Fix pytest.mark.parametrize when the argvalues is an iterator.
  • #5358: Fix assertion rewriting of all() calls to deal with non-generators.

pytest 4.6.0 (2019-05-31)

Important

The 4.6.X series will be the last series to support Python 2 and Python 3.4.

For more details, see our Python 2.7 and 3.4 support plan.

Features

  • #4559: Added the junit_log_passing_tests ini value which can be used to enable or disable logging of passing test output in the Junit XML file.
  • #4956: pytester's testdir.spawn uses tmpdir as HOME/USERPROFILE directory.
  • #5062: Unroll calls to all to full for-loops with assertion rewriting for better failure messages, especially when using Generator Expressions.
  • #5063: Switch from pkg_resources to importlib-metadata for entrypoint detection for improved performance and import time.
  • #5091: The output for ini options in --help has been improved.
  • #5269: pytest.importorskip includes the ImportError now in the default reason.
  • #5311: Captured logs that are output for each failing test are formatted using the ColoredLevelFormatter.
  • #5312: Improved formatting of multiline log messages in Python 3.

Bug Fixes

  • #2064: The debugging plugin imports the wrapped Pdb class (--pdbcls) on-demand now.
  • #4908: The pytest_enter_pdb hook gets called with post-mortem (--pdb).
  • #5036: Fix issue where fixtures dependent on other parametrized fixtures would be erroneously parametrized.
  • #5256: Handle internal error due to a lone surrogate unicode character not being representable in Jython.
  • #5257: Ensure that sys.stdout.mode does not include 'b' as it is a text stream.
  • #5278: Pytest's internal python plugin can be disabled using -p no:python again.
  • #5286: Fix issue with disable_test_id_escaping_and_forfeit_all_rights_to_community_support option not working when using a list of test IDs in parametrized tests.
  • #5330: Show the test module being collected when emitting PytestCollectionWarning messages for test classes with __init__ and __new__ methods to make it easier to pin down the problem.
  • #5333: Fix regression in 4.5.0 with --lf not re-running all tests with known failures from non-selected tests.

Improved Documentation

  • #5250: Expand docs on use of setenv and delenv with monkeypatch.

pytest 4.5.0 (2019-05-11)

Features

  • #4826: A warning is now emitted when unknown marks are used as a decorator. This is often due to a typo, which can lead to silently broken tests.

  • #4907: Show XFail reason as part of JUnitXML message field.

  • #5013: Messages from crash reports are displayed within test summaries now, truncated to the terminal width.

  • #5023: New flag --strict-markers that triggers an error when unknown markers (e.g. those not registered using the markers option in the configuration file) are used in the test suite.

    The existing --strict option has the same behavior currently, but can be augmented in the future for additional checks.

  • #5026: Assertion failure messages for sequences and dicts contain the number of different items now.

  • #5034: Improve reporting with --lf and --ff (run-last-failure).

  • #5035: The --cache-show option/action accepts an optional glob to show only matching cache entries.

  • #5059: Standard input (stdin) can be given to pytester's Testdir.run() and Testdir.popen().

  • #5068: The -r option learnt about A to display all reports (including passed ones) in the short test summary.

  • #5108: The short test summary is displayed after passes with output (-rP).

  • #5172: The --last-failed (--lf) option got smarter and will now skip entire files if all tests of that test file have passed in previous runs, greatly speeding up collection.

  • #5177: Introduce new specific warning PytestWarning subclasses to make it easier to filter warnings based on the class, rather than on the message. The new subclasses are:

    • PytestAssertRewriteWarning
    • PytestCacheWarning
    • PytestCollectionWarning
    • PytestConfigWarning
    • PytestUnhandledCoroutineWarning
    • PytestUnknownMarkWarning
  • #5202: New record_testsuite_property session-scoped fixture allows users to log <property> tags at the testsuite level with the junitxml plugin.

    The generated XML is compatible with the latest xunit standard, contrary to the properties recorded by record_property and record_xml_attribute.

  • #5214: The default logging format has been changed to improve readability. Here is an example of a previous logging message:

    test_log_cli_enabled_disabled.py    3 CRITICAL critical message logged by test
    

    This has now become:

    CRITICAL root:test_log_cli_enabled_disabled.py:3 critical message logged by test
    

    The formatting can be changed through the log_format configuration option.

  • #5220: --fixtures now also shows fixture scope for scopes other than "function".

Bug Fixes

  • #5113: Deselected items from plugins using pytest_collect_modifyitems as a hookwrapper are correctly reported now.
  • #5144: With usage errors exitstatus is set to EXIT_USAGEERROR in the pytest_sessionfinish hook now as expected.
  • #5235: outcome.exit is not used with EOF in the pdb wrapper anymore, but only with quit.

Improved Documentation

  • #4935: Expand docs on registering marks and the effect of --strict.

Trivial/Internal Changes

  • #4942: logging.raiseExceptions is not set to False anymore.
  • #5013: pytest now depends on wcwidth to properly track unicode character sizes for more precise terminal output.
  • #5059: pytester's Testdir.popen() uses stdout and stderr via keyword arguments with defaults now (subprocess.PIPE).
  • #5069: The code for the short test summary in the terminal was moved to the terminal plugin.
  • #5082: Improved validation of kwargs for various methods in the pytester plugin.
  • #5202: record_property now emits a PytestWarning when used with junit_family=xunit2: the fixture generates property tags as children of testcase, which is not permitted according to the most recent schema.
  • #5239: Pin pluggy to < 1.0 so we don't update to 1.0 automatically when it gets released: there are planned breaking changes, and we want to ensure pytest properly supports pluggy 1.0.

pytest 4.4.2 (2019-05-08)

Bug Fixes

  • #5089: Fix crash caused by error in __repr__ function with both showlocals and verbose output enabled.
  • #5139: Eliminate core dependency on 'terminal' plugin.
  • #5229: Require pluggy>=0.11.0 which reverts a dependency to importlib-metadata added in 0.10.0. The importlib-metadata package cannot be imported when installed as an egg and causes issues when relying on setup.py to install test dependencies.

Improved Documentation

  • #5171: Doc: pytest_ignore_collect, pytest_collect_directory, pytest_collect_file and pytest_pycollect_makemodule hooks's 'path' parameter documented type is now py.path.local
  • #5188: Improve help for --runxfail flag.

Trivial/Internal Changes

  • #5182: Removed internal and unused _pytest.deprecated.MARK_INFO_ATTRIBUTE.

pytest 4.4.1 (2019-04-15)

Bug Fixes

  • #5031: Environment variables are properly restored when using pytester's testdir fixture.
  • #5039: Fix regression with --pdbcls, which stopped working with local modules in 4.0.0.
  • #5092: Produce a warning when unknown keywords are passed to pytest.param(...).
  • #5098: Invalidate import caches with monkeypatch.syspath_prepend, which is required with namespace packages being used.

pytest 4.4.0 (2019-03-29)

Features

  • #2224: async test functions are skipped and a warning is emitted when a suitable async plugin is not installed (such as pytest-asyncio or pytest-trio).

    Previously async functions would not execute at all but still be marked as "passed".

  • #2482: Include new disable_test_id_escaping_and_forfeit_all_rights_to_community_support option to disable ascii-escaping in parametrized values. This may cause a series of problems and as the name makes clear, use at your own risk.

  • #4718: The -p option can now be used to early-load plugins also by entry-point name, instead of just by module name.

    This makes it possible to early load external plugins like pytest-cov in the command-line:

    pytest -p pytest_cov
    
  • #4855: The --pdbcls option handles classes via module attributes now (e.g. pdb:pdb.Pdb with pdb++), and its validation was improved.

  • #4875: The testpaths configuration option is now displayed next to the rootdir and inifile lines in the pytest header if the option is in effect, i.e., directories or file names were not explicitly passed in the command line.

    Also, inifile is only displayed if there's a configuration file, instead of an empty inifile: string.

  • #4911: Doctests can be skipped now dynamically using pytest.skip().

  • #4920: Internal refactorings have been made in order to make the implementation of the pytest-subtests plugin possible, which adds unittest sub-test support and a new subtests fixture as discussed in #1367.

    For details on the internal refactorings, please see the details on the related PR.

  • #4931: pytester's LineMatcher asserts that the passed lines are a sequence.

  • #4936: Handle -p plug after -p no:plug.

    This can be used to override a blocked plugin (e.g. in "addopts") from the command line etc.

  • #4951: Output capturing is handled correctly when only capturing via fixtures (capsys, capfs) with pdb.set_trace().

  • #4956: pytester sets $HOME and $USERPROFILE to the temporary directory during test runs.

    This ensures to not load configuration files from the real user's home directory.

  • #4980: Namespace packages are handled better with monkeypatch.syspath_prepend and testdir.syspathinsert (via pkg_resources.fixup_namespace_packages).

  • #4993: The stepwise plugin reports status information now.

  • #5008: If a setup.cfg file contains [tool:pytest] and also the no longer supported [pytest] section, pytest will use [tool:pytest] ignoring [pytest]. Previously it would unconditionally error out.

    This makes it simpler for plugins to support old pytest versions.

Bug Fixes

  • #1895: Fix bug where fixtures requested dynamically via request.getfixturevalue() might be teardown before the requesting fixture.

  • #4851: pytester unsets PYTEST_ADDOPTS now to not use outer options with testdir.runpytest().

  • #4903: Use the correct modified time for years after 2038 in rewritten .pyc files.

  • #4928: Fix line offsets with ScopeMismatch errors.

  • #4957: -p no:plugin is handled correctly for default (internal) plugins now, e.g. with -p no:capture.

    Previously they were loaded (imported) always, making e.g. the capfd fixture available.

  • #4968: The pdb quit command is handled properly when used after the debug command with pdb++.

  • #4975: Fix the interpretation of -qq option where it was being considered as -v instead.

  • #4978: outcomes.Exit is not swallowed in assertrepr_compare anymore.

  • #4988: Close logging's file handler explicitly when the session finishes.

  • #5003: Fix line offset with mark collection error (off by one).

Improved Documentation

  • #4974: Update docs for pytest_cmdline_parse hook to note availability liminations

Trivial/Internal Changes

  • #4718: pluggy>=0.9 is now required.

  • #4815: funcsigs>=1.0 is now required for Python 2.7.

  • #4829: Some left-over internal code related to yield tests has been removed.

  • #4890: Remove internally unused anypython fixture from the pytester plugin.

  • #4912: Remove deprecated Sphinx directive, add_description_unit(), pin sphinx-removed-in to >= 0.2.0 to support Sphinx 2.0.

  • #4913: Fix pytest tests invocation with custom PYTHONPATH.

  • #4965: New pytest_report_to_serializable and pytest_report_from_serializable experimental hooks.

    These hooks will be used by pytest-xdist, pytest-subtests, and the replacement for resultlog to serialize and customize reports.

    They are experimental, meaning that their details might change or even be removed completely in future patch releases without warning.

    Feedback is welcome from plugin authors and users alike.

  • #4987: Collector.repr_failure respects the --tb option, but only defaults to short now (with auto).

pytest 4.3.1 (2019-03-11)

Bug Fixes

  • #4810: Logging messages inside pytest_runtest_logreport() are now properly captured and displayed.
  • #4861: Improve validation of contents written to captured output so it behaves the same as when capture is disabled.
  • #4898: Fix AttributeError: FixtureRequest has no 'confg' attribute bug in testdir.copy_example.

Trivial/Internal Changes

  • #4768: Avoid pkg_resources import at the top-level.

pytest 4.3.0 (2019-02-16)

Deprecations

  • #4724: pytest.warns() now emits a warning when it receives unknown keyword arguments.

    This will be changed into an error in the future.

Features

  • #2753: Usage errors from argparse are mapped to pytest's UsageError.

  • #3711: Add the --ignore-glob parameter to exclude test-modules with Unix shell-style wildcards. Add the collect_ignore_glob for conftest.py to exclude test-modules with Unix shell-style wildcards.

  • #4698: The warning about Python 2.7 and 3.4 not being supported in pytest 5.0 has been removed.

    In the end it was considered to be more of a nuisance than actual utility and users of those Python versions shouldn't have problems as pip will not install pytest 5.0 on those interpreters.

  • #4707: With the help of new set_log_path() method there is a way to set log_file paths from hooks.

Bug Fixes

  • #4651: --help and --version are handled with UsageError.
  • #4782: Fix AssertionError with collection of broken symlinks with packages.

pytest 4.2.1 (2019-02-12)

Bug Fixes

  • #2895: The pytest_report_collectionfinish hook now is also called with --collect-only.
  • #3899: Do not raise UsageError when an imported package has a pytest_plugins.py child module.
  • #4347: Fix output capturing when using pdb++ with recursive debugging.
  • #4592: Fix handling of collect_ignore via parent conftest.py.
  • #4700: Fix regression where setUpClass would always be called in subclasses even if all tests were skipped by a unittest.skip() decorator applied in the subclass.
  • #4739: Fix parametrize(... ids=<function>) when the function returns non-strings.
  • #4745: Fix/improve collection of args when passing in __init__.py and a test file.
  • #4770: more_itertools is now constrained to <6.0.0 when required for Python 2.7 compatibility.
  • #526: Fix "ValueError: Plugin already registered" exceptions when running in build directories that symlink to actual source.

Improved Documentation

  • #3899: Add note to plugins.rst that pytest_plugins should not be used as a name for a user module containing plugins.
  • #4324: Document how to use raises and does_not_raise to write parametrized tests with conditional raises.
  • #4709: Document how to customize test failure messages when using pytest.warns.

Trivial/Internal Changes

  • #4741: Some verbosity related attributes of the TerminalReporter plugin are now read only properties.

pytest 4.2.0 (2019-01-30)

Features

  • #3094: Classic xunit-style functions and methods now obey the scope of autouse fixtures.

    This fixes a number of surprising issues like setup_method being called before session-scoped autouse fixtures (see #517 for an example).

  • #4627: Display a message at the end of the test session when running under Python 2.7 and 3.4 that pytest 5.0 will no longer support those Python versions.

  • #4660: The number of selected tests now are also displayed when the -k or -m flags are used.

  • #4688: pytest_report_teststatus hook now can also receive a config parameter.

  • #4691: pytest_terminal_summary hook now can also receive a config parameter.

Bug Fixes

  • #3547: --junitxml can emit XML compatible with Jenkins xUnit. junit_family INI option accepts legacy|xunit1, which produces old style output, and xunit2 that conforms more strictly to https://github.com/jenkinsci/xunit-plugin/blob/xunit-2.3.2/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd

  • #4280: Improve quitting from pdb, especially with --trace.

    Using q[quit] after pdb.set_trace() will quit pytest also.

  • #4402: Warning summary now groups warnings by message instead of by test id.

    This makes the output more compact and better conveys the general idea of how much code is actually generating warnings, instead of how many tests call that code.

  • #4536: monkeypatch.delattr handles class descriptors like staticmethod/classmethod.

  • #4649: Restore marks being considered keywords for keyword expressions.

  • #4653: tmp_path fixture and other related ones provides resolved path (a.k.a real path)

  • #4667: pytest_terminal_summary uses result from pytest_report_teststatus hook, rather than hardcoded strings.

  • #4669: Correctly handle unittest.SkipTest exception containing non-ascii characters on Python 2.

  • #4680: Ensure the tmpdir and the tmp_path fixtures are the same folder.

  • #4681: Ensure tmp_path is always a real path.

Trivial/Internal Changes

  • #4643: Use a.item() instead of the deprecated np.asscalar(a) in pytest.approx.

    np.asscalar has been deprecated in numpy 1.16..

  • #4657: Copy saferepr from pylib

  • #4668: The verbose word for expected failures in the teststatus report changes from xfail to XFAIL to be consistent with other test outcomes.

pytest 4.1.1 (2019-01-12)

Bug Fixes

  • #2256: Show full repr with assert a==b and -vv.
  • #3456: Extend Doctest-modules to ignore mock objects.
  • #4617: Fixed pytest.warns bug when context manager is reused (e.g. multiple parametrization).
  • #4631: Don't rewrite assertion when __getattr__ is broken

Improved Documentation

  • #3375: Document that using setup.cfg may crash other tools or cause hard to track down problems because it uses a different parser than pytest.ini or tox.ini files.

Trivial/Internal Changes

  • #4602: Uninstall hypothesis in regen tox env.

pytest 4.1.0 (2019-01-05)

Removals

  • #2169: pytest.mark.parametrize: in previous versions, errors raised by id functions were suppressed and changed into warnings. Now the exceptions are propagated, along with a pytest message informing the node, parameter value and index where the exception occurred.

  • #3078: Remove legacy internal warnings system: config.warn, Node.warn. The pytest_logwarning now issues a warning when implemented.

    See our docs on information on how to update your code.

  • #3079: Removed support for yield tests - they are fundamentally broken because they don't support fixtures properly since collection and test execution were separated.

    See our docs on information on how to update your code.

  • #3082: Removed support for applying marks directly to values in @pytest.mark.parametrize. Use pytest.param instead.

    See our docs on information on how to update your code.

  • #3083: Removed Metafunc.addcall. This was the predecessor mechanism to @pytest.mark.parametrize.

    See our docs on information on how to update your code.

  • #3085: Removed support for passing strings to pytest.main. Now, always pass a list of strings instead.

    See our docs on information on how to update your code.

  • #3086: [pytest] section in setup.cfg files is no longer supported, use [tool:pytest] instead. setup.cfg files are meant for use with distutils, and a section named pytest has notoriously been a source of conflicts and bugs.

    Note that for pytest.ini and tox.ini files the section remains [pytest].

  • #3616: Removed the deprecated compat properties for node.Class/Function/Module - use pytest.Class/Function/Module now.

    See our docs on information on how to update your code.

  • #4421: Removed the implementation of the pytest_namespace hook.

    See our docs on information on how to update your code.

  • #4489: Removed request.cached_setup. This was the predecessor mechanism to modern fixtures.

    See our docs on information on how to update your code.

  • #4535: Removed the deprecated PyCollector.makeitem method. This method was made public by mistake a long time ago.

  • #4543: Removed support to define fixtures using the pytest_funcarg__ prefix. Use the @pytest.fixture decorator instead.

    See our docs on information on how to update your code.

  • #4545: Calling fixtures directly is now always an error instead of a warning.

    See our docs on information on how to update your code.

  • #4546: Remove Node.get_marker(name) the return value was not usable for more than a existence check.

    Use Node.get_closest_marker(name) as a replacement.

  • #4547: The deprecated record_xml_property fixture has been removed, use the more generic record_property instead.

    See our docs for more information.

  • #4548: An error is now raised if the pytest_plugins variable is defined in a non-top-level conftest.py file (i.e., not residing in the rootdir).

    See our docs for more information.

  • #891: Remove testfunction.markername attributes - use Node.iter_markers(name=None) to iterate them.

Deprecations

Features

  • #3191: A warning is now issued when assertions are made for None.

    This is a common source of confusion among new users, which write:

    assert mocked_object.assert_called_with(3, 4, 5, key="value")
    

    When they should write:

    mocked_object.assert_called_with(3, 4, 5, key="value")
    

    Because the assert_called_with method of mock objects already executes an assertion.

    This warning will not be issued when None is explicitly checked. An assertion like:

    assert variable is None
    

    will not issue the warning.

  • #3632: Richer equality comparison introspection on AssertionError for objects created using attrs or dataclasses (Python 3.7+, backported to 3.6).

  • #4278: CACHEDIR.TAG files are now created inside cache directories.

    Those files are part of the Cache Directory Tagging Standard, and can be used by backup or synchronization programs to identify pytest's cache directory as such.

  • #4292: pytest.outcomes.Exit is derived from SystemExit instead of KeyboardInterrupt. This allows us to better handle pdb exiting.

  • #4371: Updated the --collect-only option to display test descriptions when ran using --verbose.

  • #4386: Restructured ExceptionInfo object construction and ensure incomplete instances have a repr/str.

  • #4416: pdb: added support for keyword arguments with pdb.set_trace.

    It handles header similar to Python 3.7 does it, and forwards any other keyword arguments to the Pdb constructor.

    This allows for __import__("pdb").set_trace(skip=["foo.*"]).

  • #4483: Added ini parameter junit_duration_report to optionally report test call durations, excluding setup and teardown times.

    The JUnit XML specification and the default pytest behavior is to include setup and teardown times in the test duration report. You can include just the call durations instead (excluding setup and teardown) by adding this to your pytest.ini file:

    [pytest]
    junit_duration_report = call
    
  • #4532: -ra now will show errors and failures last, instead of as the first items in the summary.

    This makes it easier to obtain a list of errors and failures to run tests selectively.

  • #4599: pytest.importorskip now supports a reason parameter, which will be shown when the requested module cannot be imported.

Bug Fixes

  • #3532: -p now accepts its argument without a space between the value, for example -pmyplugin.
  • #4327: approx again works with more generic containers, more precisely instances of Iterable and Sized instead of more restrictive Sequence.
  • #4397: Ensure that node ids are printable.
  • #4435: Fixed raises(..., 'code(string)') frame filename.
  • #4458: Display actual test ids in --collect-only.

Improved Documentation

  • #4557: Markers example documentation page updated to support latest pytest version.
  • #4558: Update cache documentation example to correctly show cache hit and miss.
  • #4580: Improved detailed summary report documentation.

Trivial/Internal Changes

  • #4447: Changed the deprecation type of --result-log to PytestDeprecationWarning.

    It was decided to remove this feature at the next major revision.

pytest 4.0.2 (2018-12-13)

Bug Fixes

  • #4265: Validate arguments from the PYTEST_ADDOPTS environment variable and the addopts ini option separately.
  • #4435: Fix raises(..., 'code(string)') frame filename.
  • #4500: When a fixture yields and a log call is made after the test runs, and, if the test is interrupted, capture attributes are None.
  • #4538: Raise TypeError for with raises(..., match=<non-None falsey value>).

Improved Documentation

  • #1495: Document common doctest fixture directory tree structure pitfalls

pytest 4.0.1 (2018-11-23)

Bug Fixes

  • #3952: Display warnings before "short test summary info" again, but still later warnings in the end.
  • #4386: Handle uninitialized exceptioninfo in repr/str.
  • #4393: Do not create .gitignore/README.md files in existing cache directories.
  • #4400: Rearrange warning handling for the yield test errors so the opt-out in 4.0.x correctly works.
  • #4405: Fix collection of testpaths with --pyargs.
  • #4412: Fix assertion rewriting involving Starred + side-effects.
  • #4425: Ensure we resolve the absolute path when the given --basetemp is a relative path.

Trivial/Internal Changes

  • #4315: Use pkg_resources.parse_version instead of LooseVersion in minversion check.
  • #4440: Adjust the stack level of some internal pytest warnings.

pytest 4.0.0 (2018-11-13)

Removals

  • #3737: RemovedInPytest4Warnings are now errors by default.

    Following our plan to remove deprecated features with as little disruption as possible, all warnings of type RemovedInPytest4Warnings now generate errors instead of warning messages.

    The affected features will be effectively removed in pytest 4.1, so please consult the Deprecations and Removals section in the docs for directions on how to update existing code.

    In the pytest 4.0.X series, it is possible to change the errors back into warnings as a stop gap measure by adding this to your pytest.ini file:

    [pytest]
    filterwarnings =
        ignore::pytest.RemovedInPytest4Warning
    

    But this will stop working when pytest 4.1 is released.

    If you have concerns about the removal of a specific feature, please add a comment to #4348.

  • #4358: Remove the ::() notation to denote a test class instance in node ids.

    Previously, node ids that contain test instances would use ::() to denote the instance like this:

    test_foo.py::Test::()::test_bar
    

    The extra ::() was puzzling to most users and has been removed, so that the test id becomes now:

    test_foo.py::Test::test_bar
    

    This change could not accompany a deprecation period as is usual when user-facing functionality changes because it was not really possible to detect when the functionality was being used explicitly.

    The extra ::() might have been removed in some places internally already, which then led to confusion in places where it was expected, e.g. with --deselect (#4127).

    Test class instances are also not listed with --collect-only anymore.

Features

  • #4270: The cache_dir option uses $TOX_ENV_DIR as prefix (if set in the environment).

    This uses a different cache per tox environment by default.

Bug Fixes

  • #3554: Fix CallInfo.__repr__ for when the call is not finished yet.

pytest 3.10.1 (2018-11-11)

Bug Fixes

  • #4287: Fix nested usage of debugging plugin (pdb), e.g. with pytester's testdir.runpytest.
  • #4304: Block the stepwise plugin if cacheprovider is also blocked, as one depends on the other.
  • #4306: Parse minversion as an actual version and not as dot-separated strings.
  • #4310: Fix duplicate collection due to multiple args matching the same packages.
  • #4321: Fix item.nodeid with resolved symlinks.
  • #4325: Fix collection of direct symlinked files, where the target does not match python_files.
  • #4329: Fix TypeError in report_collect with _collect_report_last_write.

Trivial/Internal Changes

  • #4305: Replace byte/unicode helpers in test_capture with python level syntax.

pytest 3.10.0 (2018-11-03)

Features

  • #2619: Resume capturing output after continue with __import__("pdb").set_trace().

    This also adds a new pytest_leave_pdb hook, and passes in pdb to the existing pytest_enter_pdb hook.

  • #4147: Add --sw, --stepwise as an alternative to --lf -x for stopping at the first failure, but starting the next test invocation from that test. See the documentation for more info.

  • #4188: Make --color emit colorful dots when not running in verbose mode. Earlier, it would only colorize the test-by-test output if --verbose was also passed.

  • #4225: Improve performance with collection reporting in non-quiet mode with terminals.

    The "collecting …" message is only printed/updated every 0.5s.

Bug Fixes

  • #2701: Fix false RemovedInPytest4Warning: usage of Session... is deprecated, please use pytest warnings.
  • #4046: Fix problems with running tests in package __init__.py files.
  • #4260: Swallow warnings during anonymous compilation of source.
  • #4262: Fix access denied error when deleting stale directories created by tmpdir / tmp_path.
  • #611: Naming a fixture request will now raise a warning: the request fixture is internal and should not be overwritten as it will lead to internal errors.
  • #4266: Handle (ignore) exceptions raised during collection, e.g. with Django's LazySettings proxy class.

Improved Documentation

  • #4255: Added missing documentation about the fact that module names passed to filter warnings are not regex-escaped.

Trivial/Internal Changes

  • #4272: Display cachedir also in non-verbose mode if non-default.

  • #4277: pdb: improve message about output capturing with set_trace.

    Do not display "IO-capturing turned off/on" when -s is used to avoid confusion.

  • #4279: Improve message and stack level of warnings issued by monkeypatch.setenv when the value of the environment variable is not a str.

pytest 3.9.3 (2018-10-27)

Bug Fixes

  • #4174: Fix "ValueError: Plugin already registered" with conftest plugins via symlink.
  • #4181: Handle race condition between creation and deletion of temporary folders.
  • #4221: Fix bug where the warning summary at the end of the test session was not showing the test where the warning was originated.
  • #4243: Fix regression when stacklevel for warnings was passed as positional argument on python2.

Improved Documentation

  • #3851: Add reference to empty_parameter_set_mark ini option in documentation of @pytest.mark.parametrize

Trivial/Internal Changes

  • #4028: Revert patching of sys.breakpointhook since it appears to do nothing.
  • #4233: Apply an import sorter (reorder-python-imports) to the codebase.
  • #4248: Remove use of unnecessary compat shim, six.binary_type

pytest 3.9.2 (2018-10-22)

Bug Fixes

  • #2909: Improve error message when a recursive dependency between fixtures is detected.
  • #3340: Fix logging messages not shown in hooks pytest_sessionstart() and pytest_sessionfinish().
  • #3533: Fix unescaped XML raw objects in JUnit report for skipped tests
  • #3691: Python 2: safely format warning message about passing unicode strings to warnings.warn, which may cause surprising MemoryError exception when monkey patching warnings.warn itself.
  • #4026: Improve error message when it is not possible to determine a function's signature.
  • #4177: Pin setuptools>=40.0 to support py_modules in setup.cfg
  • #4179: Restore the tmpdir behaviour of symlinking the current test run.
  • #4192: Fix filename reported by warnings.warn when using recwarn under python2.

pytest 3.9.1 (2018-10-16)

Features

  • #4159: For test-suites containing test classes, the information about the subclassed module is now output only if a higher verbosity level is specified (at least "-vv").

pytest 3.9.0 (2018-10-15 - not published due to a release automation bug)

Deprecations

  • #3616: The following accesses have been documented as deprecated for years, but are now actually emitting deprecation warnings.

    • Access of Module, Function, Class, Instance, File and Item through Node instances. Now users will this warning:

      usage of Function.Module is deprecated, please use pytest.Module instead
      

      Users should just import pytest and access those objects using the pytest module.

    • request.cached_setup, this was the precursor of the setup/teardown mechanism available to fixtures. You can consult funcarg comparison section in the docs.

    • Using objects named "Class" as a way to customize the type of nodes that are collected in Collector subclasses has been deprecated. Users instead should use pytest_collect_make_item to customize node types during collection.

      This issue should affect only advanced plugins who create new collection types, so if you see this warning message please contact the authors so they can change the code.

    • The warning that produces the message below has changed to RemovedInPytest4Warning:

      getfuncargvalue is deprecated, use getfixturevalue
      
  • #3988: Add a Deprecation warning for pytest.ensuretemp as it was deprecated since a while.

Features

  • #2293: Improve usage errors messages by hiding internal details which can be distracting and noisy.

    This has the side effect that some error conditions that previously raised generic errors (such as ValueError for unregistered marks) are now raising Failed exceptions.

  • #3332: Improve the error displayed when a conftest.py file could not be imported.

    In order to implement this, a new chain parameter was added to ExceptionInfo.getrepr to show or hide chained tracebacks in Python 3 (defaults to True).

  • #3849: Add empty_parameter_set_mark=fail_at_collect ini option for raising an exception when parametrize collects an empty set.

  • #3964: Log messages generated in the collection phase are shown when live-logging is enabled and/or when they are logged to a file.

  • #3985: Introduce tmp_path as a fixture providing a Path object.

  • #4013: Deprecation warnings are now shown even if you customize the warnings filters yourself. In the previous version any customization would override pytest's filters and deprecation warnings would fall back to being hidden by default.

  • #4073: Allow specification of timeout for Testdir.runpytest_subprocess() and Testdir.run().

  • #4098: Add returncode argument to pytest.exit() to exit pytest with a specific return code.

  • #4102: Reimplement pytest.deprecated_call using pytest.warns so it supports the match='...' keyword argument.

    This has the side effect that pytest.deprecated_call now raises pytest.fail.Exception instead of AssertionError.

  • #4149: Require setuptools>=30.3 and move most of the metadata to setup.cfg.

Bug Fixes

  • #2535: Improve error message when test functions of unittest.TestCase subclasses use a parametrized fixture.

  • #3057: request.fixturenames now correctly returns the name of fixtures created by request.getfixturevalue().

  • #3946: Warning filters passed as command line options using -W now take precedence over filters defined in ini configuration files.

  • #4066: Fix source reindenting by using textwrap.dedent directly.

  • #4102: pytest.warn will capture previously-warned warnings in Python 2. Previously they were never raised.

  • #4108: Resolve symbolic links for args.

    This fixes running pytest tests/test_foo.py::test_bar, where tests is a symlink to project/app/tests: previously project/app/conftest.py would be ignored for fixtures then.

  • #4132: Fix duplicate printing of internal errors when using --pdb.

  • #4135: pathlib based tmpdir cleanup now correctly handles symlinks in the folder.

  • #4152: Display the filename when encountering SyntaxWarning.

Improved Documentation

  • #3713: Update usefixtures documentation to clarify that it can't be used with fixture functions.
  • #4058: Update fixture documentation to specify that a fixture can be invoked twice in the scope it's defined for.
  • #4064: According to unittest.rst, setUpModule and tearDownModule were not implemented, but it turns out they are. So updated the documentation for unittest.
  • #4151: Add tempir testing example to CONTRIBUTING.rst guide

Trivial/Internal Changes

  • #2293: The internal MarkerError exception has been removed.
  • #3988: Port the implementation of tmpdir to pathlib.
  • #4063: Exclude 0.00 second entries from --duration output unless -vv is passed on the command-line.
  • #4093: Fixed formatting of string literals in internal tests.

pytest 3.8.2 (2018-10-02)

Deprecations and Removals

  • #4036: The item parameter of pytest_warning_captured hook is now documented as deprecated. We realized only after the 3.8 release that this parameter is incompatible with pytest-xdist.

    Our policy is to not deprecate features during bugfix releases, but in this case we believe it makes sense as we are only documenting it as deprecated, without issuing warnings which might potentially break test suites. This will get the word out that hook implementers should not use this parameter at all.

    In a future release item will always be None and will emit a proper warning when a hook implementation makes use of it.

Bug Fixes

  • #3539: Fix reload on assertion rewritten modules.

  • #4034: The .user_properties attribute of TestReport objects is a list of (name, value) tuples, but could sometimes be instantiated as a tuple of tuples. It is now always a list.

  • #4039: No longer issue warnings about using pytest_plugins in non-top-level directories when using --pyargs: the current --pyargs mechanism is not reliable and might give false negatives.

  • #4040: Exclude empty reports for passed tests when -rP option is used.

  • #4051: Improve error message when an invalid Python expression is passed to the -m option.

  • #4056: MonkeyPatch.setenv and MonkeyPatch.delenv issue a warning if the environment variable name is not str on Python 2.

    In Python 2, adding unicode keys to os.environ causes problems with subprocess (and possible other modules), making this a subtle bug specially susceptible when used with from __future__ import unicode_literals.

Improved Documentation

  • #3928: Add possible values for fixture scope to docs.

pytest 3.8.1 (2018-09-22)

Bug Fixes

  • #3286: .pytest_cache directory is now automatically ignored by Git. Users who would like to contribute a solution for other SCMs please consult/comment on this issue.

  • #3749: Fix the following error during collection of tests inside packages:

    TypeError: object of type 'Package' has no len()
    
  • #3941: Fix bug where indirect parametrization would consider the scope of all fixtures used by the test function to determine the parametrization scope, and not only the scope of the fixtures being parametrized.

  • #3973: Fix crash of the assertion rewriter if a test changed the current working directory without restoring it afterwards.

  • #3998: Fix issue that prevented some caplog properties (for example record_tuples) from being available when entering the debugger with --pdb.

  • #3999: Fix UnicodeDecodeError in python2.x when a class returns a non-ascii binary __repr__ in an assertion which also contains non-ascii text.

Improved Documentation

  • #3996: New Deprecations and Removals page shows all currently deprecated features, the rationale to do so, and alternatives to update your code. It also list features removed from pytest in past major releases to help those with ancient pytest versions to upgrade.

Trivial/Internal Changes

  • #3955: Improve pre-commit detection for changelog filenames
  • #3975: Remove legacy code around im_func as that was python2 only

pytest 3.8.0 (2018-09-05)

Deprecations and Removals

  • #2452: Config.warn and Node.warn have been deprecated, see https://docs.pytest.org/en/latest/deprecations.html#config-warn-and-node-warn for rationale and examples.

  • #3936: @pytest.mark.filterwarnings second parameter is no longer regex-escaped, making it possible to actually use regular expressions to check the warning message.

    Note: regex-escaping the match string was an implementation oversight that might break test suites which depend on the old behavior.

Features

  • #2452: Internal pytest warnings are now issued using the standard warnings module, making it possible to use the standard warnings filters to manage those warnings. This introduces PytestWarning, PytestDeprecationWarning and RemovedInPytest4Warning warning types as part of the public API.

    Consult the documentation for more info.

  • #2908: DeprecationWarning and PendingDeprecationWarning are now shown by default if no other warning filter is configured. This makes pytest more compliant with PEP-0506. See the docs for more info.

  • #3251: Warnings are now captured and displayed during test collection.

  • #3784: PYTEST_DISABLE_PLUGIN_AUTOLOAD environment variable disables plugin auto-loading when set.

  • #3829: Added the count option to console_output_style to enable displaying the progress as a count instead of a percentage.

  • #3837: Added support for 'xfailed' and 'xpassed' outcomes to the pytester.RunResult.assert_outcomes signature.

Bug Fixes

  • #3911: Terminal writer now takes into account unicode character width when writing out progress.
  • #3913: Pytest now returns with correct exit code (EXIT_USAGEERROR, 4) when called with unknown arguments.
  • #3918: Improve performance of assertion rewriting.

Improved Documentation

  • #3566: Added a blurb in usage.rst for the usage of -r flag which is used to show an extra test summary info.
  • #3907: Corrected type of the exceptions collection passed to xfail: raises argument accepts a tuple instead of list.

Trivial/Internal Changes

  • #3853: Removed "run all (no recorded failures)" message printed with --failed-first and --last-failed when there are no failed tests.

pytest 3.7.4 (2018-08-29)

Bug Fixes

  • #3506: Fix possible infinite recursion when writing .pyc files.
  • #3853: Cache plugin now obeys the -q flag when --last-failed and --failed-first flags are used.
  • #3883: Fix bad console output when using console_output_style=classic.
  • #3888: Fix macOS specific code using capturemanager plugin in doctests.

Improved Documentation

  • #3902: Fix pytest.org links

pytest 3.7.3 (2018-08-26)

Bug Fixes

  • #3033: Fixtures during teardown can again use capsys and capfd to inspect output captured during tests.
  • #3773: Fix collection of tests from __init__.py files if they match the python_files configuration option.
  • #3796: Fix issue where teardown of fixtures of consecutive sub-packages were executed once, at the end of the outer package.
  • #3816: Fix bug where --show-capture=no option would still show logs printed during fixture teardown.
  • #3819: Fix stdout/stderr not getting captured when real-time cli logging is active.
  • #3843: Fix collection error when specifying test functions directly in the command line using test.py::test syntax together with --doctest-modules.
  • #3848: Fix bugs where unicode arguments could not be passed to testdir.runpytest on Python 2.
  • #3854: Fix double collection of tests within packages when the filename starts with a capital letter.

Improved Documentation

  • #3824: Added example for multiple glob pattern matches in python_files.
  • #3833: Added missing docs for pytester.Testdir.
  • #3870: Correct documentation for setuptools integration.

Trivial/Internal Changes

  • #3826: Replace broken type annotations with type comments.
  • #3845: Remove a reference to issue #568 from the documentation, which has since been fixed.

pytest 3.7.2 (2018-08-16)

Bug Fixes

  • #3671: Fix filterwarnings not being registered as a builtin mark.
  • #3768, #3789: Fix test collection from packages mixed with normal directories.
  • #3771: Fix infinite recursion during collection if a pytest_ignore_collect hook returns False instead of None.
  • #3774: Fix bug where decorated fixtures would lose functionality (for example @mock.patch).
  • #3775: Fix bug where importing modules or other objects with prefix pytest_ prefix would raise a PluginValidationError.
  • #3788: Fix AttributeError during teardown of TestCase subclasses which raise an exception during __init__.
  • #3804: Fix traceback reporting for exceptions with __cause__ cycles.

Improved Documentation

  • #3746: Add documentation for metafunc.config that had been mistakenly hidden.

pytest 3.7.1 (2018-08-02)

Bug Fixes

  • #3473: Raise immediately if approx() is given an expected value of a type it doesn't understand (e.g. strings, nested dicts, etc.).
  • #3712: Correctly represent the dimensions of a numpy array when calling repr() on approx().
  • #3742: Fix incompatibility with third party plugins during collection, which produced the error object has no attribute '_collectfile'.
  • #3745: Display the absolute path if cache_dir is not relative to the rootdir instead of failing.
  • #3747: Fix compatibility problem with plugins and the warning code issued by fixture functions when they are called directly.
  • #3748: Fix infinite recursion in pytest.approx with arrays in numpy<1.13.
  • #3757: Pin pathlib2 to >=2.2.0 as we require __fspath__ support.
  • #3763: Fix TypeError when the assertion message is bytes in python 3.

pytest 3.7.0 (2018-07-30)

Deprecations and Removals

Features

  • #2283: New package fixture scope: fixtures are finalized when the last test of a package finishes. This feature is considered experimental, so use it sparingly.
  • #3576: Node.add_marker now supports an append=True/False parameter to determine whether the mark comes last (default) or first.
  • #3579: Fixture caplog now has a messages property, providing convenient access to the format-interpolated log messages without the extra data provided by the formatter/handler.
  • #3610: New --trace option to enter the debugger at the start of a test.
  • #3623: Introduce pytester.copy_example as helper to do acceptance tests against examples from the project.

Bug Fixes

  • #2220: Fix a bug where fixtures overridden by direct parameters (for example parametrization) were being instantiated even if they were not being used by a test.
  • #3695: Fix ApproxNumpy initialisation argument mixup, abs and rel tolerances were flipped causing strange comparison results. Add tests to check abs and rel tolerances for np.array and test for expecting nan with np.array()
  • #980: Fix truncated locals output in verbose mode.

Improved Documentation

  • #3295: Correct the usage documentation of --last-failed-no-failures by adding the missing --last-failed argument in the presented examples, because they are misleading and lead to think that the missing argument is not needed.

Trivial/Internal Changes

  • #3519: Now a README.md file is created in .pytest_cache to make it clear why the directory exists.

pytest 3.6.4 (2018-07-28)

Bug Fixes

  • Invoke pytest using -mpytest so sys.path does not get polluted by packages installed in site-packages. (#742)

Improved Documentation

  • Use smtp_connection instead of smtp in fixtures documentation to avoid possible confusion. (#3592)

Trivial/Internal Changes

  • Remove obsolete __future__ imports. (#2319)
  • Add CITATION to provide information on how to formally cite pytest. (#3402)
  • Replace broken type annotations with type comments. (#3635)
  • Pin pluggy to <0.8. (#3727)

pytest 3.6.3 (2018-07-04)

Bug Fixes

  • Fix ImportWarning triggered by explicit relative imports in assertion-rewritten package modules. (#3061)
  • Fix error in pytest.approx when dealing with 0-dimension numpy arrays. (#3593)
  • No longer raise ValueError when using the get_marker API. (#3605)
  • Fix problem where log messages with non-ascii characters would not appear in the output log file. (#3630)
  • No longer raise AttributeError when legacy marks can't be stored in functions. (#3631)

Improved Documentation

  • The description above the example for @pytest.mark.skipif now better matches the code. (#3611)

Trivial/Internal Changes

  • Internal refactoring: removed unused CallSpec2tox ._globalid_args attribute and metafunc parameter from CallSpec2.copy(). (#3598)
  • Silence usage of reduce warning in Python 2 (#3609)
  • Fix usage of attr.ib deprecated convert parameter. (#3653)

pytest 3.6.2 (2018-06-20)

Bug Fixes

  • Fix regression in Node.add_marker by extracting the mark object of a MarkDecorator. (#3555)
  • Warnings without location were reported as None. This is corrected to now report <undetermined location>. (#3563)
  • Continue to call finalizers in the stack when a finalizer in a former scope raises an exception. (#3569)
  • Fix encoding error with print statements in doctests (#3583)

Improved Documentation

  • Add documentation for the --strict flag. (#3549)

Trivial/Internal Changes

  • Update old quotation style to parens in fixture.rst documentation. (#3525)
  • Improve display of hint about --fulltrace with KeyboardInterrupt. (#3545)
  • pytest's testsuite is no longer runnable through python setup.py test -- instead invoke pytest or tox directly. (#3552)
  • Fix typo in documentation (#3567)

pytest 3.6.1 (2018-06-05)

Bug Fixes

  • Fixed a bug where stdout and stderr were logged twice by junitxml when a test was marked xfail. (#3491)
  • Fix usefixtures mark applyed to unittest tests by correctly instantiating FixtureInfo. (#3498)
  • Fix assertion rewriter compatibility with libraries that monkey patch file objects. (#3503)

Improved Documentation

  • Added a section on how to use fixtures as factories to the fixture documentation. (#3461)

Trivial/Internal Changes

  • Enable caching for pip/pre-commit in order to reduce build time on travis/appveyor. (#3502)
  • Switch pytest to the src/ layout as we already suggested it for good practice - now we implement it as well. (#3513)
  • Fix if in tests to support 3.7.0b5, where a docstring handling in AST got reverted. (#3530)
  • Remove some python2.5 compatibility code. (#3529)

pytest 3.6.0 (2018-05-23)

Features

  • Revamp the internals of the pytest.mark implementation with correct per node handling which fixes a number of long standing bugs caused by the old design. This introduces new Node.iter_markers(name) and Node.get_closest_marker(name) APIs. Users are strongly encouraged to read the reasons for the revamp in the docs, or jump over to details about updating existing code to use the new APIs. (#3317)
  • Now when @pytest.fixture is applied more than once to the same function a ValueError is raised. This buggy behavior would cause surprising problems and if was working for a test suite it was mostly by accident. (#2334)
  • Support for Python 3.7's builtin breakpoint() method, see Using the builtin breakpoint function for details. (#3180)
  • monkeypatch now supports a context() function which acts as a context manager which undoes all patching done within the with block. (#3290)
  • The --pdb option now causes KeyboardInterrupt to enter the debugger, instead of stopping the test session. On python 2.7, hitting CTRL+C again exits the debugger. On python 3.2 and higher, use CTRL+D. (#3299)
  • pytest no longer changes the log level of the root logger when the log-level parameter has greater numeric value than that of the level of the root logger, which makes it play better with custom logging configuration in user code. (#3307)

Bug Fixes

  • A rare race-condition which might result in corrupted .pyc files on Windows has been hopefully solved. (#3008)
  • Also use iter_marker for discovering the marks applying for marker expressions from the cli to avoid the bad data from the legacy mark storage. (#3441)
  • When showing diffs of failed assertions where the contents contain only whitespace, escape them using repr() first to make it easy to spot the differences. (#3443)

Improved Documentation

  • Change documentation copyright year to a range which auto-updates itself each time it is published. (#3303)

Trivial/Internal Changes

  • pytest now depends on the python-atomicwrites library. (#3008)
  • Update all pypi.python.org URLs to pypi.org. (#3431)
  • Detect pytest_ prefixed hooks using the internal plugin manager since pluggy is deprecating the implprefix argument to PluginManager. (#3487)
  • Import Mapping and Sequence from _pytest.compat instead of directly from collections in python_api.py::approx. Add Mapping to _pytest.compat, import it from collections on python 2, but from collections.abc on Python 3 to avoid a DeprecationWarning on Python 3.7 or newer. (#3497)

pytest 3.5.1 (2018-04-23)

Bug Fixes

  • Reset sys.last_type, sys.last_value and sys.last_traceback before each test executes. Those attributes are added by pytest during the test run to aid debugging, but were never reset so they would create a leaking reference to the last failing test's frame which in turn could never be reclaimed by the garbage collector. (#2798)
  • pytest.raises now raises TypeError when receiving an unknown keyword argument. (#3348)
  • pytest.raises now works with exception classes that look like iterables. (#3372)

Improved Documentation

  • Fix typo in caplog fixture documentation, which incorrectly identified certain attributes as methods. (#3406)

Trivial/Internal Changes

  • Added a more indicative error message when parametrizing a function whose argument takes a default value. (#3221)
  • Remove internal _pytest.terminal.flatten function in favor of more_itertools.collapse. (#3330)
  • Import some modules from collections.abc instead of collections as the former modules trigger DeprecationWarning in Python 3.7. (#3339)
  • record_property is no longer experimental, removing the warnings was forgotten. (#3360)
  • Mention in documentation and CLI help that fixtures with leading _ are printed by pytest --fixtures only if the -v option is added. (#3398)

pytest 3.5.0 (2018-03-21)

Deprecations and Removals

  • record_xml_property fixture is now deprecated in favor of the more generic record_property. (#2770)
  • Defining pytest_plugins is now deprecated in non-top-level conftest.py files, because they "leak" to the entire directory tree. See the docs for the rationale behind this decision (#3084)

Features

  • New --show-capture command-line option that allows to specify how to display captured output when tests fail: no, stdout, stderr, log or all (the default). (#1478)
  • New --rootdir command-line option to override the rules for discovering the root directory. See customize in the documentation for details. (#1642)
  • Fixtures are now instantiated based on their scopes, with higher-scoped fixtures (such as session) being instantiated first than lower-scoped fixtures (such as function). The relative order of fixtures of the same scope is kept unchanged, based in their declaration order and their dependencies. (#2405)
  • record_xml_property renamed to record_property and is now compatible with xdist, markers and any reporter. record_xml_property name is now deprecated. (#2770)
  • New --nf, --new-first options: run new tests first followed by the rest of the tests, in both cases tests are also sorted by the file modified time, with more recent files coming first. (#3034)
  • New --last-failed-no-failures command-line option that allows to specify the behavior of the cache plugin's `--last-failed feature when no tests failed in the last run (or no cache was found): none or all (the default). (#3139)
  • New --doctest-continue-on-failure command-line option to enable doctests to show multiple failures for each snippet, instead of stopping at the first failure. (#3149)
  • Captured log messages are added to the <system-out> tag in the generated junit xml file if the junit_logging ini option is set to system-out. If the value of this ini option is system-err, the logs are written to <system-err>. The default value for junit_logging is no, meaning captured logs are not written to the output file. (#3156)
  • Allow the logging plugin to handle pytest_runtest_logstart and pytest_runtest_logfinish hooks when live logs are enabled. (#3189)
  • Passing --log-cli-level in the command-line now automatically activates live logging. (#3190)
  • Add command line option --deselect to allow deselection of individual tests at collection time. (#3198)
  • Captured logs are printed before entering pdb. (#3204)
  • Deselected item count is now shown before tests are run, e.g. collected X items / Y deselected. (#3213)
  • The builtin module platform is now available for use in expressions in pytest.mark. (#3236)
  • The short test summary info section now is displayed after tracebacks and warnings in the terminal. (#3255)
  • New --verbosity flag to set verbosity level explicitly. (#3296)
  • pytest.approx now accepts comparing a numpy array with a scalar. (#3312)

Bug Fixes

  • Suppress IOError when closing the temporary file used for capturing streams in Python 2.7. (#2370)
  • Fixed clear() method on caplog fixture which cleared records, but not the text property. (#3297)
  • During test collection, when stdin is not allowed to be read, the DontReadFromStdin object still allow itself to be iterable and resolved to an iterator without crashing. (#3314)

Improved Documentation

Trivial/Internal Changes

  • Change minimum requirement of attrs to 17.4.0. (#3228)
  • Renamed example directories so all tests pass when ran from the base directory. (#3245)
  • Internal mark.py module has been turned into a package. (#3250)
  • pytest now depends on the more-itertools package. (#3265)
  • Added warning when [pytest] section is used in a .cfg file passed with -c (#3268)
  • nodeids can now be passed explicitly to FSCollector and Node constructors. (#3291)
  • Internal refactoring of FormattedExcinfo to use attrs facilities and remove old support code for legacy Python versions. (#3292)
  • Refactoring to unify how verbosity is handled internally. (#3296)
  • Internal refactoring to better integrate with argparse. (#3304)
  • Fix a python example when calling a fixture in doc/en/usage.rst (#3308)

pytest 3.4.2 (2018-03-04)

Bug Fixes

  • Removed progress information when capture option is no. (#3203)
  • Refactor check of bindir from exists to isdir. (#3241)
  • Fix TypeError issue when using approx with a Decimal value. (#3247)
  • Fix reference cycle generated when using the request fixture. (#3249)
  • [tool:pytest] sections in *.cfg files passed by the -c option are now properly recognized. (#3260)

Improved Documentation

  • Add logging plugin to plugins list. (#3209)

Trivial/Internal Changes

  • Fix minor typo in fixture.rst (#3259)

pytest 3.4.1 (2018-02-20)

Bug Fixes

  • Move import of doctest.UnexpectedException to top-level to avoid possible errors when using --pdb. (#1810)
  • Added printing of captured stdout/stderr before entering pdb, and improved a test which was giving false negatives about output capturing. (#3052)
  • Fix ordering of tests using parametrized fixtures which can lead to fixtures being created more than necessary. (#3161)
  • Fix bug where logging happening at hooks outside of "test run" hooks would cause an internal error. (#3184)
  • Detect arguments injected by unittest.mock.patch decorator correctly when pypi mock.patch is installed and imported. (#3206)
  • Errors shown when a pytest.raises() with match= fails are now cleaner on what happened: When no exception was raised, the "matching '...'" part got removed as it falsely implies that an exception was raised but it didn't match. When a wrong exception was raised, it's now thrown (like pytest.raised() without match= would) instead of complaining about the unmatched text. (#3222)
  • Fixed output capture handling in doctests on macOS. (#985)

Improved Documentation

  • Add Sphinx parameter docs for match and message args to pytest.raises. (#3202)

Trivial/Internal Changes

  • pytest has changed the publication procedure and is now being published to PyPI directly from Travis. (#3060)
  • Rename ParameterSet._for_parameterize() to _for_parametrize() in order to comply with the naming convention. (#3166)
  • Skip failing pdb/doctest test on mac. (#985)

pytest 3.4.0 (2018-01-30)

Deprecations and Removals

  • All pytest classes now subclass object for better Python 2/3 compatibility. This should not affect user code except in very rare edge cases. (#2147)

Features

  • Introduce empty_parameter_set_mark ini option to select which mark to apply when @pytest.mark.parametrize is given an empty set of parameters. Valid options are skip (default) and xfail. Note that it is planned to change the default to xfail in future releases as this is considered less error prone. (#2527)
  • Incompatible change: after community feedback the logging functionality has undergone some changes. Please consult the logging documentation for details. (#3013)
  • Console output falls back to "classic" mode when capturing is disabled (-s), otherwise the output gets garbled to the point of being useless. (#3038)
  • New pytest_runtest_logfinish hook which is called when a test item has finished executing, analogous to pytest_runtest_logstart. (#3101)
  • Improve performance when collecting tests using many fixtures. (#3107)
  • New caplog.get_records(when) method which provides access to the captured records for the "setup", "call" and "teardown" testing stages. (#3117)
  • New fixture record_xml_attribute that allows modifying and inserting attributes on the <testcase> xml node in JUnit reports. (#3130)
  • The default cache directory has been renamed from .cache to .pytest_cache after community feedback that the name .cache did not make it clear that it was used by pytest. (#3138)
  • Colorize the levelname column in the live-log output. (#3142)

Bug Fixes

  • Fix hanging pexpect test on MacOS by using flush() instead of wait(). (#2022)
  • Fix restoring Python state after in-process pytest runs with the pytester plugin; this may break tests using multiple inprocess pytest runs if later ones depend on earlier ones leaking global interpreter changes. (#3016)
  • Fix skipping plugin reporting hook when test aborted before plugin setup hook. (#3074)
  • Fix progress percentage reported when tests fail during teardown. (#3088)
  • Incompatible change: -o/--override option no longer eats all the remaining options, which can lead to surprising behavior: for example, pytest -o foo=1 /path/to/test.py would fail because /path/to/test.py would be considered as part of the -o command-line argument. One consequence of this is that now multiple configuration overrides need multiple -o flags: pytest -o foo=1 -o bar=2. (#3103)

Improved Documentation

  • Document hooks (defined with historic=True) which cannot be used with hookwrapper=True. (#2423)
  • Clarify that warning capturing doesn't change the warning filter by default. (#2457)
  • Clarify a possible confusion when using pytest_fixture_setup with fixture functions that return None. (#2698)
  • Fix the wording of a sentence on doctest flags used in pytest. (#3076)
  • Prefer https://*.readthedocs.io over http://*.rtfd.org for links in the documentation. (#3092)
  • Improve readability (wording, grammar) of Getting Started guide (#3131)
  • Added note that calling pytest.main multiple times from the same process is not recommended because of import caching. (#3143)

Trivial/Internal Changes

  • Show a simple and easy error when keyword expressions trigger a syntax error (for example, "-k foo and import" will show an error that you can not use the import keyword in expressions). (#2953)
  • Change parametrized automatic test id generation to use the __name__ attribute of functions instead of the fallback argument name plus counter. (#2976)
  • Replace py.std with stdlib imports. (#3067)
  • Corrected 'you' to 'your' in logging docs. (#3129)

pytest 3.3.2 (2017-12-25)

Bug Fixes

  • pytester: ignore files used to obtain current user metadata in the fd leak detector. (#2784)
  • Fix memory leak where objects returned by fixtures were never destructed by the garbage collector. (#2981)
  • Fix conversion of pyargs to filename to not convert symlinks on Python 2. (#2985)
  • PYTEST_DONT_REWRITE is now checked for plugins too rather than only for test modules. (#2995)

Improved Documentation

  • Add clarifying note about behavior of multiple parametrized arguments (#3001)

Trivial/Internal Changes

  • Code cleanup. (#3015, #3021)
  • Clean up code by replacing imports and references of _ast to ast. (#3018)

pytest 3.3.1 (2017-12-05)

Bug Fixes

  • Fix issue about -p no:<plugin> having no effect. (#2920)
  • Fix regression with warnings that contained non-strings in their arguments in Python 2. (#2956)
  • Always escape null bytes when setting PYTEST_CURRENT_TEST. (#2957)
  • Fix ZeroDivisionError when using the testmon plugin when no tests were actually collected. (#2971)
  • Bring back TerminalReporter.writer as an alias to TerminalReporter._tw. This alias was removed by accident in the 3.3.0 release. (#2984)
  • The pytest-capturelog plugin is now also blacklisted, avoiding errors when running pytest with it still installed. (#3004)

Improved Documentation

  • Fix broken link to plugin pytest-localserver. (#2963)

Trivial/Internal Changes

  • Update github "bugs" link in CONTRIBUTING.rst (#2949)

pytest 3.3.0 (2017-11-23)

Deprecations and Removals

  • pytest no longer supports Python 2.6 and 3.3. Those Python versions are EOL for some time now and incur maintenance and compatibility costs on the pytest core team, and following up with the rest of the community we decided that they will no longer be supported starting on this version. Users which still require those versions should pin pytest to <3.3. (#2812)
  • Remove internal _preloadplugins() function. This removal is part of the pytest_namespace() hook deprecation. (#2636)
  • Internally change CallSpec2 to have a list of marks instead of a broken mapping of keywords. This removes the keywords attribute of the internal CallSpec2 class. (#2672)
  • Remove ParameterSet.deprecated_arg_dict - its not a public api and the lack of the underscore was a naming error. (#2675)
  • Remove the internal multi-typed attribute Node._evalskip and replace it with the boolean Node._skipped_by_mark. (#2767)
  • The params list passed to pytest.fixture is now for all effects considered immutable and frozen at the moment of the pytest.fixture call. Previously the list could be changed before the first invocation of the fixture allowing for a form of dynamic parametrization (for example, updated from command-line options), but this was an unwanted implementation detail which complicated the internals and prevented some internal cleanup. See issue #2959 for details and a recommended workaround.

Features

  • pytest_fixture_post_finalizer hook can now receive a request argument. (#2124)
  • Replace the old introspection code in compat.py that determines the available arguments of fixtures with inspect.signature on Python 3 and funcsigs.signature on Python 2. This should respect __signature__ declarations on functions. (#2267)
  • Report tests with global pytestmark variable only once. (#2549)
  • Now pytest displays the total progress percentage while running tests. The previous output style can be set by configuring the console_output_style setting to classic. (#2657)
  • Match warns signature to raises by adding match keyword. (#2708)
  • pytest now captures and displays output from the standard logging module. The user can control the logging level to be captured by specifying options in pytest.ini, the command line and also during individual tests using markers. Also, a caplog fixture is available that enables users to test the captured log during specific tests (similar to capsys for example). For more information, please see the logging docs. This feature was introduced by merging the popular pytest-catchlog plugin, thanks to Thomas Hisch. Be advised that during the merging the backward compatibility interface with the defunct pytest-capturelog has been dropped. (#2794)
  • Add allow_module_level kwarg to pytest.skip(), enabling to skip the whole module. (#2808)
  • Allow setting file_or_dir, -c, and -o in PYTEST_ADDOPTS. (#2824)
  • Return stdout/stderr capture results as a namedtuple, so out and err can be accessed by attribute. (#2879)
  • Add capfdbinary, a version of capfd which returns bytes from readouterr(). (#2923)
  • Add capsysbinary a version of capsys which returns bytes from readouterr(). (#2934)
  • Implement feature to skip setup.py files when run with --doctest-modules. (#502)

Bug Fixes

  • Resume output capturing after capsys/capfd.disabled() context manager. (#1993)
  • pytest_fixture_setup and pytest_fixture_post_finalizer hooks are now called for all conftest.py files. (#2124)
  • If an exception happens while loading a plugin, pytest no longer hides the original traceback. In Python 2 it will show the original traceback with a new message that explains in which plugin. In Python 3 it will show 2 canonized exceptions, the original exception while loading the plugin in addition to an exception that pytest throws about loading a plugin. (#2491)
  • capsys and capfd can now be used by other fixtures. (#2709)
  • Internal pytester plugin properly encodes bytes arguments to utf-8. (#2738)
  • testdir now uses use the same method used by tmpdir to create its temporary directory. This changes the final structure of the testdir directory slightly, but should not affect usage in normal scenarios and avoids a number of potential problems. (#2751)
  • pytest no longer complains about warnings with unicode messages being non-ascii compatible even for ascii-compatible messages. As a result of this, warnings with unicode messages are converted first to an ascii representation for safety. (#2809)
  • Change return value of pytest command when --maxfail is reached from 2 (interrupted) to 1 (failed). (#2845)
  • Fix issue in assertion rewriting which could lead it to rewrite modules which should not be rewritten. (#2939)
  • Handle marks without description in pytest.ini. (#2942)

Trivial/Internal Changes

  • pytest now depends on attrs for internal structures to ease code maintainability. (#2641)
  • Refactored internal Python 2/3 compatibility code to use six. (#2642)
  • Stop vendoring pluggy - we're missing out on its latest changes for not much benefit (#2719)
  • Internal refactor: simplify ascii string escaping by using the backslashreplace error handler in newer Python 3 versions. (#2734)
  • Remove unnecessary mark evaluator in unittest plugin (#2767)
  • Calls to Metafunc.addcall now emit a deprecation warning. This function is scheduled to be removed in pytest-4.0. (#2876)
  • Internal move of the parameterset extraction to a more maintainable place. (#2877)
  • Internal refactoring to simplify scope node lookup. (#2910)
  • Configure pytest to prevent pip from installing pytest in unsupported Python versions. (#2922)

pytest 3.2.5 (2017-11-15)

Bug Fixes

  • Remove py<1.5 restriction from pytest as this can cause version conflicts in some installations. (#2926)

pytest 3.2.4 (2017-11-13)

Bug Fixes

  • Fix the bug where running with --pyargs will result in items with empty parent.nodeid if run from a different root directory. (#2775)
  • Fix issue with @pytest.parametrize if argnames was specified as keyword arguments. (#2819)
  • Strip whitespace from marker names when reading them from INI config. (#2856)
  • Show full context of doctest source in the pytest output, if the line number of failed example in the docstring is < 9. (#2882)
  • Match fixture paths against actual path segments in order to avoid matching folders which share a prefix. (#2836)

Improved Documentation

  • Introduce a dedicated section about conftest.py. (#1505)
  • Explicitly mention xpass in the documentation of xfail. (#1997)
  • Append example for pytest.param in the example/parametrize document. (#2658)
  • Clarify language of proposal for fixtures parameters (#2893)
  • List python 3.6 in the documented supported versions in the getting started document. (#2903)
  • Clarify the documentation of available fixture scopes. (#538)
  • Add documentation about the python -m pytest invocation adding the current directory to sys.path. (#911)

pytest 3.2.3 (2017-10-03)

Bug Fixes

  • Fix crash in tab completion when no prefix is given. (#2748)
  • The equality checking function (__eq__) of MarkDecorator returns False if one object is not an instance of MarkDecorator. (#2758)
  • When running pytest --fixtures-per-test: don't crash if an item has no _fixtureinfo attribute (e.g. doctests) (#2788)

Improved Documentation

  • In help text of -k option, add example of using not to not select certain tests whose names match the provided expression. (#1442)
  • Add note in parametrize.rst about calling metafunc.parametrize multiple times. (#1548)

Trivial/Internal Changes

  • Set xfail_strict=True in pytest's own test suite to catch expected failures as soon as they start to pass. (#2722)
  • Fix typo in example of passing a callable to markers (in example/markers.rst) (#2765)

pytest 3.2.2 (2017-09-06)

Bug Fixes

  • Calling the deprecated request.getfuncargvalue() now shows the source of the call. (#2681)
  • Allow tests declared as @staticmethod to use fixtures. (#2699)
  • Fixed edge-case during collection: attributes which raised pytest.fail when accessed would abort the entire collection. (#2707)
  • Fix ReprFuncArgs with mixed unicode and UTF-8 args. (#2731)

Improved Documentation

  • In examples on working with custom markers, add examples demonstrating the usage of pytest.mark.MARKER_NAME.with_args in comparison with pytest.mark.MARKER_NAME.__call__ (#2604)
  • In one of the simple examples, use pytest_collection_modifyitems() to skip tests based on a command-line option, allowing its sharing while preventing a user error when acessing pytest.config before the argument parsing. (#2653)

Trivial/Internal Changes

  • Fixed minor error in 'Good Practices/Manual Integration' code snippet. (#2691)
  • Fixed typo in goodpractices.rst. (#2721)
  • Improve user guidance regarding --resultlog deprecation. (#2739)

pytest 3.2.1 (2017-08-08)

Bug Fixes

  • Fixed small terminal glitch when collecting a single test item. (#2579)
  • Correctly consider / as the file separator to automatically mark plugin files for rewrite on Windows. (#2591)
  • Properly escape test names when setting PYTEST_CURRENT_TEST environment variable. (#2644)
  • Fix error on Windows and Python 3.6+ when sys.stdout has been replaced with a stream-like object which does not implement the full io module buffer protocol. In particular this affects pytest-xdist users on the aforementioned platform. (#2666)

Improved Documentation

  • Explicitly document which pytest features work with unittest. (#2626)

pytest 3.2.0 (2017-07-30)

Deprecations and Removals

  • pytest.approx no longer supports >, >=, < and <= operators to avoid surprising/inconsistent behavior. See the approx docs for more information. (#2003)
  • All old-style specific behavior in current classes in the pytest's API is considered deprecated at this point and will be removed in a future release. This affects Python 2 users only and in rare situations. (#2147)
  • A deprecation warning is now raised when using marks for parameters in pytest.mark.parametrize. Use pytest.param to apply marks to parameters instead. (#2427)

Features

  • Add support for numpy arrays (and dicts) to approx. (#1994)
  • Now test function objects have a pytestmark attribute containing a list of marks applied directly to the test function, as opposed to marks inherited from parent classes or modules. (#2516)
  • Collection ignores local virtualenvs by default; --collect-in-virtualenv overrides this behavior. (#2518)
  • Allow class methods decorated as @staticmethod to be candidates for collection as a test function. (Only for Python 2.7 and above. Python 2.6 will still ignore static methods.) (#2528)
  • Introduce mark.with_args in order to allow passing functions/classes as sole argument to marks. (#2540)
  • New cache_dir ini option: sets the directory where the contents of the cache plugin are stored. Directory may be relative or absolute path: if relative path, then directory is created relative to rootdir, otherwise it is used as is. Additionally path may contain environment variables which are expanded during runtime. (#2543)
  • Introduce the PYTEST_CURRENT_TEST environment variable that is set with the nodeid and stage (setup, call and teardown) of the test being currently executed. See the documentation for more info. (#2583)
  • Introduced @pytest.mark.filterwarnings mark which allows overwriting the warnings filter on a per test, class or module level. See the docs for more information. (#2598)
  • --last-failed now remembers forever when a test has failed and only forgets it if it passes again. This makes it easy to fix a test suite by selectively running files and fixing tests incrementally. (#2621)
  • New pytest_report_collectionfinish hook which allows plugins to add messages to the terminal reporting after collection has been finished successfully. (#2622)
  • Added support for PEP-415's Exception.__suppress_context__. Now if a raise exception from None is caught by pytest, pytest will no longer chain the context in the test report. The behavior now matches Python's traceback behavior. (#2631)
  • Exceptions raised by pytest.fail, pytest.skip and pytest.xfail now subclass BaseException, making them harder to be caught unintentionally by normal code. (#580)

Bug Fixes

  • Set stdin to a closed PIPE in pytester.py.Testdir.popen() for avoid unwanted interactive pdb (#2023)
  • Add missing encoding attribute to sys.std* streams when using capsys capture mode. (#2375)
  • Fix terminal color changing to black on Windows if colorama is imported in a conftest.py file. (#2510)
  • Fix line number when reporting summary of skipped tests. (#2548)
  • capture: ensure that EncodedFile.name is a string. (#2555)
  • The options --fixtures and --fixtures-per-test will now keep indentation within docstrings. (#2574)
  • doctests line numbers are now reported correctly, fixing pytest-sugar#122. (#2610)
  • Fix non-determinism in order of fixture collection. Adds new dependency (ordereddict) for Python 2.6. (#920)

Improved Documentation

  • Clarify pytest_configure hook call order. (#2539)
  • Extend documentation for testing plugin code with the pytester plugin. (#971)

Trivial/Internal Changes

  • Update help message for --strict to make it clear it only deals with unregistered markers, not warnings. (#2444)
  • Internal code move: move code for pytest.approx/pytest.raises to own files in order to cut down the size of python.py (#2489)
  • Renamed the utility function _pytest.compat._escape_strings to _ascii_escaped to better communicate the function's purpose. (#2533)
  • Improve error message for CollectError with skip/skipif. (#2546)
  • Emit warning about yield tests being deprecated only once per generator. (#2562)
  • Ensure final collected line doesn't include artifacts of previous write. (#2571)
  • Fixed all flake8 errors and warnings. (#2581)
  • Added fix-lint tox environment to run automatic pep8 fixes on the code. (#2582)
  • Turn warnings into errors in pytest's own test suite in order to catch regressions due to deprecations more promptly. (#2588)
  • Show multiple issue links in CHANGELOG entries. (#2620)

pytest 3.1.3 (2017-07-03)

Bug Fixes

  • Fix decode error in Python 2 for doctests in docstrings. (#2434)
  • Exceptions raised during teardown by finalizers are now suppressed until all finalizers are called, with the initial exception reraised. (#2440)
  • Fix incorrect "collected items" report when specifying tests on the command- line. (#2464)
  • deprecated_call in context-manager form now captures deprecation warnings even if the same warning has already been raised. Also, deprecated_call will always produce the same error message (previously it would produce different messages in context-manager vs. function-call mode). (#2469)
  • Fix issue where paths collected by pytest could have triple leading / characters. (#2475)
  • Fix internal error when trying to detect the start of a recursive traceback. (#2486)

Improved Documentation

  • Explicitly state for which hooks the calls stop after the first non-None result. (#2493)

Trivial/Internal Changes

  • Create invoke tasks for updating the vendored packages. (#2474)
  • Update copyright dates in LICENSE, README.rst and in the documentation. (#2499)

pytest 3.1.2 (2017-06-08)

Bug Fixes

  • Required options added via pytest_addoption will no longer prevent using --help without passing them. (#1999)
  • Respect python_files in assertion rewriting. (#2121)
  • Fix recursion error detection when frames in the traceback contain objects that can't be compared (like numpy arrays). (#2459)
  • UnicodeWarning is issued from the internal pytest warnings plugin only when the message contains non-ascii unicode (Python 2 only). (#2463)
  • Added a workaround for Python 3.6 WindowsConsoleIO breaking due to Pytests's FDCapture. Other code using console handles might still be affected by the very same issue and might require further workarounds/fixes, i.e. colorama. (#2467)

Improved Documentation

  • Fix internal API links to pluggy objects. (#2331)
  • Make it clear that pytest.xfail stops test execution at the calling point and improve overall flow of the skipping docs. (#810)

pytest 3.1.1 (2017-05-30)

Bug Fixes

  • pytest warning capture no longer overrides existing warning filters. The previous behaviour would override all filters and caused regressions in test suites which configure warning filters to match their needs. Note that as a side-effect of this is that DeprecationWarning and PendingDeprecationWarning are no longer shown by default. (#2430)
  • Fix issue with non-ascii contents in doctest text files. (#2434)
  • Fix encoding errors for unicode warnings in Python 2. (#2436)
  • pytest.deprecated_call now captures PendingDeprecationWarning in context manager form. (#2441)

Improved Documentation

  • Addition of towncrier for changelog management. (#2390)

3.1.0 (2017-05-22)

New Features

  • The pytest-warnings plugin has been integrated into the core and now pytest automatically captures and displays warnings at the end of the test session.

    Warning

    This feature may disrupt test suites which apply and treat warnings themselves, and can be disabled in your pytest.ini:

    [pytest]
    addopts = -p no:warnings
    

    See the warnings documentation page for more information.

    Thanks @nicoddemus for the PR.

  • Added junit_suite_name ini option to specify root <testsuite> name for JUnit XML reports (#533).

  • Added an ini option doctest_encoding to specify which encoding to use for doctest files. Thanks @wheerd for the PR (#2101).

  • pytest.warns now checks for subclass relationship rather than class equality. Thanks @lesteve for the PR (#2166)

  • pytest.raises now asserts that the error message matches a text or regex with the match keyword argument. Thanks @Kriechi for the PR.

  • pytest.param can be used to declare test parameter sets with marks and test ids. Thanks @RonnyPfannschmidt for the PR.

Changes

  • remove all internal uses of pytest_namespace hooks, this is to prepare the removal of preloadconfig in pytest 4.0 Thanks to @RonnyPfannschmidt for the PR.
  • pytest now warns when a callable ids raises in a parametrized test. Thanks @fogo for the PR.
  • It is now possible to skip test classes from being collected by setting a __test__ attribute to False in the class body (#2007). Thanks to @syre for the report and @lwm for the PR.
  • Change junitxml.py to produce reports that comply with Junitxml schema. If the same test fails with failure in call and then errors in teardown we split testcase element into two, one containing the error and the other the failure. (#2228) Thanks to @kkoukiou for the PR.
  • Testcase reports with a url attribute will now properly write this to junitxml. Thanks @fushi for the PR (#1874).
  • Remove common items from dict comparison output when verbosity=1. Also update the truncation message to make it clearer that pytest truncates all assertion messages if verbosity < 2 (#1512). Thanks @mattduck for the PR
  • --pdbcls no longer implies --pdb. This makes it possible to use addopts=--pdbcls=module.SomeClass on pytest.ini. Thanks @davidszotten for the PR (#1952).
  • fix #2013: turn RecordedWarning into namedtuple, to give it a comprehensible repr while preventing unwarranted modification.
  • fix #2208: ensure an iteration limit for _pytest.compat.get_real_func. Thanks @RonnyPfannschmidt for the report and PR.
  • Hooks are now verified after collection is complete, rather than right after loading installed plugins. This makes it easy to write hooks for plugins which will be loaded during collection, for example using the pytest_plugins special variable (#1821). Thanks @nicoddemus for the PR.
  • Modify pytest_make_parametrize_id() hook to accept argname as an additional parameter. Thanks @unsignedint for the PR.
  • Add venv to the default norecursedirs setting. Thanks @The-Compiler for the PR.
  • PluginManager.import_plugin now accepts unicode plugin names in Python 2. Thanks @reutsharabani for the PR.
  • fix #2308: When using both --lf and --ff, only the last failed tests are run. Thanks @ojii for the PR.
  • Replace minor/patch level version numbers in the documentation with placeholders. This significantly reduces change-noise as different contributors regnerate the documentation on different platforms. Thanks @RonnyPfannschmidt for the PR.
  • fix #2391: consider pytest_plugins on all plugin modules Thanks @RonnyPfannschmidt for the PR.

Bug Fixes

  • Fix AttributeError on sys.stdout.buffer / sys.stderr.buffer while using capsys fixture in python 3. (#1407). Thanks to @asottile.
  • Change capture.py's DontReadFromInput class to throw io.UnsupportedOperation errors rather than ValueErrors in the fileno method (#2276). Thanks @metasyn and @vlad-dragos for the PR.
  • Fix exception formatting while importing modules when the exception message contains non-ascii characters (#2336). Thanks @fabioz for the report and @nicoddemus for the PR.
  • Added documentation related to issue (#1937) Thanks @skylarjhdownes for the PR.
  • Allow collecting files with any file extension as Python modules (#2369). Thanks @Kodiologist for the PR.
  • Show the correct error message when collect "parametrize" func with wrong args (#2383). Thanks @The-Compiler for the report and @robin0371 for the PR.

3.0.7 (2017-03-14)

3.0.6 (2017-01-22)

3.0.5 (2016-12-05)

3.0.4 (2016-11-09)

3.0.3 (2016-09-28)

3.0.2 (2016-09-01)

3.0.1 (2016-08-23)

3.0.0 (2016-08-18)

Incompatible changes

A number of incompatible changes were made in this release, with the intent of removing features deprecated for a long time or change existing behaviors in order to make them less surprising/more useful.

New Features

Changes

Bug Fixes

2.9.2 (2016-05-31)

Bug Fixes

2.9.1 (2016-03-17)

Bug Fixes

2.9.0 (2016-02-29)

New Features

Changes

Bug Fixes

2.8.7 (2016-01-24)

2.8.6 (2016-01-21)

2.8.5 (2015-12-11)

2.8.4 (2015-12-06)

2.8.3 (2015-11-18)

2.8.2 (2015-10-07)

2.8.1 (2015-09-29)

2.8.0 (2015-09-18)

2.7.3 (2015-09-15)

2.7.2 (2015-06-23)

2.7.1 (2015-05-19)

2.7.0 (2015-03-26)

2.6.4 (2014-10-24)

2.6.3 (2014-09-24)

2.6.2 (2014-09-05)

2.6.1 (2014-08-07)

2.6

2.5.2 (2014-01-29)

2.5.1 (2013-12-17)

2.5.0 (2013-12-12)

2.4.2 (2013-10-04)

2.4.1 (2013-10-02)

2.4

known incompatibilities:

new features:

Bug fixes:

2.3.5 (2013-04-30)

2.3.4 (2012-11-20)

2.3.3 (2012-11-06)

2.3.2 (2012-10-25)

2.3.1 (2012-10-20)

2.3.0 (2012-10-19)

2.2.4 (2012-05-22)

2.2.3 (2012-02-05)

2.2.2 (2012-02-05)

2.2.1 (2011-12-16)

2.2.0 (2011-11-18)

2.1.3 (2011-10-18)

2.1.2 (2011-09-24)

2.1.1

2.1.0 (2011-07-09)

2.0.3 (2011-05-11)

2.0.2 (2011-03-09)

2.0.1 (2011-02-07)

2.0.0 (2010-11-25)

1.3.4 (2010-09-14)

1.3.3 (2010-07-30)

1.3.2 (2010-07-08)

New features

Bug fixes

1.3.1 (2010-05-25)

New features

Bug Fixes

1.3.0 (2010-05-05)

1.2.0 (2010-01-18)

1.1.1 (2009-11-24)

1.1.0 (2009-11-05)

1.0.3

1.0.2 (2009-08-27)

1.0.1 (2009-08-19)

1.0.0 (2009-08-04)

1.0.0b9 (2009-07-31)

1.0.0b8 (2009-07-22)

1.0.0b7

1.0.0b3 (2009-06-19)

1.0.0b1

XXX lots of things missing here XXX

0.9.2

0.9.1

This is a fairly complete list of v0.9.1, which can serve as a reference for developers.