From 5e965618beb24927091a897e9cc81241d22d89ad Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Wed, 18 Jun 2025 07:21:36 +1000 Subject: [PATCH] tests/run-tests.py: Add support for ctrl keys in REPL tests. This allows having {\xDD} in tests, which will be expanded to the given hex character. Signed-off-by: Andrew Leech --- tests/run-tests.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/run-tests.py b/tests/run-tests.py index 5eebc7246..628fde9d3 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -405,6 +405,10 @@ def run_micropython(pyb, args, test_file, test_file_abspath, is_special=False): return rv def send_get(what): + # Detect {\x00} pattern and convert to ctrl-key codes. + ctrl_code = lambda m: bytes([int(m.group(1))]) + what = re.sub(rb'{\\x(\d\d)}', ctrl_code, what) + os.write(master, what) return get()