summaryrefslogtreecommitdiff
path: root/coverage/debug.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-09-24 18:39:17 -0400
committerNed Batchelder <ned@nedbatchelder.com>2016-09-24 18:39:17 -0400
commit72c2df9297550e92dd85493dcfada7020340ff6c (patch)
tree1fc525dd1d6c488979a0e8cb7fa7c5c5a2225265 /coverage/debug.py
parentb7165a97a82eba631c70486a1e0e8910c631593f (diff)
downloadpython-coveragepy-72c2df9297550e92dd85493dcfada7020340ff6c.tar.gz
Test short_stack, and give it a skip parameter for better output.
Diffstat (limited to 'coverage/debug.py')
-rw-r--r--coverage/debug.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/coverage/debug.py b/coverage/debug.py
index 4cf0f3e..3d67c61 100644
--- a/coverage/debug.py
+++ b/coverage/debug.py
@@ -87,7 +87,7 @@ def info_formatter(info):
yield "%*s: %s" % (label_len, label, data)
-def short_stack(limit=None): # pragma: debugging
+def short_stack(limit=None, skip=0):
"""Return a string summarizing the call stack.
The string is multi-line, with one line per stack frame. Each line shows
@@ -101,8 +101,11 @@ def short_stack(limit=None): # pragma: debugging
`limit` is the number of frames to include, defaulting to all of them.
+ `skip` is the number of frames to skip, so that debugging functions can
+ call this and not be included in the result.
+
"""
- stack = inspect.stack()[limit:0:-1]
+ stack = inspect.stack()[limit:skip:-1]
return "\n".join("%30s : %s @%d" % (t[3], t[1], t[2]) for t in stack)