diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index d5ec5dbbf..69beeab5f 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -10,24 +10,8 @@ in case of warnings which need to format their messages. """ from __future__ import absolute_import, division, print_function -import attr -from _pytest.warning_types import RemovedInPytest4Warning - - -@attr.s -class UnformattedWarning(object): - """Used to hold warnings that need to format their message at runtime, as opposed to a direct message. - - Using this class avoids to keep all the warning types and messages in this module, avoiding misuse. - """ - - category = attr.ib() - template = attr.ib() - - def format(self, **kwargs): - """Returns an instance of the warning category, formatted with given kwargs""" - return self.category(self.template.format(**kwargs)) +from _pytest.warning_types import UnformattedWarning, RemovedInPytest4Warning MAIN_STR_ARGS = RemovedInPytest4Warning( diff --git a/src/_pytest/warning_types.py b/src/_pytest/warning_types.py index 8861f6f2b..55e1f037a 100644 --- a/src/_pytest/warning_types.py +++ b/src/_pytest/warning_types.py @@ -1,3 +1,6 @@ +import attr + + class PytestWarning(UserWarning): """ Bases: :class:`UserWarning`. @@ -39,4 +42,19 @@ class PytestExperimentalApiWarning(PytestWarning, FutureWarning): ) +@attr.s +class UnformattedWarning(object): + """Used to hold warnings that need to format their message at runtime, as opposed to a direct message. + + Using this class avoids to keep all the warning types and messages in this module, avoiding misuse. + """ + + category = attr.ib() + template = attr.ib() + + def format(self, **kwargs): + """Returns an instance of the warning category, formatted with given kwargs""" + return self.category(self.template.format(**kwargs)) + + PYTESTER_COPY_EXAMPLE = PytestExperimentalApiWarning.simple("testdir.copy_example")