From 1f8b39ed328a395c073db603bf4063fb3ec97218 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Mon, 1 Jan 2024 13:17:58 +0200 Subject: [PATCH] Remove deprecated `--strict` option --- doc/en/deprecations.rst | 27 ++++++++++++++------------- src/_pytest/config/__init__.py | 5 ----- src/_pytest/deprecated.py | 4 ---- testing/deprecated_test.py | 19 ------------------- 4 files changed, 14 insertions(+), 41 deletions(-) diff --git a/doc/en/deprecations.rst b/doc/en/deprecations.rst index c8189b1bb..7562f98eb 100644 --- a/doc/en/deprecations.rst +++ b/doc/en/deprecations.rst @@ -438,19 +438,6 @@ The proper fix is to change the `return` to an `assert`: assert foo(a, b) == result -The ``--strict`` command-line option -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. deprecated:: 6.2 - -The ``--strict`` command-line option has been deprecated in favor of ``--strict-markers``, which -better conveys what the option does. - -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). - - The ``yield_fixture`` function/decorator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -470,6 +457,20 @@ an appropriate period of deprecation has passed. Some breaking changes which could not be deprecated are also listed. +The ``--strict`` command-line option +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 6.2 +.. versionremoved:: 8.0 + +The ``--strict`` command-line option has been deprecated in favor of ``--strict-markers``, which +better conveys what the option does. + +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). + + .. _cmdline-preparse-deprecated: Implementing the ``pytest_cmdline_preparse`` hook diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 9f25b67ab..2d5db1724 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -1319,11 +1319,6 @@ class Config: self._validate_plugins() self._warn_about_skipped_plugins() - if self.known_args_namespace.strict: - self.issue_config_time_warning( - _pytest.deprecated.STRICT_OPTION, stacklevel=2 - ) - if self.known_args_namespace.confcutdir is None: if self.inipath is not None: confcutdir = str(self.inipath.parent) diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index b7beb3531..1ead61e8c 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -46,10 +46,6 @@ YIELD_FIXTURE = PytestDeprecationWarning( "Use @pytest.fixture instead; they are the same." ) -STRICT_OPTION = PytestRemovedIn8Warning( - "The --strict option is deprecated, use --strict-markers instead." -) - # This deprecation is never really meant to be removed. PRIVATE = PytestDeprecationWarning("A private pytest class or function was used.") diff --git a/testing/deprecated_test.py b/testing/deprecated_test.py index 042be8264..dd6a6dfcf 100644 --- a/testing/deprecated_test.py +++ b/testing/deprecated_test.py @@ -67,25 +67,6 @@ def test_hookimpl_via_function_attributes_are_deprecated(): assert record.filename == __file__ -def test_strict_option_is_deprecated(pytester: Pytester) -> None: - """--strict is a deprecated alias to --strict-markers (#7530).""" - pytester.makepyfile( - """ - import pytest - - @pytest.mark.unknown - def test_foo(): pass - """ - ) - result = pytester.runpytest("--strict", "-Wdefault::pytest.PytestRemovedIn8Warning") - result.stdout.fnmatch_lines( - [ - "'unknown' not found in `markers` configuration option", - "*PytestRemovedIn8Warning: The --strict option is deprecated, use --strict-markers instead.", - ] - ) - - def test_yield_fixture_is_deprecated() -> None: with pytest.warns(DeprecationWarning, match=r"yield_fixture is deprecated"):