summaryrefslogtreecommitdiff
path: root/src/_pytest
diff options
context:
space:
mode:
authorBruno Oliveira <nicoddemus@gmail.com>2020-11-06 05:48:20 -0300
committerGitHub <noreply@github.com>2020-11-06 09:48:20 +0100
commit30287b49cd02b6a14ade1bbe9adf9711c3d1259e (patch)
treee60be4d29f6b11927f2978e65b7e1546af2d119c /src/_pytest
parent4cd0fde277f657560bf5c4453d3b645094d2c747 (diff)
downloadpytest-30287b49cd02b6a14ade1bbe9adf9711c3d1259e.tar.gz
Deprecate --strict (#7985)
Fix #7530
Diffstat (limited to 'src/_pytest')
-rw-r--r--src/_pytest/config/__init__.py5
-rw-r--r--src/_pytest/deprecated.py4
-rw-r--r--src/_pytest/main.py4
-rw-r--r--src/_pytest/mark/structures.py2
4 files changed, 13 insertions, 2 deletions
diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py
index 7e486e99e..6c1d9c69a 100644
--- a/src/_pytest/config/__init__.py
+++ b/src/_pytest/config/__init__.py
@@ -1177,6 +1177,11 @@ 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 and self.inipath is not None:
confcutdir = str(self.inipath.parent)
self.known_args_namespace.confcutdir = confcutdir
diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py
index fd00fe2d6..a9a162f41 100644
--- a/src/_pytest/deprecated.py
+++ b/src/_pytest/deprecated.py
@@ -51,3 +51,7 @@ FSCOLLECTOR_GETHOOKPROXY_ISINITPATH = PytestDeprecationWarning(
"The gethookproxy() and isinitpath() methods of FSCollector and Package are deprecated; "
"use self.session.gethookproxy() and self.session.isinitpath() instead. "
)
+
+STRICT_OPTION = PytestDeprecationWarning(
+ "The --strict option is deprecated, use --strict-markers instead."
+)
diff --git a/src/_pytest/main.py b/src/_pytest/main.py
index d8a208a1a..04b51ac00 100644
--- a/src/_pytest/main.py
+++ b/src/_pytest/main.py
@@ -101,11 +101,13 @@ def pytest_addoption(parser: Parser) -> None:
)
group._addoption(
"--strict-markers",
- "--strict",
action="store_true",
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(
"-c",
metavar="file",
type=str,
diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py
index 6cbdf8b30..6c126cf4a 100644
--- a/src/_pytest/mark/structures.py
+++ b/src/_pytest/mark/structures.py
@@ -496,7 +496,7 @@ class MarkGenerator:
# 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.
if name not in self._markers:
- if self._config.option.strict_markers:
+ if self._config.option.strict_markers or self._config.option.strict:
fail(
f"{name!r} not found in `markers` configuration option",
pytrace=False,