]> granicus.if.org Git - python/commitdiff
correct example
authorSkip Montanaro <skip@pobox.com>
Sun, 23 Apr 2006 19:32:14 +0000 (19:32 +0000)
committerSkip Montanaro <skip@pobox.com>
Sun, 23 Apr 2006 19:32:14 +0000 (19:32 +0000)
Lib/trace.py

index 799c30280840bf527e9992360bcb02f1b6e415e4..16f4b04e7460a8d92be5b79dbe71982df7d7a5e8 100644 (file)
@@ -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