summaryrefslogtreecommitdiff
path: root/coverage/collector.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2009-10-07 05:31:03 -0400
committerNed Batchelder <ned@nedbatchelder.com>2009-10-07 05:31:03 -0400
commita7072c02bd2f9f4f5de97be0e85db32265756109 (patch)
tree1229b0de791af41013f66babd0b8ec42d2c463fe /coverage/collector.py
parenta3f706683ec93cb8082f4495c6cdaae207950799 (diff)
downloadpython-coveragepy-git-a7072c02bd2f9f4f5de97be0e85db32265756109.tar.gz
Basic plumbing for a --branch option.
Diffstat (limited to 'coverage/collector.py')
-rw-r--r--coverage/collector.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/coverage/collector.py b/coverage/collector.py
index 3b56d241..8e304c1f 100644
--- a/coverage/collector.py
+++ b/coverage/collector.py
@@ -35,6 +35,7 @@ class PyTracer:
self.cur_filename = None
self.filename_stack = []
self.last_exc_back = None
+ self.branch = False
def _trace(self, frame, event, arg_unused):
"""The trace function passed to sys.settrace."""
@@ -68,6 +69,7 @@ class PyTracer:
def start(self):
"""Start this Tracer."""
+ assert not self.branch
sys.settrace(self._trace)
def stop(self):
@@ -95,7 +97,7 @@ class Collector:
# the top, and resumed when they become the top again.
_collectors = []
- def __init__(self, should_trace, timid=False):
+ def __init__(self, should_trace, timid=False, branch=False):
"""Create a collector.
`should_trace` is a function, taking a filename, and returning a
@@ -107,10 +109,13 @@ class Collector:
tracing functions make the faster more sophisticated trace function not
operate properly.
+ TODO: `branch`
+
"""
self.should_trace = should_trace
+ self.branch = branch
self.reset()
- if timid:
+ if timid or branch:
# Being timid: use the simple Python trace function.
self._trace_class = PyTracer
else:
@@ -142,6 +147,7 @@ class Collector:
tracer.data = self.data
tracer.should_trace = self.should_trace
tracer.should_trace_cache = self.should_trace_cache
+ tracer.branch = self.branch
tracer.start()
self.tracers.append(tracer)