From 8532e991a53732a241f0d2b4b1f254a6db597b69 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sun, 28 Apr 2019 10:06:01 -0300 Subject: [PATCH] Publish UnknownMarkWarning as part of the public API and docs --- doc/en/warnings.rst | 2 ++ src/_pytest/mark/structures.py | 4 ++-- src/_pytest/warning_types.py | 2 +- src/pytest.py | 2 ++ tox.ini | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/en/warnings.rst b/doc/en/warnings.rst index 26bd2fdb2..54740b970 100644 --- a/doc/en/warnings.rst +++ b/doc/en/warnings.rst @@ -420,3 +420,5 @@ The following warning types ares used by pytest and are part of the public API: .. autoclass:: pytest.RemovedInPytest4Warning .. autoclass:: pytest.PytestExperimentalApiWarning + +.. autoclass:: pytest.PytestUnknownMarkWarning diff --git a/src/_pytest/mark/structures.py b/src/_pytest/mark/structures.py index 4cae97b71..b4ff6e988 100644 --- a/src/_pytest/mark/structures.py +++ b/src/_pytest/mark/structures.py @@ -12,7 +12,7 @@ from ..compat import MappingMixin from ..compat import NOTSET from _pytest.deprecated import PYTEST_PARAM_UNKNOWN_KWARGS from _pytest.outcomes import fail -from _pytest.warning_types import UnknownMarkWarning +from _pytest.warning_types import PytestUnknownMarkWarning EMPTY_PARAMETERSET_OPTION = "empty_parameter_set_mark" @@ -318,7 +318,7 @@ class MarkGenerator(object): "Unknown pytest.mark.%s - is this a typo? You can register " "custom marks to avoid this warning - for details, see " "https://docs.pytest.org/en/latest/mark.html" % name, - UnknownMarkWarning, + PytestUnknownMarkWarning, ) return MarkDecorator(Mark(name, (), {})) diff --git a/src/_pytest/warning_types.py b/src/_pytest/warning_types.py index ffc6e69d6..70f41a2b2 100644 --- a/src/_pytest/warning_types.py +++ b/src/_pytest/warning_types.py @@ -9,7 +9,7 @@ class PytestWarning(UserWarning): """ -class UnknownMarkWarning(PytestWarning): +class PytestUnknownMarkWarning(PytestWarning): """ Bases: :class:`PytestWarning`. diff --git a/src/pytest.py b/src/pytest.py index c0010f166..2be72ce77 100644 --- a/src/pytest.py +++ b/src/pytest.py @@ -37,6 +37,7 @@ from _pytest.recwarn import deprecated_call from _pytest.recwarn import warns from _pytest.warning_types import PytestDeprecationWarning from _pytest.warning_types import PytestExperimentalApiWarning +from _pytest.warning_types import PytestUnknownMarkWarning from _pytest.warning_types import PytestWarning from _pytest.warning_types import RemovedInPytest4Warning @@ -72,6 +73,7 @@ __all__ = [ "raises", "register_assert_rewrite", "RemovedInPytest4Warning", + "PytestUnknownMarkWarning", "Session", "set_trace", "skip", diff --git a/tox.ini b/tox.ini index e297b7099..3c1ca65b7 100644 --- a/tox.ini +++ b/tox.ini @@ -169,7 +169,7 @@ filterwarnings = # Do not cause SyntaxError for invalid escape sequences in py37. default:invalid escape sequence:DeprecationWarning # ignore use of unregistered marks, because we use many to test the implementation - ignore::_pytest.warning_types.UnknownMarkWarning + ignore::_pytest.warning_types.PytestUnknownMarkWarning pytester_example_dir = testing/example_scripts markers = issue