diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2016-09-24 18:39:17 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2016-09-24 18:39:17 -0400 |
commit | 798c38e9f6d6598dc59ea6f5d71fce96cdeb7ae7 (patch) | |
tree | b360c9f30acb6469dcc0882fb52e06920604925e /coverage/debug.py | |
parent | 894b7a67537eac5e8fb5171d80503a3e6b537f69 (diff) | |
download | python-coveragepy-git-798c38e9f6d6598dc59ea6f5d71fce96cdeb7ae7.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.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/coverage/debug.py b/coverage/debug.py index 4cf0f3e5..3d67c611 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) |