pytest v6.1.0 Release Notes

Release Date: 2020-09-26 // over 1 year ago
  • โœ… pytest 6.1.0 (2020-09-26)

    ๐Ÿ’ฅ Breaking Changes

    โœ… #5585: As per our policy, the following features which have been deprecated in the 5.X series are now
    โœ‚ removed:

    • The funcargnames read-only property of FixtureRequest, Metafunc, and Function classes. Use fixturenames attribute.
    • @pytest.fixture no longer supports positional arguments, pass all arguments by keyword instead.
    • Direct construction of Node subclasses now raise an error, use from_parent instead.
    • The default value for junit_family has changed to xunit2. If you require the old format, add junit_family=xunit1 to your configuration file.
    • The TerminalReporter no longer has a writer attribute. Plugin authors may use the public functions of the TerminalReporter instead of accessing the TerminalWriter object directly.
    • The --result-log option has been removed. Users are recommended to use the pytest-reportlog plugin instead.

    For more information consult
    โœ… Deprecations and Removals in the docs.

    ๐Ÿ—„ Deprecations

    โœ… #6981: The pytest.collect module is deprecated: all its names can be imported from pytest directly.

    โœ… #7097: The pytest._fillfuncargs function is deprecated. This function was kept
    ๐Ÿ”Œ for backward compatibility with an older plugin.

    It's functionality is not meant to be used directly, but if you must replace
    it, use function._request._fillfixtures() instead, though note this is not
    a public API and may break in the future.

    โœ… #7210: The special -k '-expr' syntax to -k is deprecated. Use -k 'not expr'
    instead.

    ๐Ÿ—„ The special -k 'expr:' syntax to -k is deprecated. Please open an issue
    if you use this and want a replacement.

    โš  #7255: The pytest_warning_captured <_pytest.hookspec.pytest_warning_captured> hook is deprecated in favor
    โš  of pytest_warning_recorded <_pytest.hookspec.pytest_warning_recorded>, and will be removed in a future version.

    ๐Ÿ“ฆ #7648: The gethookproxy() and isinitpath() methods of FSCollector and Package are deprecated;
    ๐Ÿ‘‰ use self.session.gethookproxy() and self.session.isinitpath() instead.
    โœ… This should work on all pytest versions.

    ๐Ÿ”‹ Features

    • โœ… #7667: New --durations-min command-line flag controls the minimal duration for inclusion in the slowest list of tests shown by --durations. Previously this was hard-coded to 0.005s.

    ๐Ÿ‘Œ Improvements

    โœ… #6681: Internal pytest warnings issued during the early stages of initialization are now properly handled and can filtered through filterwarnings or --pythonwarnings/-W.

    โœ… This also fixes a number of long standing issues: #2891, #7620, #7426.

    โœ… #7572: When a plugin listed in required_plugins is missing or an unknown config key is used with --strict-config, a simple error message is now shown instead of a stacktrace.

    โœ… #7685: Added two new attributes rootpath <_pytest.config.Config.rootpath> and inipath <_pytest.config.Config.inipath> to Config <_pytest.config.Config>.
    โœ… These attributes are pathlib.Path versions of the existing rootdir <_pytest.config.Config.rootdir> and inifile <_pytest.config.Config.inifile> attributes,
    and should be preferred over them when possible.

    โœ… #7780: Public classes which are not designed to be inherited from are now marked @final.
    Code which inherits from these classes will trigger a type-checking (e.g. mypy) error, but will still work in runtime.
    Currently the final designation does not appear in the API Reference but hopefully will in the future.

    ๐Ÿ› Bug Fixes

    โœ… #1953: Fixed error when overwriting a parametrized fixture, while also reusing the super fixture value.

    # conftest.py
    import pytest
    
    
    @pytest.fixture(params=[1, 2])
    def foo(request):
        return request.param
    
    
    # test_foo.py
    import pytest
    
    
    @pytest.fixture
    def foo(foo):
        return foo * 2
    

    โœ… #4984: Fixed an internal error crash with IndexError: list index out of range when
    collecting a module which starts with a decorated function, the decorator
    raises, and assertion rewriting is enabled.

    ๐Ÿ‘• #7591: pylint shouldn't complain anymore about unimplemented abstract methods when inheriting from File <non-python tests>.

    ๐Ÿ #7628: Fixed test collection when a full path without a drive letter was passed to pytest on Windows (for example \projects\tests\test.py instead of c:\projects\tests\pytest.py).

    ๐Ÿ #7638: Fix handling of command-line options that appear as paths but trigger an OS-level syntax error on Windows, such as the options used internally by pytest-xdist.

    โœ… #7742: Fixed INTERNALERROR when accessing locals / globals with faulty exec.

    ๐Ÿ‘Œ Improved Documentation

    • ๐Ÿšš #1477: Removed faq.rst and its reference in contents.rst.

    Trivial/Internal Changes

    • โœ… #7536: The internal junitxml plugin has rewritten to use xml.etree.ElementTree.
      The order of attributes in XML elements might differ. Some unneeded escaping is
      no longer performed.
    • ๐Ÿ“ฆ #7587: The dependency on the more-itertools package has been removed.
    • โœ… #7631: The result type of capfd.readouterr() <_pytest.capture.CaptureFixture.readouterr> (and similar) is no longer a namedtuple,
      but should behave like one in all respects. This was done for technical reasons.
    • โœ… #7671: When collecting tests, pytest finds test classes and functions by examining the
      attributes of python objects (modules, classes and instances). To speed up this
      process, pytest now ignores builtin attributes (like __class__,
      __delattr__ and __new__) without consulting the python_classes and
      ๐Ÿ”ง python_functions configuration options and without passing them to plugins
      using the pytest_pycollect_makeitem <_pytest.hookspec.pytest_pycollect_makeitem> hook.