From e8e689f30335222821ce78761f34a8d2ceaaa056 Mon Sep 17 00:00:00 2001 From: devdanzin <74280297+devdanzin@users.noreply.github.com> Date: Wed, 2 Sep 2026 15:04:37 -0300 Subject: [PATCH] fix two tests that have failed CI on every run since 2026-08-19 CI has been red on main for five consecutive merges (#261 through #266). Both failures are tests asserting a property of the INTERPRETER BUILD rather than of fusil, so both pass on the local interpreters and fail on the python.org builds setup-python installs. A permanently red CI catches nothing, which is exactly how a real regression gets in. test_builtins_still_discoverable_under_only_c asserted `math` is discovered under --only-c. Whether math is a builtin or a shared extension is a build choice: it is compiled in on both local interpreters and is an extension on CI, so the test was naming a module CI does not have. The invariant it actually guards -- a builtin has no filename, so the file-based only-c check must not drop it -- is now asserted over sys.builtin_module_names, whatever this interpreter happens to contain. test_tricky_objects_runs_without_types_CapsuleType builds a shim `types` module with every attribute except CapsuleType, to prove the prelude survives a target that lacks it. It copied `__getattr__` along with everything else -- and CPython 3.13 defines CapsuleType LAZILY through a module-level __getattr__ (PEP 562), so the copy resolved the attribute straight back to the real module and the shim stopped shimming. 3.14 defines it eagerly via _types, which is why it passed here and failed only on CI's 3.13 job. Skipping __getattr__ fixes it; verified against a simulated 3.13-style lazy `types`, since no 3.13 is installed locally. Neither fix touches fusil itself. --- tests/python/test_list_all_modules.py | 8 +++++++- tests/python/test_target_py311_compat.py | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/python/test_list_all_modules.py b/tests/python/test_list_all_modules.py index 2cbdb5e..ab78d56 100644 --- a/tests/python/test_list_all_modules.py +++ b/tests/python/test_list_all_modules.py @@ -267,7 +267,13 @@ def test_builtins_still_discoverable_under_only_c(self): # Regression guard: a builtin IS a C module (compiled into the interpreter) but has no # filename, so routing the seed through the file-based only-c check would drop every # builtin from --only-c runs. - self.assertIn("math", self._discovered(set(), only_c=True)) + # + # Which modules are built in is a property of the BUILD, not of fusil: `math` is + # compiled into the interpreters used here but is a shared extension on the + # python.org builds CI installs, where naming it made this fail on every run since + # 2026-08-19. Assert the invariant over whatever this interpreter actually has. + expected = set(sys.builtin_module_names) - {"__main__"} + self.assertEqual(self._discovered(set(), only_c=True) & expected, expected) def test_dunder_main_still_excluded(self): self.assertNotIn("__main__", self._discovered(set())) diff --git a/tests/python/test_target_py311_compat.py b/tests/python/test_target_py311_compat.py index 25a319d..00d98ea 100644 --- a/tests/python/test_target_py311_compat.py +++ b/tests/python/test_target_py311_compat.py @@ -38,9 +38,14 @@ def test_tricky_objects_runs_without_types_CapsuleType(self): # killing the session during the prelude -- before a single call is fuzzed. source = (SAMPLES / "tricky_objects.py").read_text() + # `__getattr__` must be skipped as well, not just CapsuleType. CPython 3.13 defines + # CapsuleType LAZILY through a module-level __getattr__ (PEP 562); copying that into + # the shim resolves the attribute straight back to the real module and the shim stops + # shimming. 3.14 defines it eagerly via _types, which is why this passed locally and + # failed on CI's 3.13 job on every run since 2026-08-19. shim = types.ModuleType("types") for name in dir(types): - if name != "CapsuleType": + if name not in ("CapsuleType", "__getattr__"): setattr(shim, name, getattr(types, name)) self.assertFalse(hasattr(shim, "CapsuleType"))