diff options
author | stijn <stijn@ignitron.net> | 2020-12-15 11:54:34 +0100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-12-18 13:56:45 +1100 |
commit | 108183fcc01f722d17e373f91f392a2a60ac787a (patch) | |
tree | 33110db9ce8892bd3403de2a3dd4b7b61a1e789a /tests/misc/sys_settrace_features.py | |
parent | 505a1853b9490246fbb95850ad8dae6d1b49d002 (diff) |
tests/misc/sys_settrace: Make test output independent of invoked path.
The original logic of reducing a full path to a relative one assumes
"tests/misc" is in the filename which is limited in usage: it never works
for CPython on Windows since that will use a backslash as path separator,
and also won't work when the filename is a path not relative to the tests
directory which happens for example in the common case of running
"./run-tests -d misc".
Fix all cases by printing only the bare filename, which requires them all
to start with sys_settrace_ hence the renaming.
Diffstat (limited to 'tests/misc/sys_settrace_features.py')
-rw-r--r-- | tests/misc/sys_settrace_features.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/misc/sys_settrace_features.py b/tests/misc/sys_settrace_features.py index d315ea697..e1b1a059d 100644 --- a/tests/misc/sys_settrace_features.py +++ b/tests/misc/sys_settrace_features.py @@ -20,8 +20,8 @@ def print_stacktrace(frame, level=0): " ", frame.f_globals["__name__"], frame.f_code.co_name, - # reduce full path to some pseudo-relative - "misc" + "".join(frame.f_code.co_filename.split("tests/misc")[-1:]), + # Keep just the filename. + "sys_settrace_" + frame.f_code.co_filename.split("sys_settrace_")[-1], frame.f_lineno, ) ) @@ -95,9 +95,9 @@ def do_tests(): print("Who loves the sun?") print("Not every-", factorial(3)) - from sys_settrace_subdir import trace_generic + from sys_settrace_subdir import sys_settrace_generic - trace_generic.run_tests() + sys_settrace_generic.run_tests() return |