From 140cb590e7f0fc9268262406cb787cae65c852a9 Mon Sep 17 00:00:00 2001 From: Alex Tumanov Date: Sat, 3 Oct 2026 15:11:01 -0500 Subject: [PATCH] test(extract): preserve isolation with external module calls Require exact coarse calls to unresolved absolute imports while retaining package and cross-directory local target isolation. AI-Assisted-By: OpenAI Codex (cherry picked from commit e1eeede9b56e3f30562410d70264a74d1fa5a48b) --- tests/test_loose_sibling_import_resolution.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_loose_sibling_import_resolution.py b/tests/test_loose_sibling_import_resolution.py index 7652b2d14..c91dcb977 100644 --- a/tests/test_loose_sibling_import_resolution.py +++ b/tests/test_loose_sibling_import_resolution.py @@ -178,9 +178,11 @@ def test_package_isolation_pep328(tmp_path): f"Package import in pkg/app.py was falsely repointed to sibling pkg_helper: {import_edges[0]}" ) - # No member call was resolved (package isolation) + # The coarse external call must not resolve to the package's local helper. call_edges = [e for e in res["edges"] if e.get("relation") == "calls"] - assert not call_edges, f"Spurious call edge resolved inside package: {call_edges}" + assert [(e["source"], e["target"]) for e in call_edges] == [ + ("pkg_app_run", "helper") + ], f"Package call was falsely resolved to a local sibling: {call_edges}" def test_no_cross_directory_leakage(tmp_path): @@ -214,12 +216,14 @@ def test_no_cross_directory_leakage(tmp_path): f"Unrelated src/app.py import was leaked to scripts_utils: {import_edges[0]}" ) - # No member call resolved + # The coarse external call must not resolve to the other directory's utils. call_edges = [ e for e in res["edges"] if e.get("source") == "src_app_run" and e.get("relation") == "calls" ] - assert not call_edges, f"Spurious cross-directory call edge resolved: {call_edges}" + assert [(e["source"], e["target"]) for e in call_edges] == [ + ("src_app_run", "utils") + ], f"Call was falsely resolved across directories: {call_edges}" def test_aliased_import_resolves_member_call(tmp_path):