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.
This commit is contained in:
stijn
2020-12-15 11:54:34 +01:00
committed by Damien George
parent 505a1853b9
commit 108183fcc0
7 changed files with 195 additions and 195 deletions

View File

@@ -17,8 +17,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,
)
)