Move PytestExerimentalApiWarning to warning_types

This commit is contained in:
Bruno Oliveira
2018-09-04 10:48:11 -03:00
parent b818314045
commit 8ce3aeadbf
6 changed files with 28 additions and 18 deletions

View File

@@ -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")

View File

@@ -642,10 +642,12 @@ class Testdir(object):
return p
def copy_example(self, name=None):
from . import experiments
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")
if example_dir is None:
raise ValueError("pytester_example_dir is unset, can't copy examples")

View File

@@ -20,3 +20,20 @@ class RemovedInPytest4Warning(PytestDeprecationWarning):
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
)
)