summaryrefslogtreecommitdiffstats
path: root/Lib/trace.py
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2006-04-23 19:32:14 (GMT)
committerSkip Montanaro <skip@pobox.com>2006-04-23 19:32:14 (GMT)
commit7b1559ac2633ec858abdf6fb8b4cfa45b08cbc88 (patch)
tree1936d59b2ff6526192cf97ed191da920f08eb983 /Lib/trace.py
parent9ab2f453acc0da853c2623e0abb468f66c56a321 (diff)
downloadcpython-7b1559ac2633ec858abdf6fb8b4cfa45b08cbc88.zip
cpython-7b1559ac2633ec858abdf6fb8b4cfa45b08cbc88.tar.gz
cpython-7b1559ac2633ec858abdf6fb8b4cfa45b08cbc88.tar.bz2
correct example
Diffstat (limited to 'Lib/trace.py')
-rw-r--r--Lib/trace.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/Lib/trace.py b/Lib/trace.py
index 799c302..16f4b04 100644
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -35,15 +35,17 @@ Sample use, command line:
trace.py --trackcalls spam.py eggs
Sample use, programmatically
- # create a Trace object, telling it what to ignore, and whether to
- # do tracing or line-counting or both.
- trace = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], trace=0,
- count=1)
- # run the new command using the given trace
- trace.run('main()')
- # make a report, telling it where you want output
- r = trace.results()
- r.write_results(show_missing=True)
+ 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")
"""
import linecache