diff options
| author | Matti Picus <matti.picus@gmail.com> | 2020-12-29 11:00:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-29 11:00:14 +0200 |
| commit | 717df4e93234a1a290aa1b472b5c1c4e600009cd (patch) | |
| tree | 4a55bd33af1e0857e4909b6a9b21c81efee710bd /numpy/testing/_private | |
| parent | a481a044c8cbd679ca736341056314ffd71d54a4 (diff) | |
| parent | dd25816ccb9701af74895c95d3f0f2d31abbdf01 (diff) | |
| download | numpy-717df4e93234a1a290aa1b472b5c1c4e600009cd.tar.gz | |
Merge pull request #18051 from rpolley/deprecate-np-testing-dec-2
DEP: deprecate np.testing.dec
Diffstat (limited to 'numpy/testing/_private')
| -rw-r--r-- | numpy/testing/_private/decorators.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/numpy/testing/_private/decorators.py b/numpy/testing/_private/decorators.py index 4c87d1a49..cb49d9a73 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.21 + 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,19 @@ def slow(t): print('Big, slow test') """ + # Numpy 1.21, 2020-12-20 + warnings.warn('the np.testing.dec decorators are included for nose support, and are ' + 'deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.', DeprecationWarning, stacklevel=2) t.slow = True return t def setastest(tf=True): """ + .. deprecated:: 1.21 + 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 +96,9 @@ def setastest(tf=True): pass """ + # Numpy 1.21, 2020-12-20 + warnings.warn('the np.testing.dec decorators are included for nose support, and are ' + 'deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.', DeprecationWarning, stacklevel=2) def set_test(t): t.__test__ = tf return t @@ -91,6 +106,10 @@ def setastest(tf=True): def skipif(skip_condition, msg=None): """ + .. deprecated:: 1.21 + 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 +142,10 @@ def skipif(skip_condition, msg=None): # import time overhead at actual test-time. import nose + # Numpy 1.21, 2020-12-20 + warnings.warn('the np.testing.dec decorators are included for nose support, and are ' + 'deprecated since NumPy v1.21. 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 +190,10 @@ def skipif(skip_condition, msg=None): def knownfailureif(fail_condition, msg=None): """ + .. deprecated:: 1.21 + 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 +222,10 @@ def knownfailureif(fail_condition, msg=None): function in order to transmit function name, and various other metadata. """ + # Numpy 1.21, 2020-12-20 + warnings.warn('the np.testing.dec decorators are included for nose support, and are ' + 'deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.', DeprecationWarning, stacklevel=2) + if msg is None: msg = 'Test skipped due to known failure' @@ -221,6 +252,10 @@ def knownfailureif(fail_condition, msg=None): def deprecated(conditional=True): """ + .. deprecated:: 1.21 + 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 +284,10 @@ def deprecated(conditional=True): # import time overhead at actual test-time. import nose + # Numpy 1.21, 2020-12-20 + warnings.warn('the np.testing.dec decorators are included for nose support, and are ' + 'deprecated since NumPy v1.21. 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 +306,10 @@ def deprecated(conditional=True): def parametrize(vars, input): """ + .. deprecated:: 1.21 + 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 +322,10 @@ def parametrize(vars, input): """ from .parameterized import parameterized + # Numpy 1.21, 2020-12-20 + warnings.warn('the np.testing.dec decorators are included for nose support, and are ' + 'deprecated since NumPy v1.21. Use the nose2 or pytest frameworks instead.', DeprecationWarning, stacklevel=2) + return parameterized(input) _needs_refcount = skipif(not HAS_REFCOUNT, "python has no sys.getrefcount") |
