summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coverage/collector.py2
-rw-r--r--coverage/control.py8
-rw-r--r--test/test_coverage.py19
3 files changed, 21 insertions, 8 deletions
diff --git a/coverage/collector.py b/coverage/collector.py
index 0a5349ad..940f7c75 100644
--- a/coverage/collector.py
+++ b/coverage/collector.py
@@ -20,6 +20,7 @@ except ImportError:
def _global_trace(self, frame, event, arg_unused):
"""The trace function passed to sys.settrace."""
+ #print "global event: %s %r" % (event, frame.f_code.co_filename)
if event == 'call':
# Entering a new function context. Decide if we should trace
# in this file.
@@ -42,6 +43,7 @@ except ImportError:
def _local_trace(self, frame, event, arg_unused):
"""The trace function used within a function."""
+ #print "local event: %s %r" % (event, frame.f_code.co_filename)
if self.last_exc_back:
if frame == self.last_exc_back:
# Someone forgot a return event.
diff --git a/coverage/control.py b/coverage/control.py
index b0e7512e..0d19a56c 100644
--- a/coverage/control.py
+++ b/coverage/control.py
@@ -119,6 +119,14 @@ class coverage:
return canonical
+ # To log what should_trace returns, change this to "if 1:"
+ if 0:
+ _real_should_trace = _should_trace
+ def _should_trace(self, filename, frame):
+ ret = self._real_should_trace(filename, frame)
+ print "should_trace: %r -> %r" % (filename, ret)
+ return ret
+
def use_cache(self, usecache):
"""Control the use of a data file (incorrectly called a cache).
diff --git a/test/test_coverage.py b/test/test_coverage.py
index 7ff5b4c0..e548ab4c 100644
--- a/test/test_coverage.py
+++ b/test/test_coverage.py
@@ -1841,23 +1841,23 @@ class ExceptionTest(CoverageTest):
# Each run nests the functions differently to get different combinations
# of catching exceptions and letting them fly.
runs = [
- ("fly oops", {
+ ("doit fly oops", {
'doit.py': [302,303,304,305],
'fly.py': [102,103],
'oops.py': [2,3],
}),
- ("catch oops", {
+ ("doit catch oops", {
'doit.py': [302,303],
'catch.py': [202,203,204,206,207],
'oops.py': [2,3],
}),
- ("fly catch oops", {
+ ("doit fly catch oops", {
'doit.py': [302,303],
'fly.py': [102,103,104],
'catch.py': [202,203,204,206,207],
'oops.py': [2,3],
}),
- ("catch fly oops", {
+ ("doit catch fly oops", {
'doit.py': [302,303],
'catch.py': [202,203,204,206,207],
'fly.py': [102,103],
@@ -1866,12 +1866,15 @@ class ExceptionTest(CoverageTest):
]
for callnames, lines_expected in runs:
- cov = coverage.coverage()
- # Import the python file, executing it.
- cov.start()
+ # Make the list of functions we'll call for this test.
calls = [getattr(sys.modules[cn], cn) for cn in callnames.split()]
- getattr(sys.modules['doit'], 'doit')(calls)
+
+ cov = coverage.coverage()
+ cov.start()
+ # Call our list of functions: invoke the first, with the rest as
+ # an argument.
+ calls[0](calls[1:])
cov.stop()
# Clean the line data and compare to expected results.