mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 20:50:14 +01:00
tests: Format all Python code with black, except tests in basics subdir.
This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
This commit is contained in:
committed by
Damien George
parent
488613bca6
commit
3dc324d3f1
@@ -8,21 +8,28 @@ except AttributeError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
|
||||
def print_stacktrace(frame, level=0):
|
||||
print("%2d: %s@%s:%s => %s:%d" % (
|
||||
level, " ",
|
||||
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:]),
|
||||
frame.f_lineno,
|
||||
))
|
||||
print(
|
||||
"%2d: %s@%s:%s => %s:%d"
|
||||
% (
|
||||
level,
|
||||
" ",
|
||||
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:]),
|
||||
frame.f_lineno,
|
||||
)
|
||||
)
|
||||
|
||||
if frame.f_back:
|
||||
print_stacktrace(frame.f_back, level + 1)
|
||||
|
||||
|
||||
trace_count = 0
|
||||
|
||||
|
||||
def trace_tick_handler(frame, event, arg):
|
||||
global trace_count
|
||||
print("### trace_handler::main event:", event)
|
||||
@@ -30,6 +37,7 @@ def trace_tick_handler(frame, event, arg):
|
||||
print_stacktrace(frame)
|
||||
return trace_tick_handler
|
||||
|
||||
|
||||
def test_loop():
|
||||
# for loop
|
||||
r = 0
|
||||
@@ -45,6 +53,7 @@ def test_loop():
|
||||
i += 1
|
||||
print("test_while_loop", i)
|
||||
|
||||
|
||||
sys.settrace(trace_tick_handler)
|
||||
test_loop()
|
||||
sys.settrace(None)
|
||||
|
||||
Reference in New Issue
Block a user