mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 09:39:52 +08:00
Better support for helper functions in pexpect
When a pexpect test fails, it reports the "failing line." Prior to this commit, it did so by walking up the Python call stack, looking for the first frame which is not in the pexpect_helper module, and so presumably in the test itself. However sometimes the test wants to define a helper function; then if the test fails the helper function is reported as the failing line, not the callsite of the helper. Fix this by skipping functions which have the `callsite_skip` attribute set. Nothing to relnote here.
This commit is contained in:
parent
cb027bfdc0
commit
cfbebb7201
|
@ -48,7 +48,12 @@ def get_callsite():
|
|||
"""Return a triple (filename, line_number, line_text) of the call site location."""
|
||||
callstack = inspect.getouterframes(inspect.currentframe())
|
||||
for f in callstack:
|
||||
if inspect.getmodule(f.frame) is not Message.MODULE:
|
||||
# Skip call sites from this file.
|
||||
if inspect.getmodule(f.frame) is Message.MODULE:
|
||||
continue
|
||||
# Skip functions which have a truthy callsite_skip attribute.
|
||||
if getattr(f.function, "callsite_skip", False):
|
||||
continue
|
||||
return (os.path.basename(f.filename), f.lineno, f.code_context)
|
||||
return ("Unknown", -1, "")
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user