diff options
Diffstat (limited to 'coverage')
-rw-r--r-- | coverage/control.py | 8 | ||||
-rw-r--r-- | coverage/debug.py | 23 | ||||
-rw-r--r-- | coverage/misc.py | 6 |
3 files changed, 28 insertions, 9 deletions
diff --git a/coverage/control.py b/coverage/control.py index 1dbf0672..91365e11 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -449,10 +449,12 @@ class Coverage(object): if dunder_file: filename = self._source_for_file(dunder_file) if original_filename and not original_filename.startswith('<'): - if os.path.basename(original_filename) != os.path.basename(filename): + orig = os.path.basename(original_filename) + if orig != os.path.basename(filename): # Files shouldn't be renamed when moved. This happens when - # exec'ing code, not sure why yet. - self._warn("File was renamed?: %r became %r" % (original_filename, filename)) + # exec'ing code. If it seems like something is wrong with + # the frame's filename, then just use the original. + filename = original_filename if not filename: # Empty string is pretty useless. diff --git a/coverage/debug.py b/coverage/debug.py index 5b41bc40..fbffc569 100644 --- a/coverage/debug.py +++ b/coverage/debug.py @@ -1,5 +1,6 @@ """Control of and utilities for debugging.""" +import inspect import os @@ -66,3 +67,25 @@ def info_formatter(info): prefix = "" else: yield "%*s: %s" % (label_len, label, data) + + +def short_stack(): # pragma: debugging + """Return a string summarizing the call stack. + + The string is multi-line, with one line per stack frame. Each line shows + the function name, the file name, and the line number: + + ... + start_import_stop : /Users/ned/coverage/trunk/tests/coveragetest.py @95 + import_local_file : /Users/ned/coverage/trunk/tests/coveragetest.py @81 + import_local_file : /Users/ned/coverage/trunk/coverage/backward.py @159 + ... + + """ + stack = inspect.stack()[:0:-1] + return "\n".join("%30s : %s @%d" % (t[3], t[1], t[2]) for t in stack) + + +def dump_stack_frames(): # pragma: debugging + """Print a summary of the stack to stdout.""" + print(short_stack()) diff --git a/coverage/misc.py b/coverage/misc.py index 21b7333c..b99fbb81 100644 --- a/coverage/misc.py +++ b/coverage/misc.py @@ -75,12 +75,6 @@ def format_lines(statements, lines): return ret -def short_stack(): # pragma: debugging - """Return a string summarizing the call stack.""" - stack = inspect.stack()[:0:-1] - return "\n".join("%30s : %s @%d" % (t[3], t[1], t[2]) for t in stack) - - def expensive(fn): """A decorator to cache the result of an expensive operation. |