Module trace
program/module to trace Python program or function execution
Sample use, command line:
trace.py -c -f counts --ignore-dir '$prefix' spam.py eggs
trace.py -t --ignore-dir '$prefix' spam.py eggs
trace.py --trackcalls spam.py eggs
Sample use, programmatically
import sys
# create a Trace object, telling it what to ignore, and whether to
# do tracing or line-counting or both.
tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], trace=0,
count=1)
# run the new command using the given tracer
tracer.run('main()')
# make a report, placing output in /tmp
r = tracer.results()
r.write_results(show_missing=True, coverdir="/tmp")
|
|
|
modname(path)
Return a plausible module name for the patch. |
|
|
|
fullmodname(path)
Return a plausible module name for the path. |
|
|
|
find_lines_from_code(code,
strs)
Return dict where keys are lines in the line number table. |
|
|
|
find_lines(code,
strs)
Return lineno dict for all code objects reachable from code. |
|
|
|
find_strings(filename)
Return a dict of possible docstring positions. |
|
|
|
find_executable_linenos(filename)
Return dict where keys are line numbers in the line number table. |
|
|
|
|
|
|
|
PRAGMA_NOCOVER = ' #pragma NO COVER '
|
|
rx_blank = re.compile(r'^\s* ( #.* ) ? $')
|
Imports:
linecache,
os,
re,
sys,
threading,
token,
tokenize,
types,
gc,
cPickle,
pickle
Return a dict of possible docstring positions.
The dict maps line numbers to strings. There is an entry for line
that contains only a string or a part of a triple-quoted string.
|