summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/tests/test_multiarray.py21
-rw-r--r--numpy/core/tests/test_regression.py4
-rw-r--r--numpy/testing/_private/utils.py21
3 files changed, 24 insertions, 22 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 1cec8ac20..d47f1e17e 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -44,6 +44,7 @@ from numpy.testing import (
assert_allclose, IS_PYPY, HAS_REFCOUNT, assert_array_less, runstring,
temppath, suppress_warnings, break_cycles,
)
+from numpy.testing._private.utils import _no_tracing
from numpy.core.tests._locales import CommaDecimalPointLocale
# Need to test an object that does not fully implement math interface
@@ -94,26 +95,6 @@ def _aligned_zeros(shape, dtype=float, order="C", align=None):
data.fill(0)
return data
-def _no_tracing(func):
- """
- Decorator to temporarily turn off tracing for the duration of a test.
- Needed in tests that check refcounting, otherwise the tracing itself
- influences the refcounts
- """
- if not hasattr(sys, 'gettrace'):
- return func
- else:
- @functools.wraps(func)
- def wrapper(*args, **kwargs):
- original_trace = sys.gettrace()
- try:
- sys.settrace(None)
- return func(*args, **kwargs)
- finally:
- sys.settrace(original_trace)
- return wrapper
-
-
class TestFlags:
def setup(self):
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index c77c11d41..10255b88d 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -14,8 +14,8 @@ from numpy.testing import (
assert_raises_regex, assert_warns, suppress_warnings,
_assert_valid_refcount, HAS_REFCOUNT,
)
+from numpy.testing._private.utils import _no_tracing
from numpy.compat import asbytes, asunicode, long, pickle
-from test.support import no_tracing
try:
RecursionError
@@ -1315,7 +1315,7 @@ class TestRegression:
assert_(pickle.loads(
pickle.dumps(test_record, protocol=proto)) == test_record)
- @no_tracing
+ @_no_tracing
def test_blasdot_uninitialized_memory(self):
# Ticket #950
for m in [0, 1, 2]:
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py
index 914491b71..69b2af4df 100644
--- a/numpy/testing/_private/utils.py
+++ b/numpy/testing/_private/utils.py
@@ -2474,3 +2474,24 @@ def _get_mem_available():
return info['memfree'] + info['cached']
return None
+
+
+def _no_tracing(func):
+ """
+ Decorator to temporarily turn off tracing for the duration of a test.
+ Needed in tests that check refcounting, otherwise the tracing itself
+ influences the refcounts
+ """
+ if not hasattr(sys, 'gettrace'):
+ return func
+ else:
+ @wraps(func)
+ def wrapper(*args, **kwargs):
+ original_trace = sys.gettrace()
+ try:
+ sys.settrace(None)
+ return func(*args, **kwargs)
+ finally:
+ sys.settrace(original_trace)
+ return wrapper
+