summaryrefslogtreecommitdiff
path: root/coverage/pytracer.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2015-02-09 09:41:28 -0500
committerNed Batchelder <ned@nedbatchelder.com>2015-02-09 09:41:28 -0500
commit674fbf7bfd2c60835cdc2213f2d901b97b304a8d (patch)
treeea331bc33c99f5dda81ee8b5eaf27f8efa204bd5 /coverage/pytracer.py
parente6293b0f0d8a029489a5571f39f975021c2249e8 (diff)
downloadpython-coveragepy-674fbf7bfd2c60835cdc2213f2d901b97b304a8d.tar.gz
Plugin support is now only in the CTracer, not in the PyTracer.
Diffstat (limited to 'coverage/pytracer.py')
-rw-r--r--coverage/pytracer.py48
1 files changed, 8 insertions, 40 deletions
diff --git a/coverage/pytracer.py b/coverage/pytracer.py
index 16a51c2..7029c25 100644
--- a/coverage/pytracer.py
+++ b/coverage/pytracer.py
@@ -28,13 +28,10 @@ class PyTracer(object):
self.arcs = False
self.should_trace = None
self.should_trace_cache = None
- self.check_include = None
self.warn = None
- self.plugin_data = None
# The threading module to use, if any.
self.threading = None
- self.file_tracer = []
self.cur_file_dict = []
self.last_line = [0]
@@ -63,72 +60,43 @@ class PyTracer(object):
if self.arcs and self.cur_file_dict:
pair = (self.last_line, -self.last_exc_firstlineno)
self.cur_file_dict[pair] = None
- self.file_tracer, self.cur_file_dict, self.last_line = (
- self.data_stack.pop()
- )
+ self.cur_file_dict, self.last_line = self.data_stack.pop()
self.last_exc_back = None
if event == 'call':
# Entering a new function context. Decide if we should trace
# in this file.
- self.data_stack.append(
- (self.file_tracer, self.cur_file_dict, self.last_line)
- )
+ self.data_stack.append((self.cur_file_dict, self.last_line))
filename = frame.f_code.co_filename
disp = self.should_trace_cache.get(filename)
if disp is None:
disp = self.should_trace(filename, frame)
self.should_trace_cache[filename] = disp
- self.file_tracer = None
self.cur_file_dict = None
if disp.trace:
tracename = disp.source_filename
- if disp.file_tracer and disp.has_dynamic_filename:
- tracename = disp.file_tracer.dynamic_source_filename(tracename, frame)
- if tracename:
- included = self.should_trace_cache.get(tracename)
- if included is None:
- included = self.check_include(tracename, frame)
- self.should_trace_cache[tracename] = included
- if not included:
- tracename = None
- else:
- tracename = None
- if tracename:
if tracename not in self.data:
self.data[tracename] = {}
- if disp.file_tracer:
- self.plugin_data[tracename] = disp.file_tracer.plugin_name
self.cur_file_dict = self.data[tracename]
- self.file_tracer = disp.file_tracer
# Set the last_line to -1 because the next arc will be entering a
# code block, indicated by (-1, n).
self.last_line = -1
elif event == 'line':
# Record an executed line.
if self.cur_file_dict is not None:
- if self.file_tracer:
- lineno_from, lineno_to = self.file_tracer.line_number_range(frame)
+ lineno = frame.f_lineno
+ if self.arcs:
+ self.cur_file_dict[(self.last_line, lineno)] = None
else:
- lineno_from, lineno_to = frame.f_lineno, frame.f_lineno
- if lineno_from != -1:
- if self.arcs:
- self.cur_file_dict[
- (self.last_line, lineno_from)
- ] = None
- else:
- for lineno in range(lineno_from, lineno_to+1):
- self.cur_file_dict[lineno] = None
- self.last_line = lineno_to
+ self.cur_file_dict[lineno] = None
+ self.last_line = lineno
elif event == 'return':
if self.arcs and self.cur_file_dict:
first = frame.f_code.co_firstlineno
self.cur_file_dict[(self.last_line, -first)] = None
# Leaving this function, pop the filename stack.
- self.file_tracer, self.cur_file_dict, self.last_line = (
- self.data_stack.pop()
- )
+ self.cur_file_dict, self.last_line = self.data_stack.pop()
elif event == 'exception':
self.last_exc_back = frame.f_back
self.last_exc_firstlineno = frame.f_code.co_firstlineno