diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2020-01-14 19:52:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-14 19:52:54 -0700 |
commit | 2199ba7fb7f8bb383552fdcd6feec4faee7ae394 (patch) | |
tree | 98fc87c31da28c14b0c34546b0dd6560ce522d99 /numpy/testing/_private/utils.py | |
parent | b03e4dc36b1b4441fbc955920e0fe92fd39f095e (diff) | |
parent | 16e9d42c120a66fefaacb45684a3ff52944a4b38 (diff) | |
download | numpy-2199ba7fb7f8bb383552fdcd6feec4faee7ae394.tar.gz |
Merge pull request #15329 from mattip/issue-15202a
TST: move _no_tracing to testing._private, remove testing.support
Diffstat (limited to 'numpy/testing/_private/utils.py')
-rw-r--r-- | numpy/testing/_private/utils.py | 21 |
1 files changed, 21 insertions, 0 deletions
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 + |