From 728a2fb1625ae8721edc13e3f51d7f442aa182b4 Mon Sep 17 00:00:00 2001 From: Jarry Shaw Date: Tue, 13 Oct 2026 21:48:22 -0400 Subject: [PATCH] test: spell test_base_class_contract's suffix strip so Python 3.8 runs it (#1699) BaseClassAliasTests.test_library_modules_do_not_bind_the_public_name_at_runtime stripped `.py` from each PENDING_ALIAS_PATHS key with `str.removesuffix`, which is Python 3.9+. The dict is empty today, so the line never ran; its first entry would have raised AttributeError on the 3.8 leg. It now reads `rel[:-len('.py')] if rel.endswith('.py') else rel`, the same result. With one entry patched in, the test errors on 3.8 before and passes after; the module is 7 passed, unchanged, on 3.8, 3.9 and 3.14. --- tests/test_base_class_contract.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_base_class_contract.py b/tests/test_base_class_contract.py index c644ae9d06..aaa978c336 100644 --- a/tests/test_base_class_contract.py +++ b/tests/test_base_class_contract.py @@ -246,7 +246,9 @@ class itself*, so identity is what is asserted, not absence: the name may exist, it just may not be the base. """ - pending = tuple(rel.removesuffix('.py').replace('/', '.') + # Not ``str.removesuffix``: that is Python 3.9+, and the 3.8 leg runs + # this line as soon as the dict gains an entry. C.f. #1699. + pending = tuple((rel[:-len('.py')] if rel.endswith('.py') else rel).replace('/', '.') for rel in PENDING_ALIAS_PATHS) offenders = []