summaryrefslogtreecommitdiff
path: root/lab
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2020-12-31 18:34:37 -0500
committerNed Batchelder <ned@nedbatchelder.com>2021-01-10 09:46:18 -0500
commitc7649842853de89c9a67c3f361f967349b17cb5f (patch)
tree52100e693b2ebf8cb84d04af4e20284db07e0c3c /lab
parentbd90b202587dd9f1e2e1319c1c542545c7263dd3 (diff)
downloadpython-coveragepy-git-c7649842853de89c9a67c3f361f967349b17cb5f.tar.gz
A simple tool to see branch tracing arcs
Diffstat (limited to 'lab')
-rw-r--r--lab/branch_trace.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/lab/branch_trace.py b/lab/branch_trace.py
new file mode 100644
index 00000000..7e8e88f9
--- /dev/null
+++ b/lab/branch_trace.py
@@ -0,0 +1,17 @@
+import sys
+
+pairs = set()
+last = -1
+
+def trace(frame, event, arg):
+ global last
+ if event == "line":
+ this = frame.f_lineno
+ pairs.add((last, this))
+ last = this
+ return trace
+
+code = open(sys.argv[1]).read()
+sys.settrace(trace)
+exec(code)
+print(sorted(pairs))