Move PytestExerimentalApiWarning to warning_types
This commit is contained in:
parent
b818314045
commit
8ce3aeadbf
|
@ -378,3 +378,5 @@ The following warning types ares used by pytest and are part of the public API:
|
||||||
|
|
||||||
.. autoclass:: pytest.RemovedInPytest4Warning
|
.. autoclass:: pytest.RemovedInPytest4Warning
|
||||||
|
|
||||||
|
.. autoclass:: pytest.PytestExerimentalApiWarning
|
||||||
|
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
class PytestExerimentalApiWarning(FutureWarning):
|
|
||||||
"warning category used to denote experiments in pytest"
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def simple(cls, apiname):
|
|
||||||
return cls(
|
|
||||||
"{apiname} is an experimental api that may change over time".format(
|
|
||||||
apiname=apiname
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
PYTESTER_COPY_EXAMPLE = PytestExerimentalApiWarning.simple("testdir.copy_example")
|
|
|
@ -642,10 +642,12 @@ class Testdir(object):
|
||||||
return p
|
return p
|
||||||
|
|
||||||
def copy_example(self, name=None):
|
def copy_example(self, name=None):
|
||||||
from . import experiments
|
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
warnings.warn(experiments.PYTESTER_COPY_EXAMPLE, stacklevel=2)
|
warnings.warn(
|
||||||
|
pytest.PytestExerimentalApiWarning.simple("testdir.copy_example"),
|
||||||
|
stacklevel=2,
|
||||||
|
)
|
||||||
example_dir = self.request.config.getini("pytester_example_dir")
|
example_dir = self.request.config.getini("pytester_example_dir")
|
||||||
if example_dir is None:
|
if example_dir is None:
|
||||||
raise ValueError("pytester_example_dir is unset, can't copy examples")
|
raise ValueError("pytester_example_dir is unset, can't copy examples")
|
||||||
|
|
|
@ -20,3 +20,20 @@ class RemovedInPytest4Warning(PytestDeprecationWarning):
|
||||||
|
|
||||||
Warning class for features scheduled to be removed in pytest 4.0.
|
Warning class for features scheduled to be removed in pytest 4.0.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class PytestExerimentalApiWarning(PytestWarning, FutureWarning):
|
||||||
|
"""
|
||||||
|
Bases: :class:`pytest.PytestWarning`, :class:`FutureWarning`.
|
||||||
|
|
||||||
|
Warning category used to denote experiments in pytest. Use sparingly as the API might change or even be
|
||||||
|
removed completely in future version
|
||||||
|
"""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def simple(cls, apiname):
|
||||||
|
return cls(
|
||||||
|
"{apiname} is an experimental api that may change over time".format(
|
||||||
|
apiname=apiname
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
|
@ -24,6 +24,7 @@ from _pytest.warning_types import (
|
||||||
PytestWarning,
|
PytestWarning,
|
||||||
PytestDeprecationWarning,
|
PytestDeprecationWarning,
|
||||||
RemovedInPytest4Warning,
|
RemovedInPytest4Warning,
|
||||||
|
PytestExerimentalApiWarning,
|
||||||
)
|
)
|
||||||
|
|
||||||
set_trace = __pytestPDB.set_trace
|
set_trace = __pytestPDB.set_trace
|
||||||
|
@ -53,8 +54,9 @@ __all__ = [
|
||||||
"Module",
|
"Module",
|
||||||
"Package",
|
"Package",
|
||||||
"param",
|
"param",
|
||||||
"PytestWarning",
|
|
||||||
"PytestDeprecationWarning",
|
"PytestDeprecationWarning",
|
||||||
|
"PytestExerimentalApiWarning",
|
||||||
|
"PytestWarning",
|
||||||
"raises",
|
"raises",
|
||||||
"register_assert_rewrite",
|
"register_assert_rewrite",
|
||||||
"RemovedInPytest4Warning",
|
"RemovedInPytest4Warning",
|
||||||
|
|
4
tox.ini
4
tox.ini
|
@ -229,8 +229,8 @@ filterwarnings =
|
||||||
ignore:.*type argument to addoption.*:DeprecationWarning
|
ignore:.*type argument to addoption.*:DeprecationWarning
|
||||||
# produced by python >=3.5 on execnet (pytest-xdist)
|
# produced by python >=3.5 on execnet (pytest-xdist)
|
||||||
ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning
|
ignore:.*inspect.getargspec.*deprecated, use inspect.signature.*:DeprecationWarning
|
||||||
#pytests own futurewarnings
|
# pytest's own futurewarnings
|
||||||
ignore::_pytest.experiments.PytestExerimentalApiWarning
|
ignore::pytest.PytestExerimentalApiWarning
|
||||||
pytester_example_dir = testing/example_scripts
|
pytester_example_dir = testing/example_scripts
|
||||||
[flake8]
|
[flake8]
|
||||||
max-line-length = 120
|
max-line-length = 120
|
||||||
|
|
Loading…
Reference in New Issue