Make PytestWarning and RemovedInPytest4Warning part of the public API
This commit is contained in:
parent
78ac7d99f5
commit
19a01c9849
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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__
|
||||
)
|
||||
|
|
|
@ -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"""
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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"
|
||||
)
|
||||
|
||||
|
||||
|
|
6
tox.ini
6
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
|
||||
|
|
Loading…
Reference in New Issue