parent
4cd0fde277
commit
30287b49cd
|
@ -0,0 +1,4 @@
|
||||||
|
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).
|
|
@ -18,6 +18,19 @@ Deprecated Features
|
||||||
Below is a complete list of all pytest features which are considered deprecated. Using those features will issue
|
Below is a complete list of all pytest features which are considered deprecated. Using those features will issue
|
||||||
:class:`PytestWarning` or subclasses, which can be filtered using :ref:`standard warning filters <warnings>`.
|
:class:`PytestWarning` or subclasses, which can be filtered using :ref:`standard warning filters <warnings>`.
|
||||||
|
|
||||||
|
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 ``pytest_warning_captured`` hook
|
The ``pytest_warning_captured`` hook
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
|
@ -1177,6 +1177,11 @@ class Config:
|
||||||
self._validate_plugins()
|
self._validate_plugins()
|
||||||
self._warn_about_skipped_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 and self.inipath is not None:
|
if self.known_args_namespace.confcutdir is None and self.inipath is not None:
|
||||||
confcutdir = str(self.inipath.parent)
|
confcutdir = str(self.inipath.parent)
|
||||||
self.known_args_namespace.confcutdir = confcutdir
|
self.known_args_namespace.confcutdir = confcutdir
|
||||||
|
|
|
@ -51,3 +51,7 @@ FSCOLLECTOR_GETHOOKPROXY_ISINITPATH = PytestDeprecationWarning(
|
||||||
"The gethookproxy() and isinitpath() methods of FSCollector and Package are deprecated; "
|
"The gethookproxy() and isinitpath() methods of FSCollector and Package are deprecated; "
|
||||||
"use self.session.gethookproxy() and self.session.isinitpath() instead. "
|
"use self.session.gethookproxy() and self.session.isinitpath() instead. "
|
||||||
)
|
)
|
||||||
|
|
||||||
|
STRICT_OPTION = PytestDeprecationWarning(
|
||||||
|
"The --strict option is deprecated, use --strict-markers instead."
|
||||||
|
)
|
||||||
|
|
|
@ -101,10 +101,12 @@ def pytest_addoption(parser: Parser) -> None:
|
||||||
)
|
)
|
||||||
group._addoption(
|
group._addoption(
|
||||||
"--strict-markers",
|
"--strict-markers",
|
||||||
"--strict",
|
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="markers not registered in the `markers` section of the configuration file raise errors.",
|
help="markers not registered in the `markers` section of the configuration file raise errors.",
|
||||||
)
|
)
|
||||||
|
group._addoption(
|
||||||
|
"--strict", action="store_true", help="(deprecated) alias to --strict-markers.",
|
||||||
|
)
|
||||||
group._addoption(
|
group._addoption(
|
||||||
"-c",
|
"-c",
|
||||||
metavar="file",
|
metavar="file",
|
||||||
|
|
|
@ -496,7 +496,7 @@ class MarkGenerator:
|
||||||
# If the name is not in the set of known marks after updating,
|
# If the name is not in the set of known marks after updating,
|
||||||
# then it really is time to issue a warning or an error.
|
# then it really is time to issue a warning or an error.
|
||||||
if name not in self._markers:
|
if name not in self._markers:
|
||||||
if self._config.option.strict_markers:
|
if self._config.option.strict_markers or self._config.option.strict:
|
||||||
fail(
|
fail(
|
||||||
f"{name!r} not found in `markers` configuration option",
|
f"{name!r} not found in `markers` configuration option",
|
||||||
pytrace=False,
|
pytrace=False,
|
||||||
|
|
|
@ -4,6 +4,7 @@ from unittest import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest import deprecated
|
from _pytest import deprecated
|
||||||
|
from _pytest.pytester import Pytester
|
||||||
from _pytest.pytester import Testdir
|
from _pytest.pytester import Testdir
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,3 +96,22 @@ def test_fscollector_gethookproxy_isinitpath(testdir: Testdir) -> None:
|
||||||
session.gethookproxy(testdir.tmpdir)
|
session.gethookproxy(testdir.tmpdir)
|
||||||
session.isinitpath(testdir.tmpdir)
|
session.isinitpath(testdir.tmpdir)
|
||||||
assert len(rec) == 0
|
assert len(rec) == 0
|
||||||
|
|
||||||
|
|
||||||
|
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")
|
||||||
|
result.stdout.fnmatch_lines(
|
||||||
|
[
|
||||||
|
"'unknown' not found in `markers` configuration option",
|
||||||
|
"*PytestDeprecationWarning: The --strict option is deprecated, use --strict-markers instead.",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue