mirror of
https://github.com/safishamsi/graphify.git
synced 2026-09-23 05:55:54 +00:00
test: add regression test for ambiguous cross-file call resolution (#632)
This commit is contained in:
@@ -168,3 +168,25 @@ def test_calls_deduplication():
|
||||
result = extract_python(FIXTURES / "sample_calls.py")
|
||||
call_pairs = [(e["source"], e["target"]) for e in result["edges"] if e["relation"] == "calls"]
|
||||
assert len(call_pairs) == len(set(call_pairs)), "Duplicate calls edges found"
|
||||
|
||||
|
||||
def test_cross_file_calls_skip_ambiguous_duplicate_labels(tmp_path):
|
||||
"""Unqualified cross-file calls must not guess between duplicate helper names."""
|
||||
caller = tmp_path / "caller.py"
|
||||
helper_a = tmp_path / "a.py"
|
||||
helper_b = tmp_path / "b.py"
|
||||
caller.write_text("def run():\n log()\n")
|
||||
helper_a.write_text("def log():\n return 'a'\n")
|
||||
helper_b.write_text("def log():\n return 'b'\n")
|
||||
|
||||
result = extract([caller, helper_a, helper_b], cache_root=tmp_path)
|
||||
nodes = {n["id"]: n for n in result["nodes"]}
|
||||
calls = [
|
||||
e for e in result["edges"]
|
||||
if e["relation"] == "calls" and e["confidence"] == "INFERRED"
|
||||
]
|
||||
|
||||
assert not any(
|
||||
nodes[e["source"]]["label"] == "run()" and nodes[e["target"]]["label"] == "log()"
|
||||
for e in calls
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user