From e7073afe6e2373175130511135020af8b4e3a670 Mon Sep 17 00:00:00 2001 From: pytest bot Date: Sat, 12 Dec 2020 20:35:28 +0000 Subject: [PATCH] Prepare release version 6.2.0 --- changelog/1265.improvement.rst | 1 - changelog/2044.improvement.rst | 1 - changelog/4824.bugfix.rst | 1 - changelog/5299.feature.rst | 2 - changelog/7425.feature.rst | 5 - changelog/7429.doc.rst | 1 - changelog/7469.deprecation.rst | 18 --- changelog/7469.improvement.rst | 23 ---- changelog/7527.improvement.rst | 1 - changelog/7530.deprecation.rst | 4 - changelog/7615.improvement.rst | 1 - changelog/7695.feature.rst | 19 --- changelog/7701.improvement.rst | 1 - changelog/7710.improvement.rst | 4 - changelog/7758.bugfix.rst | 1 - changelog/7780.doc.rst | 1 - changelog/7802.trivial.rst | 1 - changelog/7808.breaking.rst | 1 - changelog/7872.doc.rst | 1 - changelog/7878.doc.rst | 1 - changelog/7911.bugfix.rst | 1 - changelog/7913.bugfix.rst | 1 - changelog/7938.improvement.rst | 1 - changelog/7951.bugfix.rst | 1 - changelog/7981.bugfix.rst | 1 - changelog/7988.deprecation.rst | 3 - changelog/8006.feature.rst | 8 -- changelog/8014.trivial.rst | 2 - changelog/8016.bugfix.rst | 1 - changelog/8023.improvement.rst | 1 - changelog/8032.improvement.rst | 1 - doc/en/announce/index.rst | 1 + doc/en/announce/release-6.2.0.rst | 76 +++++++++++ doc/en/builtin.rst | 10 ++ doc/en/changelog.rst | 197 ++++++++++++++++++++++++++++ doc/en/example/nonpython.rst | 2 +- doc/en/example/parametrize.rst | 6 +- doc/en/example/pythoncollection.rst | 6 +- doc/en/example/reportingdemo.rst | 2 +- doc/en/fixture.rst | 4 +- doc/en/getting-started.rst | 2 +- doc/en/reference.rst | 7 +- doc/en/tmpdir.rst | 4 +- doc/en/writing_plugins.rst | 8 +- 44 files changed, 302 insertions(+), 132 deletions(-) delete mode 100644 changelog/1265.improvement.rst delete mode 100644 changelog/2044.improvement.rst delete mode 100644 changelog/4824.bugfix.rst delete mode 100644 changelog/5299.feature.rst delete mode 100644 changelog/7425.feature.rst delete mode 100644 changelog/7429.doc.rst delete mode 100644 changelog/7469.deprecation.rst delete mode 100644 changelog/7469.improvement.rst delete mode 100644 changelog/7527.improvement.rst delete mode 100644 changelog/7530.deprecation.rst delete mode 100644 changelog/7615.improvement.rst delete mode 100644 changelog/7695.feature.rst delete mode 100644 changelog/7701.improvement.rst delete mode 100644 changelog/7710.improvement.rst delete mode 100644 changelog/7758.bugfix.rst delete mode 100644 changelog/7780.doc.rst delete mode 100644 changelog/7802.trivial.rst delete mode 100644 changelog/7808.breaking.rst delete mode 100644 changelog/7872.doc.rst delete mode 100644 changelog/7878.doc.rst delete mode 100644 changelog/7911.bugfix.rst delete mode 100644 changelog/7913.bugfix.rst delete mode 100644 changelog/7938.improvement.rst delete mode 100644 changelog/7951.bugfix.rst delete mode 100644 changelog/7981.bugfix.rst delete mode 100644 changelog/7988.deprecation.rst delete mode 100644 changelog/8006.feature.rst delete mode 100644 changelog/8014.trivial.rst delete mode 100644 changelog/8016.bugfix.rst delete mode 100644 changelog/8023.improvement.rst delete mode 100644 changelog/8032.improvement.rst create mode 100644 doc/en/announce/release-6.2.0.rst diff --git a/changelog/1265.improvement.rst b/changelog/1265.improvement.rst deleted file mode 100644 index 4e7d98c0a99..00000000000 --- a/changelog/1265.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Added an ``__str__`` implementation to the :class:`~pytest.pytester.LineMatcher` class which is returned from ``pytester.run_pytest().stdout`` and similar. It returns the entire output, like the existing ``str()`` method. diff --git a/changelog/2044.improvement.rst b/changelog/2044.improvement.rst deleted file mode 100644 index c9e47c3f604..00000000000 --- a/changelog/2044.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Verbose mode now shows the reason that a test was skipped in the test's terminal line after the "SKIPPED", "XFAIL" or "XPASS". diff --git a/changelog/4824.bugfix.rst b/changelog/4824.bugfix.rst deleted file mode 100644 index f2e6db7ab0f..00000000000 --- a/changelog/4824.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed quadratic behavior and improved performance of collection of items using autouse fixtures and xunit fixtures. diff --git a/changelog/5299.feature.rst b/changelog/5299.feature.rst deleted file mode 100644 index 7853e1833db..00000000000 --- a/changelog/5299.feature.rst +++ /dev/null @@ -1,2 +0,0 @@ -pytest now warns about unraisable exceptions and unhandled thread exceptions that occur in tests on Python>=3.8. -See :ref:`unraisable` for more information. diff --git a/changelog/7425.feature.rst b/changelog/7425.feature.rst deleted file mode 100644 index 47e6f4dbd30..00000000000 --- a/changelog/7425.feature.rst +++ /dev/null @@ -1,5 +0,0 @@ -New :fixture:`pytester` fixture, which is identical to :fixture:`testdir` but its methods return :class:`pathlib.Path` when appropriate instead of ``py.path.local``. - -This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future. - -Internally, the old :class:`Testdir <_pytest.pytester.Testdir>` is now a thin wrapper around :class:`Pytester <_pytest.pytester.Pytester>`, preserving the old interface. diff --git a/changelog/7429.doc.rst b/changelog/7429.doc.rst deleted file mode 100644 index e6376b727b2..00000000000 --- a/changelog/7429.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Add more information and use cases about skipping doctests. diff --git a/changelog/7469.deprecation.rst b/changelog/7469.deprecation.rst deleted file mode 100644 index 67d0b2bba46..00000000000 --- a/changelog/7469.deprecation.rst +++ /dev/null @@ -1,18 +0,0 @@ -Directly constructing/calling the following classes/functions is now deprecated: - -- ``_pytest.cacheprovider.Cache`` -- ``_pytest.cacheprovider.Cache.for_config()`` -- ``_pytest.cacheprovider.Cache.clear_cache()`` -- ``_pytest.cacheprovider.Cache.cache_dir_from_config()`` -- ``_pytest.capture.CaptureFixture`` -- ``_pytest.fixtures.FixtureRequest`` -- ``_pytest.fixtures.SubRequest`` -- ``_pytest.logging.LogCaptureFixture`` -- ``_pytest.pytester.Pytester`` -- ``_pytest.pytester.Testdir`` -- ``_pytest.recwarn.WarningsRecorder`` -- ``_pytest.recwarn.WarningsChecker`` -- ``_pytest.tmpdir.TempPathFactory`` -- ``_pytest.tmpdir.TempdirFactory`` - -These have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 7.0.0. diff --git a/changelog/7469.improvement.rst b/changelog/7469.improvement.rst deleted file mode 100644 index cbd75f05419..00000000000 --- a/changelog/7469.improvement.rst +++ /dev/null @@ -1,23 +0,0 @@ -It is now possible to construct a :class:`MonkeyPatch` object directly as ``pytest.MonkeyPatch()``, -in cases when the :fixture:`monkeypatch` fixture cannot be used. Previously some users imported it -from the private `_pytest.monkeypatch.MonkeyPatch` namespace. - -The types of builtin pytest fixtures are now exported so they may be used in type annotations of test functions. -The newly-exported types are: - -- ``pytest.FixtureRequest`` for the :fixture:`request` fixture. -- ``pytest.Cache`` for the :fixture:`cache` fixture. -- ``pytest.CaptureFixture[str]`` for the :fixture:`capfd` and :fixture:`capsys` fixtures. -- ``pytest.CaptureFixture[bytes]`` for the :fixture:`capfdbinary` and :fixture:`capsysbinary` fixtures. -- ``pytest.LogCaptureFixture`` for the :fixture:`caplog` fixture. -- ``pytest.Pytester`` for the :fixture:`pytester` fixture. -- ``pytest.Testdir`` for the :fixture:`testdir` fixture. -- ``pytest.TempdirFactory`` for the :fixture:`tmpdir_factory` fixture. -- ``pytest.TempPathFactory`` for the :fixture:`tmp_path_factory` fixture. -- ``pytest.MonkeyPatch`` for the :fixture:`monkeypatch` fixture. -- ``pytest.WarningsRecorder`` for the :fixture:`recwarn` fixture. - -Constructing them is not supported (except for `MonkeyPatch`); they are only meant for use in type annotations. -Doing so will emit a deprecation warning, and may become a hard-error in pytest 7.0. - -Subclassing them is also not supported. This is not currently enforced at runtime, but is detected by type-checkers such as mypy. diff --git a/changelog/7527.improvement.rst b/changelog/7527.improvement.rst deleted file mode 100644 index 3a7e063fe6f..00000000000 --- a/changelog/7527.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -When a comparison between :func:`namedtuple ` instances of the same type fails, pytest now shows the differing field names (possibly nested) instead of their indexes. diff --git a/changelog/7530.deprecation.rst b/changelog/7530.deprecation.rst deleted file mode 100644 index 36a763e51f1..00000000000 --- a/changelog/7530.deprecation.rst +++ /dev/null @@ -1,4 +0,0 @@ -The ``--strict`` command-line option has been deprecated, use ``--strict-markers`` instead. - -We have plans to maybe in the future to reintroduce ``--strict`` and make it an encompassing flag for all strictness -related options (``--strict-markers`` and ``--strict-config`` at the moment, more might be introduced in the future). diff --git a/changelog/7615.improvement.rst b/changelog/7615.improvement.rst deleted file mode 100644 index fcf9a1a9b42..00000000000 --- a/changelog/7615.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -:meth:`Node.warn <_pytest.nodes.Node.warn>` now permits any subclass of :class:`Warning`, not just :class:`PytestWarning `. diff --git a/changelog/7695.feature.rst b/changelog/7695.feature.rst deleted file mode 100644 index ec8632fc82a..00000000000 --- a/changelog/7695.feature.rst +++ /dev/null @@ -1,19 +0,0 @@ -A new hook was added, `pytest_markeval_namespace` which should return a dictionary. -This dictionary will be used to augment the "global" variables available to evaluate skipif/xfail/xpass markers. - -Pseudo example - -``conftest.py``: - -.. code-block:: python - - def pytest_markeval_namespace(): - return {"color": "red"} - -``test_func.py``: - -.. code-block:: python - - @pytest.mark.skipif("color == 'blue'", reason="Color is not red") - def test_func(): - assert False diff --git a/changelog/7701.improvement.rst b/changelog/7701.improvement.rst deleted file mode 100644 index e214be9e3fe..00000000000 --- a/changelog/7701.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Improved reporting when using ``--collected-only``. It will now show the number of collected tests in the summary stats. diff --git a/changelog/7710.improvement.rst b/changelog/7710.improvement.rst deleted file mode 100644 index 91b703ab60f..00000000000 --- a/changelog/7710.improvement.rst +++ /dev/null @@ -1,4 +0,0 @@ -Use strict equality comparison for non-numeric types in :func:`pytest.approx` instead of -raising :class:`TypeError`. - -This was the undocumented behavior before 3.7, but is now officially a supported feature. diff --git a/changelog/7758.bugfix.rst b/changelog/7758.bugfix.rst deleted file mode 100644 index a3119b46c0d..00000000000 --- a/changelog/7758.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0. diff --git a/changelog/7780.doc.rst b/changelog/7780.doc.rst deleted file mode 100644 index 631873b156e..00000000000 --- a/changelog/7780.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Classes which should not be inherited from are now marked ``final class`` in the API reference. diff --git a/changelog/7802.trivial.rst b/changelog/7802.trivial.rst deleted file mode 100644 index 1f8bc2c9dc6..00000000000 --- a/changelog/7802.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -The ``attrs`` dependency requirement is now >=19.2.0 instead of >=17.4.0. diff --git a/changelog/7808.breaking.rst b/changelog/7808.breaking.rst deleted file mode 100644 index 114b6a382cf..00000000000 --- a/changelog/7808.breaking.rst +++ /dev/null @@ -1 +0,0 @@ -pytest now supports python3.6+ only. diff --git a/changelog/7872.doc.rst b/changelog/7872.doc.rst deleted file mode 100644 index 46236acbf2a..00000000000 --- a/changelog/7872.doc.rst +++ /dev/null @@ -1 +0,0 @@ -``_pytest.config.argparsing.Parser.addini()`` accepts explicit ``None`` and ``"string"``. diff --git a/changelog/7878.doc.rst b/changelog/7878.doc.rst deleted file mode 100644 index ff5d00d6c02..00000000000 --- a/changelog/7878.doc.rst +++ /dev/null @@ -1 +0,0 @@ -In pull request section, ask to commit after editing changelog and authors file. diff --git a/changelog/7911.bugfix.rst b/changelog/7911.bugfix.rst deleted file mode 100644 index 1ef783fbabb..00000000000 --- a/changelog/7911.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Directories created by by :fixture:`tmp_path` and :fixture:`tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites. diff --git a/changelog/7913.bugfix.rst b/changelog/7913.bugfix.rst deleted file mode 100644 index f42e7cb9cbd..00000000000 --- a/changelog/7913.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed a crash or hang in :meth:`pytester.spawn <_pytest.pytester.Pytester.spawn>` when the :mod:`readline` module is involved. diff --git a/changelog/7938.improvement.rst b/changelog/7938.improvement.rst deleted file mode 100644 index ffe612d0da6..00000000000 --- a/changelog/7938.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -New ``--sw-skip`` argument which is a shorthand for ``--stepwise-skip``. diff --git a/changelog/7951.bugfix.rst b/changelog/7951.bugfix.rst deleted file mode 100644 index 56c71db7839..00000000000 --- a/changelog/7951.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed handling of recursive symlinks when collecting tests. diff --git a/changelog/7981.bugfix.rst b/changelog/7981.bugfix.rst deleted file mode 100644 index 0a254b5d49d..00000000000 --- a/changelog/7981.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed symlinked directories not being followed during collection. Regressed in pytest 6.1.0. diff --git a/changelog/7988.deprecation.rst b/changelog/7988.deprecation.rst deleted file mode 100644 index 34f646c9ab4..00000000000 --- a/changelog/7988.deprecation.rst +++ /dev/null @@ -1,3 +0,0 @@ -The ``@pytest.yield_fixture`` decorator/function is now deprecated. Use :func:`pytest.fixture` instead. - -``yield_fixture`` has been an alias for ``fixture`` for a very long time, so can be search/replaced safely. diff --git a/changelog/8006.feature.rst b/changelog/8006.feature.rst deleted file mode 100644 index 0203689ba4b..00000000000 --- a/changelog/8006.feature.rst +++ /dev/null @@ -1,8 +0,0 @@ -It is now possible to construct a :class:`~pytest.MonkeyPatch` object directly as ``pytest.MonkeyPatch()``, -in cases when the :fixture:`monkeypatch` fixture cannot be used. Previously some users imported it -from the private `_pytest.monkeypatch.MonkeyPatch` namespace. - -Additionally, :meth:`MonkeyPatch.context ` is now a classmethod, -and can be used as ``with MonkeyPatch.context() as mp: ...``. This is the recommended way to use -``MonkeyPatch`` directly, since unlike the ``monkeypatch`` fixture, an instance created directly -is not ``undo()``-ed automatically. diff --git a/changelog/8014.trivial.rst b/changelog/8014.trivial.rst deleted file mode 100644 index 3b9fb7bc271..00000000000 --- a/changelog/8014.trivial.rst +++ /dev/null @@ -1,2 +0,0 @@ -`.pyc` files created by pytest's assertion rewriting now conform to the newer PEP-552 format on Python>=3.7. -(These files are internal and only interpreted by pytest itself.) diff --git a/changelog/8016.bugfix.rst b/changelog/8016.bugfix.rst deleted file mode 100644 index 94539af5c97..00000000000 --- a/changelog/8016.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed only one doctest being collected when using ``pytest --doctest-modules path/to/an/__init__.py``. diff --git a/changelog/8023.improvement.rst b/changelog/8023.improvement.rst deleted file mode 100644 index c791dabc72d..00000000000 --- a/changelog/8023.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -Added ``'node_modules'`` to default value for :confval:`norecursedirs`. diff --git a/changelog/8032.improvement.rst b/changelog/8032.improvement.rst deleted file mode 100644 index 76789ea5097..00000000000 --- a/changelog/8032.improvement.rst +++ /dev/null @@ -1 +0,0 @@ -:meth:`doClassCleanups ` (introduced in :mod:`unittest` in Python and 3.8) is now called appropriately. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index f0e44107b69..003a0a1a9ca 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-6.2.0 release-6.1.2 release-6.1.1 release-6.1.0 diff --git a/doc/en/announce/release-6.2.0.rst b/doc/en/announce/release-6.2.0.rst new file mode 100644 index 00000000000..af16b830ddd --- /dev/null +++ b/doc/en/announce/release-6.2.0.rst @@ -0,0 +1,76 @@ +pytest-6.2.0 +======================================= + +The pytest team is proud to announce the 6.2.0 release! + +This release contains new features, improvements, bug fixes, and breaking changes, so users +are encouraged to take a look at the CHANGELOG carefully: + + https://docs.pytest.org/en/stable/changelog.html + +For complete documentation, please visit: + + https://docs.pytest.org/en/stable/ + +As usual, you can upgrade from PyPI via: + + pip install -U pytest + +Thanks to all of the contributors to this release: + +* Adam Johnson +* Albert Villanova del Moral +* Anthony Sottile +* Anton +* Ariel Pillemer +* Bruno Oliveira +* Charles Aracil +* Christine M +* Christine Mecklenborg +* Cserna Zsolt +* Dominic Mortlock +* Emiel van de Laar +* Florian Bruhin +* Garvit Shubham +* Gustavo Camargo +* Hugo Martins +* Hugo van Kemenade +* Jakob van Santen +* Josias Aurel +* Jürgen Gmach +* Karthikeyan Singaravelan +* Katarzyna +* Kyle Altendorf +* Manuel Mariñez +* Matthew Hughes +* Matthias Gabriel +* Max Voitko +* Maximilian Cosmo Sitter +* Mikhail Fesenko +* Nimesh Vashistha +* Pedro Algarvio +* Petter Strandmark +* Prakhar Gurunani +* Prashant Sharma +* Ran Benita +* Ronny Pfannschmidt +* Sanket Duthade +* Shubham Adep +* Simon K +* Tanvi Mehta +* Thomas Grainger +* Tim Hoffmann +* Vasilis Gerakaris +* William Jamir Silva +* Zac Hatfield-Dodds +* crricks +* dependabot[bot] +* duthades +* frankgerhardt +* kwgchi +* mickeypash +* symonk + + +Happy testing, +The pytest Development Team diff --git a/doc/en/builtin.rst b/doc/en/builtin.rst index 1d7fe76e3b7..5c7c8dfe666 100644 --- a/doc/en/builtin.rst +++ b/doc/en/builtin.rst @@ -158,6 +158,11 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a function invocation, created as a sub directory of the base temporary directory. + By default, a new base temporary directory is created each test session, + and old bases are removed after 3 sessions, to aid in debugging. If + ``--basetemp`` is used then it is cleared each session. See :ref:`base + temporary directory`. + The returned object is a `py.path.local`_ path object. .. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html @@ -167,6 +172,11 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a function invocation, created as a sub directory of the base temporary directory. + By default, a new base temporary directory is created each test session, + and old bases are removed after 3 sessions, to aid in debugging. If + ``--basetemp`` is used then it is cleared each session. See :ref:`base + temporary directory`. + The returned object is a :class:`pathlib.Path` object. diff --git a/doc/en/changelog.rst b/doc/en/changelog.rst index 3f14921a80a..77340b1bb84 100644 --- a/doc/en/changelog.rst +++ b/doc/en/changelog.rst @@ -28,6 +28,203 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 6.2.0 (2020-12-12) +========================= + +Breaking Changes +---------------- + +- `#7808 `_: pytest now supports python3.6+ only. + + + +Deprecations +------------ + +- `#7469 `_: Directly constructing/calling the following classes/functions is now deprecated: + + - ``_pytest.cacheprovider.Cache`` + - ``_pytest.cacheprovider.Cache.for_config()`` + - ``_pytest.cacheprovider.Cache.clear_cache()`` + - ``_pytest.cacheprovider.Cache.cache_dir_from_config()`` + - ``_pytest.capture.CaptureFixture`` + - ``_pytest.fixtures.FixtureRequest`` + - ``_pytest.fixtures.SubRequest`` + - ``_pytest.logging.LogCaptureFixture`` + - ``_pytest.pytester.Pytester`` + - ``_pytest.pytester.Testdir`` + - ``_pytest.recwarn.WarningsRecorder`` + - ``_pytest.recwarn.WarningsChecker`` + - ``_pytest.tmpdir.TempPathFactory`` + - ``_pytest.tmpdir.TempdirFactory`` + + These have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 7.0.0. + + +- `#7530 `_: The ``--strict`` command-line option has been deprecated, use ``--strict-markers`` instead. + + We have plans to maybe in the future to reintroduce ``--strict`` and make it an encompassing flag for all strictness + related options (``--strict-markers`` and ``--strict-config`` at the moment, more might be introduced in the future). + + +- `#7988 `_: The ``@pytest.yield_fixture`` decorator/function is now deprecated. Use :func:`pytest.fixture` instead. + + ``yield_fixture`` has been an alias for ``fixture`` for a very long time, so can be search/replaced safely. + + + +Features +-------- + +- `#5299 `_: pytest now warns about unraisable exceptions and unhandled thread exceptions that occur in tests on Python>=3.8. + See :ref:`unraisable` for more information. + + +- `#7425 `_: New :fixture:`pytester` fixture, which is identical to :fixture:`testdir` but its methods return :class:`pathlib.Path` when appropriate instead of ``py.path.local``. + + This is part of the movement to use :class:`pathlib.Path` objects internally, in order to remove the dependency to ``py`` in the future. + + Internally, the old :class:`Testdir <_pytest.pytester.Testdir>` is now a thin wrapper around :class:`Pytester <_pytest.pytester.Pytester>`, preserving the old interface. + + +- `#7695 `_: A new hook was added, `pytest_markeval_namespace` which should return a dictionary. + This dictionary will be used to augment the "global" variables available to evaluate skipif/xfail/xpass markers. + + Pseudo example + + ``conftest.py``: + + .. code-block:: python + + def pytest_markeval_namespace(): + return {"color": "red"} + + ``test_func.py``: + + .. code-block:: python + + @pytest.mark.skipif("color == 'blue'", reason="Color is not red") + def test_func(): + assert False + + +- `#8006 `_: It is now possible to construct a :class:`~pytest.MonkeyPatch` object directly as ``pytest.MonkeyPatch()``, + in cases when the :fixture:`monkeypatch` fixture cannot be used. Previously some users imported it + from the private `_pytest.monkeypatch.MonkeyPatch` namespace. + + Additionally, :meth:`MonkeyPatch.context ` is now a classmethod, + and can be used as ``with MonkeyPatch.context() as mp: ...``. This is the recommended way to use + ``MonkeyPatch`` directly, since unlike the ``monkeypatch`` fixture, an instance created directly + is not ``undo()``-ed automatically. + + + +Improvements +------------ + +- `#1265 `_: Added an ``__str__`` implementation to the :class:`~pytest.pytester.LineMatcher` class which is returned from ``pytester.run_pytest().stdout`` and similar. It returns the entire output, like the existing ``str()`` method. + + +- `#2044 `_: Verbose mode now shows the reason that a test was skipped in the test's terminal line after the "SKIPPED", "XFAIL" or "XPASS". + + +- `#7469 `_ The types of builtin pytest fixtures are now exported so they may be used in type annotations of test functions. + The newly-exported types are: + + - ``pytest.FixtureRequest`` for the :fixture:`request` fixture. + - ``pytest.Cache`` for the :fixture:`cache` fixture. + - ``pytest.CaptureFixture[str]`` for the :fixture:`capfd` and :fixture:`capsys` fixtures. + - ``pytest.CaptureFixture[bytes]`` for the :fixture:`capfdbinary` and :fixture:`capsysbinary` fixtures. + - ``pytest.LogCaptureFixture`` for the :fixture:`caplog` fixture. + - ``pytest.Pytester`` for the :fixture:`pytester` fixture. + - ``pytest.Testdir`` for the :fixture:`testdir` fixture. + - ``pytest.TempdirFactory`` for the :fixture:`tmpdir_factory` fixture. + - ``pytest.TempPathFactory`` for the :fixture:`tmp_path_factory` fixture. + - ``pytest.MonkeyPatch`` for the :fixture:`monkeypatch` fixture. + - ``pytest.WarningsRecorder`` for the :fixture:`recwarn` fixture. + + Constructing them is not supported (except for `MonkeyPatch`); they are only meant for use in type annotations. + Doing so will emit a deprecation warning, and may become a hard-error in pytest 7.0. + + Subclassing them is also not supported. This is not currently enforced at runtime, but is detected by type-checkers such as mypy. + + +- `#7527 `_: When a comparison between :func:`namedtuple ` instances of the same type fails, pytest now shows the differing field names (possibly nested) instead of their indexes. + + +- `#7615 `_: :meth:`Node.warn <_pytest.nodes.Node.warn>` now permits any subclass of :class:`Warning`, not just :class:`PytestWarning `. + + +- `#7701 `_: Improved reporting when using ``--collected-only``. It will now show the number of collected tests in the summary stats. + + +- `#7710 `_: Use strict equality comparison for non-numeric types in :func:`pytest.approx` instead of + raising :class:`TypeError`. + + This was the undocumented behavior before 3.7, but is now officially a supported feature. + + +- `#7938 `_: New ``--sw-skip`` argument which is a shorthand for ``--stepwise-skip``. + + +- `#8023 `_: Added ``'node_modules'`` to default value for :confval:`norecursedirs`. + + +- `#8032 `_: :meth:`doClassCleanups ` (introduced in :mod:`unittest` in Python and 3.8) is now called appropriately. + + + +Bug Fixes +--------- + +- `#4824 `_: Fixed quadratic behavior and improved performance of collection of items using autouse fixtures and xunit fixtures. + + +- `#7758 `_: Fixed an issue where some files in packages are getting lost from ``--lf`` even though they contain tests that failed. Regressed in pytest 5.4.0. + + +- `#7911 `_: Directories created by by :fixture:`tmp_path` and :fixture:`tmpdir` are now considered stale after 3 days without modification (previous value was 3 hours) to avoid deleting directories still in use in long running test suites. + + +- `#7913 `_: Fixed a crash or hang in :meth:`pytester.spawn <_pytest.pytester.Pytester.spawn>` when the :mod:`readline` module is involved. + + +- `#7951 `_: Fixed handling of recursive symlinks when collecting tests. + + +- `#7981 `_: Fixed symlinked directories not being followed during collection. Regressed in pytest 6.1.0. + + +- `#8016 `_: Fixed only one doctest being collected when using ``pytest --doctest-modules path/to/an/__init__.py``. + + + +Improved Documentation +---------------------- + +- `#7429 `_: Add more information and use cases about skipping doctests. + + +- `#7780 `_: Classes which should not be inherited from are now marked ``final class`` in the API reference. + + +- `#7872 `_: ``_pytest.config.argparsing.Parser.addini()`` accepts explicit ``None`` and ``"string"``. + + +- `#7878 `_: In pull request section, ask to commit after editing changelog and authors file. + + + +Trivial/Internal Changes +------------------------ + +- `#7802 `_: The ``attrs`` dependency requirement is now >=19.2.0 instead of >=17.4.0. + + +- `#8014 `_: `.pyc` files created by pytest's assertion rewriting now conform to the newer PEP-552 format on Python>=3.7. + (These files are internal and only interpreted by pytest itself.) + + pytest 6.1.2 (2020-10-28) ========================= diff --git a/doc/en/example/nonpython.rst b/doc/en/example/nonpython.rst index 558c56772f1..a3477fe1e1d 100644 --- a/doc/en/example/nonpython.rst +++ b/doc/en/example/nonpython.rst @@ -102,4 +102,4 @@ interesting to just look at the collection tree: - ========================== 2 tests found in 0.12s =========================== + ======================== 2 tests collected in 0.12s ======================== diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index d5a11b45192..6e2f53984ee 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -175,7 +175,7 @@ objects, they are still using the default pytest representation: - ========================== 8 tests found in 0.12s =========================== + ======================== 8 tests collected in 0.12s ======================== In ``test_timedistance_v3``, we used ``pytest.param`` to specify the test IDs together with the actual data, instead of listing them separately. @@ -252,7 +252,7 @@ If you just collect tests you'll also nicely see 'advanced' and 'basic' as varia - ========================== 4 tests found in 0.12s =========================== + ======================== 4 tests collected in 0.12s ======================== Note that we told ``metafunc.parametrize()`` that your scenario values should be considered class-scoped. With pytest-2.3 this leads to a @@ -328,7 +328,7 @@ Let's first see how it looks like at collection time: - ========================== 2/2 tests found in 0.12s =========================== + ======================== 2 tests collected in 0.12s ======================== And then when we run the test: diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index f7917b790ef..a6ce2e742e5 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -157,7 +157,7 @@ The test collection would look like this: - ========================== 2 tests found in 0.12s =========================== + ======================== 2 tests collected in 0.12s ======================== You can check for multiple glob patterns by adding a space between the patterns: @@ -220,7 +220,7 @@ You can always peek at the collection tree without running tests like this: - ========================== 3 tests found in 0.12s =========================== + ======================== 3 tests collected in 0.12s ======================== .. _customizing-test-collection: @@ -296,7 +296,7 @@ file will be left out: rootdir: $REGENDOC_TMPDIR, configfile: pytest.ini collected 0 items - ========================== no tests found in 0.12s =========================== + ======================= no tests collected in 0.12s ======================== It's also possible to ignore files based on Unix shell-style wildcards by adding patterns to :globalvar:`collect_ignore_glob`. diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index f1b973f3b33..6e7dbe49683 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -446,7 +446,7 @@ Here is a nice run of several failures and how ``pytest`` presents things: def test_reinterpret_fails_with_print_for_the_fun_of_it(self): items = [1, 2, 3] - print("items is {!r}".format(items)) + print(f"items is {items!r}") > a, b = items.pop() E TypeError: cannot unpack non-iterable int object diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 22b86ffcafc..963fc32e6b0 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -919,7 +919,7 @@ Running the above tests results in the following test IDs being used: - ========================== 10 tests found in 0.12s =========================== + ======================= 10 tests collected in 0.12s ======================== .. _`fixture-parametrize-marks`: @@ -958,7 +958,7 @@ Running this test will *skip* the invocation of ``data_set`` with value ``2``: test_fixture_marks.py::test_data[0] PASSED [ 33%] test_fixture_marks.py::test_data[1] PASSED [ 66%] - test_fixture_marks.py::test_data[2] SKIPPED [100%] + test_fixture_marks.py::test_data[2] SKIPPED (unconditional skip) [100%] ======================= 2 passed, 1 skipped in 0.12s ======================= diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 4814b850586..fe15c218cde 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -28,7 +28,7 @@ Install ``pytest`` .. code-block:: bash $ pytest --version - pytest 6.1.2 + pytest 6.2.0 .. _`simpletest`: diff --git a/doc/en/reference.rst b/doc/en/reference.rst index f62b51414b4..8aa95ca6448 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -1749,7 +1749,8 @@ All the command-line flags can be obtained by running ``pytest --help``:: failures. --sw, --stepwise exit on test failure and continue from last failing test next time - --stepwise-skip ignore the first failing test but stop on the next + --sw-skip, --stepwise-skip + ignore the first failing test but stop on the next failing test reporting: @@ -1791,9 +1792,9 @@ All the command-line flags can be obtained by running ``pytest --help``:: --maxfail=num exit after first num failures or errors. --strict-config any warnings encountered while parsing the `pytest` section of the configuration file raise errors. - --strict-markers, --strict - markers not registered in the `markers` section of + --strict-markers markers not registered in the `markers` section of the configuration file raise errors. + --strict (deprecated) alias to --strict-markers. -c file load configuration from `file` instead of trying to locate one of the implicit configuration files. --continue-on-collection-errors diff --git a/doc/en/tmpdir.rst b/doc/en/tmpdir.rst index c8da5877b28..adcba02cb15 100644 --- a/doc/en/tmpdir.rst +++ b/doc/en/tmpdir.rst @@ -61,7 +61,7 @@ Running this would result in a passed test except for the last > assert 0 E assert 0 - test_tmp_path.py:13: AssertionError + test_tmp_path.py:11: AssertionError ========================= short test summary info ========================== FAILED test_tmp_path.py::test_create_file - assert 0 ============================ 1 failed in 0.12s ============================= @@ -129,7 +129,7 @@ Running this would result in a passed test except for the last > assert 0 E assert 0 - test_tmpdir.py:9: AssertionError + test_tmpdir.py:6: AssertionError ========================= short test summary info ========================== FAILED test_tmpdir.py::test_create_file - assert 0 ============================ 1 failed in 0.12s ============================= diff --git a/doc/en/writing_plugins.rst b/doc/en/writing_plugins.rst index 41967525b33..908366d5290 100644 --- a/doc/en/writing_plugins.rst +++ b/doc/en/writing_plugins.rst @@ -449,13 +449,7 @@ Additionally it is possible to copy examples for an example folder before runnin test_example.py .. [100%] - ============================= warnings summary ============================= - test_example.py::test_plugin - $REGENDOC_TMPDIR/test_example.py:4: PytestExperimentalApiWarning: testdir.copy_example is an experimental api that may change over time - testdir.copy_example("test_example.py") - - -- Docs: https://docs.pytest.org/en/stable/warnings.html - ======================= 2 passed, 1 warning in 0.12s ======================= + ============================ 2 passed in 0.12s ============================= For more information about the result object that ``runpytest()`` returns, and the methods that it provides please check out the :py:class:`RunResult