diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index f0aecbe55..cec56e800 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -176,9 +176,9 @@ def _prepareconfig(args=None, plugins=None): else: pluginmanager.register(plugin) if warning: - from _pytest.warning_types import PytestUsageWarning + from _pytest.warning_types import PytestWarning - warnings.warn(warning, PytestUsageWarning) + warnings.warn(warning, PytestWarning) return pluginmanager.hook.pytest_cmdline_parse( pluginmanager=pluginmanager, args=args ) diff --git a/src/_pytest/python.py b/src/_pytest/python.py index 5a531766b..9ac216332 100644 --- a/src/_pytest/python.py +++ b/src/_pytest/python.py @@ -44,11 +44,7 @@ from _pytest.mark.structures import ( get_unpacked_marks, normalize_mark_list, ) -from _pytest.warning_types import ( - PytestUsageWarning, - RemovedInPytest4Warning, - PytestWarning, -) +from _pytest.warning_types import RemovedInPytest4Warning, PytestWarning # relative paths that we use to filter traceback entries from appearing to the user; # see filter_traceback @@ -671,12 +667,12 @@ class Class(PyCollector): self.std_warn( "cannot collect test class %r because it has a " "__init__ constructor" % self.obj.__name__, - PytestUsageWarning, + PytestWarning, ) return [] elif hasnew(self.obj): self.std_warn( - PytestUsageWarning( + PytestWarning( "cannot collect test class %r because it has a " "__new__ constructor" % self.obj.__name__ ) diff --git a/src/_pytest/warning_types.py b/src/_pytest/warning_types.py index be06f39c9..a98732ee3 100644 --- a/src/_pytest/warning_types.py +++ b/src/_pytest/warning_types.py @@ -2,9 +2,5 @@ class PytestWarning(UserWarning): """Base class for all warnings emitted by pytest""" -class PytestUsageWarning(PytestWarning): - """Warnings related to pytest usage: either command line or testing code.""" - - class RemovedInPytest4Warning(PytestWarning, DeprecationWarning): """warning class for features that will be removed in pytest 4.0""" diff --git a/src/pytest.py b/src/pytest.py index ae542b76d..bf6a9416f 100644 --- a/src/pytest.py +++ b/src/pytest.py @@ -19,45 +19,47 @@ from _pytest.main import Session from _pytest.nodes import Item, Collector, File from _pytest.fixtures import fillfixtures as _fillfuncargs from _pytest.python import Package, Module, Class, Instance, Function, Generator - from _pytest.python_api import approx, raises +from _pytest.warning_types import PytestWarning, RemovedInPytest4Warning set_trace = __pytestPDB.set_trace __all__ = [ - "main", - "UsageError", - "cmdline", - "hookspec", - "hookimpl", "__version__", - "register_assert_rewrite", - "freeze_includes", - "set_trace", - "warns", - "deprecated_call", - "fixture", - "yield_fixture", - "fail", - "skip", - "xfail", - "importorskip", - "exit", - "mark", - "param", - "approx", "_fillfuncargs", - "Item", - "File", - "Collector", - "Package", - "Session", - "Module", + "approx", "Class", - "Instance", + "cmdline", + "Collector", + "deprecated_call", + "exit", + "fail", + "File", + "fixture", + "freeze_includes", "Function", "Generator", + "hookimpl", + "hookspec", + "importorskip", + "Instance", + "Item", + "main", + "mark", + "Module", + "Package", + "param", + "PytestWarning", "raises", + "register_assert_rewrite", + "RemovedInPytest4Warning", + "Session", + "set_trace", + "skip", + "UsageError", + "warns", + "xfail", + "yield_fixture", ] if __name__ == "__main__": diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index fdbaa9e90..c82e1dccf 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -761,9 +761,8 @@ def test_rewritten(): def test_rewrite_warning(self, pytestconfig): hook = AssertionRewritingHook(pytestconfig) - from _pytest.warning_types import PytestWarning - with pytest.warns(PytestWarning): + with pytest.warns(pytest.PytestWarning): hook.mark_rewrite("_pytest") def test_rewrite_module_imported_from_conftest(self, testdir): diff --git a/testing/test_mark.py b/testing/test_mark.py index ae41fb1b8..12aded416 100644 --- a/testing/test_mark.py +++ b/testing/test_mark.py @@ -16,7 +16,7 @@ from _pytest.mark import ( from _pytest.nodes import Node ignore_markinfo = pytest.mark.filterwarnings( - "ignore:MarkInfo objects:_pytest.warning_types.RemovedInPytest4Warning" + "ignore:MarkInfo objects:pytest.RemovedInPytest4Warning" ) diff --git a/tox.ini b/tox.ini index d1e251e99..4b5eae066 100644 --- a/tox.ini +++ b/tox.ini @@ -218,9 +218,9 @@ norecursedirs = .tox ja .hg cx_freeze_source testing/example_scripts xfail_strict=true filterwarnings = error - ignore:yield tests are deprecated, and scheduled to be removed in pytest 4.0: - ignore:Metafunc.addcall is deprecated and scheduled to be removed in pytest 4.0: - ignore:Module already imported so cannot be rewritten: + ignore:yield tests are deprecated, and scheduled to be removed in pytest 4.0:pytest.RemovedInPytest4Warning + ignore:Metafunc.addcall is deprecated and scheduled to be removed in pytest 4.0:pytest.RemovedInPytest4Warning + ignore:Module already imported so cannot be rewritten:pytest.PytestWarning # produced by path.local ignore:bad escape.*:DeprecationWarning:re # produced by path.readlines