From 5c6d87b80c29dd2acc79afe2a358986300dc2175 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 8 Nov 2021 18:42:36 +0100 Subject: [PATCH 1/7] Remove changelog entry for #8251 Reverted in #8903 --- changelog/8251.deprecation.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 changelog/8251.deprecation.rst diff --git a/changelog/8251.deprecation.rst b/changelog/8251.deprecation.rst deleted file mode 100644 index 1d988bfc83b..00000000000 --- a/changelog/8251.deprecation.rst +++ /dev/null @@ -1 +0,0 @@ -Deprecate ``Node.fspath`` as we plan to move off `py.path.local `__ and switch to :mod:``pathlib``. From 61fef754e29152d7353b56f6343a8a384997ce63 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 8 Nov 2021 20:10:46 +0100 Subject: [PATCH 2/7] Move #9202 changelog to to trivial This won't concern users of pytest --- changelog/{9202.improvement.rst => 9202.trivial.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{9202.improvement.rst => 9202.trivial.rst} (100%) diff --git a/changelog/9202.improvement.rst b/changelog/9202.trivial.rst similarity index 100% rename from changelog/9202.improvement.rst rename to changelog/9202.trivial.rst From cf86f23b14f77067237da4a3d83e3db029de76f4 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 8 Nov 2021 20:11:40 +0100 Subject: [PATCH 3/7] Streamline deprecation changelogs/docs --- changelog/7259.breaking.rst | 1 + changelog/8447.deprecation.rst | 4 +-- changelog/8592.deprecation.rst | 2 ++ doc/en/deprecations.rst | 47 ++++++++++++++++++++++++++++------ 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/changelog/7259.breaking.rst b/changelog/7259.breaking.rst index 37f2fe6d700..48ecbcbb730 100644 --- a/changelog/7259.breaking.rst +++ b/changelog/7259.breaking.rst @@ -5,4 +5,5 @@ Since `py.path.local` is a `os.PathLike[str]`, these plugins are unaffacted. Plugins and users which call `reportinfo()`, use the first return value and interact with it as a `py.path.local`, would need to adjust by calling `py.path.local(fspath)`. Although preferably, avoid the legacy `py.path.local` and use `pathlib.Path`, or use `item.location` or `item.path`, instead. + Note: pytest was not able to provide a deprecation period for this change. diff --git a/changelog/8447.deprecation.rst b/changelog/8447.deprecation.rst index 0116483a3bb..8386e3b7480 100644 --- a/changelog/8447.deprecation.rst +++ b/changelog/8447.deprecation.rst @@ -1,4 +1,4 @@ -Defining a custom pytest node type which is both an :class:`pytest.Item ` and a :class:`pytest.Collector ` now issues a warning. +Defining a custom pytest node type which is both an :class:`pytest.Item ` and a :class:`pytest.Collector ` (e.g. :class:`pytest.File `) now issues a warning. It was never sanely supported and triggers hard to debug errors. -Instead, a separate collector node should be used, which collects the item. See :ref:`non-python tests` for an example. +See :ref:`the deprecation note ` for full details. diff --git a/changelog/8592.deprecation.rst b/changelog/8592.deprecation.rst index 51b7a6b0d1e..733ad3586e5 100644 --- a/changelog/8592.deprecation.rst +++ b/changelog/8592.deprecation.rst @@ -1 +1,3 @@ :func:`pytest_cmdline_preparse <_pytest.hookspec.pytest_cmdline_preparse>` has been officially deprecated. It will be removed in a future release. Use :func:`pytest_load_initial_conftests <_pytest.hookspec.pytest_load_initial_conftests>` instead. + +See :ref:`the deprecation note ` for full details. diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index c47e9a70384..87fbd68424c 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -55,6 +55,26 @@ In order to support the transition from ``py.path.local`` to :mod:`pathlib`, the The accompanying ``py.path.local`` based paths have been deprecated: plugins which manually invoke those hooks should only pass the new ``pathlib.Path`` arguments, and users should change their hook implementations to use the new ``pathlib.Path`` arguments. +Directly constructing internal classes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 7.0 + +Directly constructing the following classes is now deprecated: + +- ``_pytest.mark.structures.Mark`` +- ``_pytest.mark.structures.MarkDecorator`` +- ``_pytest.mark.structures.MarkGenerator`` +- ``_pytest.python.Metafunc`` +- ``_pytest.runner.CallInfo`` +- ``_pytest._code.ExceptionInfo`` +- ``_pytest.config.argparsing.Parser`` +- ``_pytest.config.argparsing.OptionGroup`` +- ``_pytest.pytester.HookRecorder`` + +These constructors have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 8. + +.. _cmdline-preparse-deprecated: Implementing the ``pytest_cmdline_preparse`` hook ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -78,18 +98,19 @@ Implement the :func:`pytest_load_initial_conftests <_pytest.hookspec.pytest_load ) -> None: ... +.. _diamond-inheritance-deprecated: -Diamond inheritance between :class:`pytest.File` and :class:`pytest.Item` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Diamond inheritance between :class:`pytest.Collector` and :class:`pytest.Item` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. deprecated:: 7.0 -Inheriting from both Item and file at once has never been supported officially, -however some plugins providing linting/code analysis have been using this as a hack. - -This practice is now officially deprecated and a common way to fix this is `example pr fixing inheritance`_. - +Defining a custom pytest node type which is both an :class:`pytest.Item ` and a :class:`pytest.Collector ` (e.g. :class:`pytest.File `) now issues a warning. +It was never sanely supported and triggers hard to debug errors. +Some plugins providing linting/code analysis have been using this as a hack. +Instead, a separate collector node should be used, which collects the item. See +:ref:`non-python tests` for an example, as well as an `example pr fixing inheritance`_. .. _example pr fixing inheritance: https://github.com/asmeurer/pytest-flakes/pull/40/files @@ -100,7 +121,7 @@ Backward compatibilities in ``Parser.addoption`` .. deprecated:: 2.4 Several behaviors of :meth:`Parser.addoption ` are now -scheduled for removal in pytest 7 (deprecated since pytest 2.4.0): +scheduled for removal in pytest 8 (deprecated since pytest 2.4.0): - ``parser.addoption(..., help=".. %default ..")`` - use ``%(default)s`` instead. - ``parser.addoption(..., type="int/string/float/complex")`` - use ``type=int`` etc. instead. @@ -119,6 +140,16 @@ collection. You are probably not doing that. Ordinary usage of :class:`unittest.SkipTest` / :meth:`unittest.TestCase.skipTest` / :func:`unittest.skip` in unittest test cases is fully supported. +Using ``pytest.warns(None)`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 7.0 + +:func:`pytest.warns(None) ` is now deprecated because many people used +it to mean "this code does not emit warnings", but it actually had the effect of +checking that the code emits at least one warning of any type - like ``pytest.warns()`` +or ``pytest.warns(Warning)``. + The ``--strict`` command-line option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From d072259bb6d8a6d1562cc6d91e1febbe5cc21abb Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 8 Nov 2021 20:13:03 +0100 Subject: [PATCH 4/7] Remove #8994 changelog This is an impovement for a warning introduced in this release, so including it in a changelog against the last release seems confusing. --- changelog/8994.improvement.rst | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 changelog/8994.improvement.rst diff --git a/changelog/8994.improvement.rst b/changelog/8994.improvement.rst deleted file mode 100644 index 2c8a2ef836d..00000000000 --- a/changelog/8994.improvement.rst +++ /dev/null @@ -1,2 +0,0 @@ -Included the module of the class in the error message about direct -node construction (without using ``from_parent``). From 36da787ef2070ec3060955a3f832ee6ef2c108ec Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 8 Nov 2021 20:16:35 +0100 Subject: [PATCH 5/7] Remove #9241 changelog This is an impovement for a doc update introduced in this release, so including it in a changelog against the last release seems confusing. The issue number also seems about something different. --- changelog/451.doc.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 changelog/451.doc.rst diff --git a/changelog/451.doc.rst b/changelog/451.doc.rst deleted file mode 100644 index 3c8075489ad..00000000000 --- a/changelog/451.doc.rst +++ /dev/null @@ -1 +0,0 @@ -The PDF documentation’s list of plugins doesn’t run off the page anymore. From 57b4161c6ad56944b8bd94e93bd732e7966e28de Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 8 Nov 2021 20:17:43 +0100 Subject: [PATCH 6/7] Remove #8897 changelog Empty file... --- changelog/8897.doc.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 changelog/8897.doc.rst diff --git a/changelog/8897.doc.rst b/changelog/8897.doc.rst deleted file mode 100644 index e69de29bb2d..00000000000 From 6f878b51d2f7e37ae6a7b8c30aade7f20cee28e1 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 8 Nov 2021 20:21:09 +0100 Subject: [PATCH 7/7] Various minor changelog fixes --- changelog/7864.improvement.rst | 2 +- changelog/8061.bugfix.rst | 2 +- changelog/8133.trivial.rst | 2 +- changelog/8803.improvement.rst | 4 ++-- changelog/9242.doc.rst | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/changelog/7864.improvement.rst b/changelog/7864.improvement.rst index f5627be5e37..195632346fe 100644 --- a/changelog/7864.improvement.rst +++ b/changelog/7864.improvement.rst @@ -1,4 +1,4 @@ Improved error messages when parsing warning filters. -Previously pytest would show an internal traceback, which besides ugly sometimes would hide the cause +Previously pytest would show an internal traceback, which besides being ugly sometimes would hide the cause of the problem (for example an ``ImportError`` while importing a specific warning type). diff --git a/changelog/8061.bugfix.rst b/changelog/8061.bugfix.rst index 2c8980fb34e..5686af66321 100644 --- a/changelog/8061.bugfix.rst +++ b/changelog/8061.bugfix.rst @@ -1 +1 @@ -Fixed failing staticmethod test cases if they are inherited from a parent test class. +Fixed failing ``staticmethod`` test cases if they are inherited from a parent test class. diff --git a/changelog/8133.trivial.rst b/changelog/8133.trivial.rst index 107d06b639b..7ceaae59765 100644 --- a/changelog/8133.trivial.rst +++ b/changelog/8133.trivial.rst @@ -1 +1 @@ -Migrate to setuptools_scm 6.x to use SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST for more robust release tooling. +Migrate to ``setuptools_scm`` 6.x to use ``SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST`` for more robust release tooling. diff --git a/changelog/8803.improvement.rst b/changelog/8803.improvement.rst index 6080070025f..1e4db257dfc 100644 --- a/changelog/8803.improvement.rst +++ b/changelog/8803.improvement.rst @@ -1,9 +1,9 @@ It is now possible to add colors to custom log levels on cli log. -By using :func:`add_color_level <_pytest.logging.add_color_level` from a ``pytest_configure`` hook, colors can be added:: +By using :func:`add_color_level <_pytest.logging.add_color_level>` from a ``pytest_configure`` hook, colors can be added:: logging_plugin = config.pluginmanager.get_plugin('logging-plugin') logging_plugin.log_cli_handler.formatter.add_color_level(logging.INFO, 'cyan') logging_plugin.log_cli_handler.formatter.add_color_level(logging.SPAM, 'blue') - See :ref:`log_colors` for more information. +See :ref:`log_colors` for more information. diff --git a/changelog/9242.doc.rst b/changelog/9242.doc.rst index 3239cf9980a..ef2afc744bf 100644 --- a/changelog/9242.doc.rst +++ b/changelog/9242.doc.rst @@ -1 +1 @@ -Upgrade readthedocs configuration to use a [newer Ubuntu version](https://blog.readthedocs.com/new-build-specification/) with better unicode support for PDF docs. +Upgrade readthedocs configuration to use a `newer Ubuntu version `__` with better unicode support for PDF docs.