mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
correct example
This commit is contained in:
parent
9ab2f453ac
commit
7b1559ac26
1 changed files with 11 additions and 9 deletions
20
Lib/trace.py
20
Lib/trace.py
|
@ -35,15 +35,17 @@ Sample use, command line:
|
||||||
trace.py --trackcalls spam.py eggs
|
trace.py --trackcalls spam.py eggs
|
||||||
|
|
||||||
Sample use, programmatically
|
Sample use, programmatically
|
||||||
# create a Trace object, telling it what to ignore, and whether to
|
import sys
|
||||||
# do tracing or line-counting or both.
|
|
||||||
trace = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], trace=0,
|
# create a Trace object, telling it what to ignore, and whether to
|
||||||
count=1)
|
# do tracing or line-counting or both.
|
||||||
# run the new command using the given trace
|
tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], trace=0,
|
||||||
trace.run('main()')
|
count=1)
|
||||||
# make a report, telling it where you want output
|
# run the new command using the given tracer
|
||||||
r = trace.results()
|
tracer.run('main()')
|
||||||
r.write_results(show_missing=True)
|
# make a report, placing output in /tmp
|
||||||
|
r = tracer.results()
|
||||||
|
r.write_results(show_missing=True, coverdir="/tmp")
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import linecache
|
import linecache
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue