summaryrefslogtreecommitdiffstats
path: root/Lib/test/support.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2011-02-22 03:04:06 (GMT)
committerBrett Cannon <bcannon@gmail.com>2011-02-22 03:04:06 (GMT)
commit7a54073a566080f3d7c10871f6ce244c9fc1221b (patch)
treec477930f8c868d6bdf9b8e65e7293bc2fdfe21ae /Lib/test/support.py
parenteb70e47d85d52e0bafc6b6350b9b627e0b577e96 (diff)
downloadcpython-7a54073a566080f3d7c10871f6ce244c9fc1221b.zip
cpython-7a54073a566080f3d7c10871f6ce244c9fc1221b.tar.gz
cpython-7a54073a566080f3d7c10871f6ce244c9fc1221b.tar.bz2
Issue #10992: make tests pass when run under coverage.
Various tests fail when run under coverage. A primary culprit is refcount tests which fail as the counts are thrown off by the coverage code. A new decorator -- test.support.refcount_test -- is used to decorate tests which test refcounts and to skip them when running under coverage. Other tests simply fail because of changes in the system (e.g., __local__ suddenly appearing). Thanks to Kristian Vlaardingerbroek for helping to diagnose the test failures.
Diffstat (limited to 'Lib/test/support.py')
-rw-r--r--Lib/test/support.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py
index f037a7a..9300aae 100644
--- a/Lib/test/support.py
+++ b/Lib/test/support.py
@@ -1124,6 +1124,17 @@ def no_tracing(func):
return wrapper
+def refcount_test(test):
+ """Decorator for tests which involve reference counting.
+
+ To start, the decorator does not run the test if is not run by CPython.
+ After that, any trace function is unset during the test to prevent
+ unexpected refcounts caused by the trace function.
+
+ """
+ return no_tracing(cpython_only(test))
+
+
def _run_suite(suite):
"""Run tests from a unittest.TestSuite-derived class."""
if verbose: