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
commit894bc33e4fd8aa9bc798ee1a968a6a06da5d5d48 (patch)
tree63e00ca93cfd03aa2c523635f5f1c486b23ecf69 /coverage/collector.py
parent28711a2a525a2f46b8e1733d2d1a1ffaf9a4df15 (diff)
downloadpython-coveragepy-894bc33e4fd8aa9bc798ee1a968a6a06da5d5d48.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 3b56d24..8e304c1 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)