From 86b9a0b876f70ad48e724977ef31944294eea220 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 12 Jun 2025 11:03:21 +0200 Subject: [PATCH] test_driver: use isinstance chain to replace Python 3.10's match statement We still want to support Python 3.9 (debian-oldstable); it's still used by our (outdated) FreeBSD CI, and, more importantly by (nightly) builders on OBS. Ref: https://github.com/fish-shell/fish-shell/pull/11560#discussion_r2134556573 --- tests/test_driver.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tests/test_driver.py b/tests/test_driver.py index b59696771..3de5d473a 100755 --- a/tests/test_driver.py +++ b/tests/test_driver.py @@ -174,17 +174,22 @@ async def main(): for f, arg in files ] for task in asyncio.as_completed(tasks): - match await task: - case TestSkip(arg): - skipcount += 1 - print_result(arg, "SKIPPED", BLUE) - case TestFail(arg, duration_ms, error_message): - failcount += 1 - failed += [arg] - print_result(arg, "FAILED", RED, duration_ms, error_message) - case TestPass(arg, duration_ms): - passcount += 1 - print_result(arg, "PASSED", GREEN, duration_ms) + result = await task + if isinstance(result, TestSkip): + arg = result.arg + skipcount += 1 + print_result(arg, "SKIPPED", BLUE) + elif isinstance(result, TestFail): + # fmt: off + arg, duration_ms, error_message = result.arg, result.duration_ms, result.error_message + # fmt: on + failcount += 1 + failed += [arg] + print_result(arg, "FAILED", RED, duration_ms, error_message) + elif isinstance(result, TestPass): + arg, duration_ms = result.arg, result.duration_ms + passcount += 1 + print_result(arg, "PASSED", GREEN, duration_ms) if passcount + failcount + skipcount > 1: print(f"{passcount} / {passcount + failcount} passed ({skipcount} skipped)")