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 <andrew.leech@planetinnovation.com.au>
This commit is contained in:
Andrew Leech 2025-06-18 07:21:36 +10:00 committed by Damien George
parent c16a4db151
commit 5e965618be

View file

@ -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()