pytest v6.1.0 Release Notes

Release Date: 2020-09-26 // over 3 years 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.