summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorRyan Polley <rypolley@gmail.com>2020-12-20 20:45:36 -0600
committerRyan Polley <rypolley@gmail.com>2020-12-20 20:45:36 -0600
commitf5579746f07a4f40d8b9391336fac0ee79659d22 (patch)
tree6b1235c092a71f70e9679b506a044635cc9584a9 /numpy
parentd7a75e8e8fefc433cf6e5305807d5f3180954273 (diff)
downloadnumpy-f5579746f07a4f40d8b9391336fac0ee79659d22.tar.gz
DEC: deprecate the decorators in np.testing.dec
Since the decorators in np.testing.dec are intended for nose test framework support, deprecate them by updating the docstring and adding a warning when they are used on functions
Diffstat (limited to 'numpy')
-rw-r--r--numpy/testing/_private/decorators.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/numpy/testing/_private/decorators.py b/numpy/testing/_private/decorators.py
index 4c87d1a49..a18b3aa2e 100644
--- a/numpy/testing/_private/decorators.py
+++ b/numpy/testing/_private/decorators.py
@@ -14,6 +14,7 @@ function name, setup and teardown functions and so on - see
"""
import collections.abc
+import warnings
from .utils import SkipTest, assert_warns, HAS_REFCOUNT
@@ -23,6 +24,10 @@ __all__ = ['slow', 'setastest', 'skipif', 'knownfailureif', 'deprecated',
def slow(t):
"""
+ .. deprecated:: 1.20
+ This decorator is retained for compatibility with the nose testing framework, which is being phased out.
+ Please use the nose2 or pytest frameworks instead.
+
Label a test as 'slow'.
The exact definition of a slow test is obviously both subjective and
@@ -52,12 +57,18 @@ def slow(t):
print('Big, slow test')
"""
+ warnings.warn('the np.testing.dec decorators are included for nose support, and are '
+ 'deprecated since NumPy v1.20. Use the nose2 or pytest frameworks instead.', DeprecationWarning, stacklevel=2)
t.slow = True
return t
def setastest(tf=True):
"""
+ .. deprecated:: 1.20
+ This decorator is retained for compatibility with the nose testing framework, which is being phased out.
+ Please use the nose2 or pytest frameworks instead.
+
Signals to nose that this function is or is not a test.
Parameters
@@ -84,6 +95,8 @@ def setastest(tf=True):
pass
"""
+ warnings.warn('the np.testing.dec decorators are included for nose support, and are '
+ 'deprecated since NumPy v1.20. Use the nose2 or pytest frameworks instead.', DeprecationWarning, stacklevel=2)
def set_test(t):
t.__test__ = tf
return t
@@ -91,6 +104,10 @@ def setastest(tf=True):
def skipif(skip_condition, msg=None):
"""
+ .. deprecated:: 1.20
+ This decorator is retained for compatibility with the nose testing framework, which is being phased out.
+ Please use the nose2 or pytest frameworks instead.
+
Make function raise SkipTest exception if a given condition is true.
If the condition is a callable, it is used at runtime to dynamically
@@ -123,6 +140,9 @@ def skipif(skip_condition, msg=None):
# import time overhead at actual test-time.
import nose
+ warnings.warn('the np.testing.dec decorators are included for nose support, and are '
+ 'deprecated since NumPy v1.20. Use the nose2 or pytest frameworks instead.', DeprecationWarning, stacklevel=2)
+
# Allow for both boolean or callable skip conditions.
if isinstance(skip_condition, collections.abc.Callable):
skip_val = lambda: skip_condition()
@@ -167,6 +187,10 @@ def skipif(skip_condition, msg=None):
def knownfailureif(fail_condition, msg=None):
"""
+ .. deprecated:: 1.20
+ This decorator is retained for compatibility with the nose testing framework, which is being phased out.
+ Please use the nose2 or pytest frameworks instead.
+
Make function raise KnownFailureException exception if given condition is true.
If the condition is a callable, it is used at runtime to dynamically
@@ -195,6 +219,9 @@ def knownfailureif(fail_condition, msg=None):
function in order to transmit function name, and various other metadata.
"""
+ warnings.warn('the np.testing.dec decorators are included for nose support, and are '
+ 'deprecated since NumPy v1.20. Use the nose2 or pytest frameworks instead.', DeprecationWarning, stacklevel=2)
+
if msg is None:
msg = 'Test skipped due to known failure'
@@ -221,6 +248,10 @@ def knownfailureif(fail_condition, msg=None):
def deprecated(conditional=True):
"""
+ .. deprecated:: 1.20
+ This decorator is retained for compatibility with the nose testing framework, which is being phased out.
+ Please use the nose2 or pytest frameworks instead.
+
Filter deprecation warnings while running the test suite.
This decorator can be used to filter DeprecationWarning's, to avoid
@@ -249,6 +280,9 @@ def deprecated(conditional=True):
# import time overhead at actual test-time.
import nose
+ warnings.warn('the np.testing.dec decorators are included for nose support, and are '
+ 'deprecated since NumPy v1.20. Use the nose2 or pytest frameworks instead.', DeprecationWarning, stacklevel=2)
+
def _deprecated_imp(*args, **kwargs):
# Poor man's replacement for the with statement
with assert_warns(DeprecationWarning):
@@ -267,6 +301,10 @@ def deprecated(conditional=True):
def parametrize(vars, input):
"""
+ .. deprecated:: 1.20
+ This decorator is retained for compatibility with the nose testing framework, which is being phased out.
+ Please use the nose2 or pytest frameworks instead.
+
Pytest compatibility class. This implements the simplest level of
pytest.mark.parametrize for use in nose as an aid in making the transition
to pytest. It achieves that by adding a dummy var parameter and ignoring
@@ -279,6 +317,9 @@ def parametrize(vars, input):
"""
from .parameterized import parameterized
+ warnings.warn('the np.testing.dec decorators are included for nose support, and are '
+ 'deprecated since NumPy v1.20. Use the nose2 or pytest frameworks instead.', DeprecationWarning, stacklevel=2)
+
return parameterized(input)
_needs_refcount = skipif(not HAS_REFCOUNT, "python has no sys.getrefcount")