diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2012-07-07 09:53:36 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2012-07-07 09:53:36 -0400 |
commit | 07b188473f945262949a5ce0cf3ee7b1e943a6ee (patch) | |
tree | 3884e761d0585ff13cb2260738322940a60d0fc9 | |
parent | 31dd92b34e3d09b2110e1592d2931d7572b07191 (diff) | |
download | python-coveragepy-git-07b188473f945262949a5ce0cf3ee7b1e943a6ee.tar.gz |
If the C tracer is missing during testing, make the problem immediately apparent.
-rw-r--r-- | AUTHORS.txt | 1 | ||||
-rw-r--r-- | coverage/collector.py | 13 | ||||
-rw-r--r-- | test/test_oddball.py | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/AUTHORS.txt b/AUTHORS.txt index edb6be94..ef8ef276 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -3,6 +3,7 @@ extended and maintained by Ned Batchelder. Other contributions have been made by: +Marc Abramowitz Chris Adams Geoff Bache Titus Brown diff --git a/coverage/collector.py b/coverage/collector.py index 3fdedaad..73a14b93 100644 --- a/coverage/collector.py +++ b/coverage/collector.py @@ -1,12 +1,23 @@ """Raw data collector for Coverage.""" -import sys, threading +import os, sys, threading try: # Use the C extension code when we can, for speed. from coverage.tracer import CTracer except ImportError: # Couldn't import the C extension, maybe it isn't built. + if os.getenv('COVERAGE_TEST_TRACER') == 'c': + # During testing, we use the COVERAGE_TEST_TRACER env var to indicate + # that we've fiddled with the environment to test this fallback code. + # If we thought we had a C tracer, but couldn't import it, then exit + # quickly and clearly instead of dribbling confusing errors. I'm using + # sys.exit here instead of an exception because an exception here + # causes all sorts of other noise in unittest. + sys.stderr.write( + "*** COVERAGE_TEST_TRACER is 'c' but can't import CTracer!\n" + ) + sys.exit(1) CTracer = None diff --git a/test/test_oddball.py b/test/test_oddball.py index 724ae863..1a3bd22f 100644 --- a/test/test_oddball.py +++ b/test/test_oddball.py @@ -131,7 +131,7 @@ class RecursionTest(CoverageTest): class MemoryLeakTest(CoverageTest): """Attempt the impossible: test that memory doesn't leak. - Note: this test is truly unusual, and may fail unexpectedly. + Note: this test is truly unusual, and may fail unexpectedly. In particular, it is known to fail on PyPy if test_oddball.py is run in isolation: https://bitbucket.org/ned/coveragepy/issue/186 |