Skip to content

Commit 5844043

Browse files
author
Codeflash Bot
committed
ready
1 parent 376ca0d commit 5844043

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

codeflash/discovery/discover_unit_tests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,17 @@ def visit_ImportFrom(self, node: ast.ImportFrom) -> None:
296296
self.found_qualified_name = target_func
297297
return
298298

299+
# Check if any target function is a method of the imported class/module
300+
# e.g., importing Graph and looking for Graph.topologicalSort
301+
# TODO will pick up all tests which have the same class name (could be coming from a different file)
302+
for target_func in fnames:
303+
if "." in target_func:
304+
class_name, method_name = target_func.split(".", 1)
305+
if aname == class_name:
306+
self.found_any_target_function = True
307+
self.found_qualified_name = target_func
308+
return
309+
299310
def visit_Attribute(self, node: ast.Attribute) -> None:
300311
"""Handle attribute access like module.function_name."""
301312
if self.found_any_target_function:

tests/scripts/end_to_end_test_topological_sort_worktree.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def run_test(expected_improvement_pct: int) -> bool:
1818
expected_lines=[25, 26, 27, 28, 29, 30, 31],
1919
)
2020
],
21+
expected_unit_tests=1,
2122
)
2223
cwd = (pathlib.Path(__file__).parent.parent.parent / "code_to_optimize").resolve()
2324
return_var = run_codeflash_command(cwd, config, expected_improvement_pct)

0 commit comments

Comments
 (0)