Move warning messages to _pytest.deprecated
This commit is contained in:
parent
feb8240410
commit
32ee0b9c88
|
@ -18,6 +18,22 @@ YIELD_TESTS = RemovedInPytest4Warning(
|
||||||
"yield tests are deprecated, and scheduled to be removed in pytest 4.0"
|
"yield tests are deprecated, and scheduled to be removed in pytest 4.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
CACHED_SETUP = RemovedInPytest4Warning(
|
||||||
|
"cached_setup is deprecated and will be removed in a future release. "
|
||||||
|
"Use standard fixture functions instead."
|
||||||
|
)
|
||||||
|
|
||||||
|
COMPAT_PROPERTY = (
|
||||||
|
"usage of {owner}.{name} is deprecated, please use pytest.{name} instead"
|
||||||
|
)
|
||||||
|
|
||||||
|
CUSTOM_CLASS = (
|
||||||
|
'use of special named "{name}" objects in collectors of type "{type_name}" to '
|
||||||
|
"customize the created nodes is deprecated. "
|
||||||
|
"Use pytest_pycollect_makeitem(...) to create custom "
|
||||||
|
"collection nodes instead."
|
||||||
|
)
|
||||||
|
|
||||||
FUNCARG_PREFIX = (
|
FUNCARG_PREFIX = (
|
||||||
'{name}: declaring fixtures using "pytest_funcarg__" prefix is deprecated '
|
'{name}: declaring fixtures using "pytest_funcarg__" prefix is deprecated '
|
||||||
"and scheduled to be removed in pytest 4.0. "
|
"and scheduled to be removed in pytest 4.0. "
|
||||||
|
|
|
@ -479,11 +479,9 @@ class FixtureRequest(FuncargnamesCompatAttr):
|
||||||
or ``session`` indicating the caching lifecycle of the resource.
|
or ``session`` indicating the caching lifecycle of the resource.
|
||||||
:arg extrakey: added to internal caching key of (funcargname, scope).
|
:arg extrakey: added to internal caching key of (funcargname, scope).
|
||||||
"""
|
"""
|
||||||
msg = (
|
from _pytest.deprecated import CACHED_SETUP
|
||||||
"cached_setup is deprecated and will be removed in a future release. "
|
|
||||||
"Use standard fixture functions instead."
|
warnings.warn(CACHED_SETUP, stacklevel=2)
|
||||||
)
|
|
||||||
warnings.warn(RemovedInPytest4Warning(msg), stacklevel=2)
|
|
||||||
if not hasattr(self.config, "_setupcache"):
|
if not hasattr(self.config, "_setupcache"):
|
||||||
self.config._setupcache = {} # XXX weakref?
|
self.config._setupcache = {} # XXX weakref?
|
||||||
cachekey = (self.fixturename, self._getscopeitem(scope), extrakey)
|
cachekey = (self.fixturename, self._getscopeitem(scope), extrakey)
|
||||||
|
|
|
@ -62,11 +62,12 @@ class _CompatProperty(object):
|
||||||
if obj is None:
|
if obj is None:
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
from _pytest.deprecated import COMPAT_PROPERTY
|
||||||
|
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"usage of {owner}.{name} is deprecated, please use pytest.{name} instead".format(
|
RemovedInPytest4Warning(
|
||||||
name=self.name, owner=owner.__name__
|
COMPAT_PROPERTY.format(name=self.name, owner=owner.__name__)
|
||||||
),
|
),
|
||||||
RemovedInPytest4Warning,
|
|
||||||
stacklevel=2,
|
stacklevel=2,
|
||||||
)
|
)
|
||||||
return getattr(__import__("pytest"), self.name)
|
return getattr(__import__("pytest"), self.name)
|
||||||
|
@ -129,14 +130,14 @@ class Node(object):
|
||||||
if isinstance(maybe_compatprop, _CompatProperty):
|
if isinstance(maybe_compatprop, _CompatProperty):
|
||||||
return getattr(__import__("pytest"), name)
|
return getattr(__import__("pytest"), name)
|
||||||
else:
|
else:
|
||||||
|
from _pytest.deprecated import CUSTOM_CLASS
|
||||||
|
|
||||||
cls = getattr(self, name)
|
cls = getattr(self, name)
|
||||||
msg = (
|
self.warn(
|
||||||
'use of special named "%s" objects in collectors of type "%s" to '
|
RemovedInPytest4Warning(
|
||||||
"customize the created nodes is deprecated. "
|
CUSTOM_CLASS.format(name=name, type_name=type(self).__name__)
|
||||||
"Use pytest_pycollect_makeitem(...) to create custom "
|
)
|
||||||
"collection nodes instead." % (name, type(self).__name__)
|
|
||||||
)
|
)
|
||||||
self.warn(RemovedInPytest4Warning(msg))
|
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
|
Loading…
Reference in New Issue