Skip to content

Commit 2d7fd10

Browse files
committed
guard path
1 parent f29824a commit 2d7fd10

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

codeflash/discovery/discover_unit_tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def insert_test(
9090
line_number: int,
9191
col_number: int,
9292
) -> None:
93-
self.cur.execute("DELETE FROM discovered_tests WHERE file_path = ?", (file_path,))
9493
test_type_value = test_type.value if hasattr(test_type, "value") else test_type
9594
self.cur.execute(
9695
"INSERT INTO discovered_tests VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
@@ -210,7 +209,7 @@ def visit_Attribute(self, node: ast.Attribute) -> None:
210209
self.generic_visit(node)
211210

212211

213-
def analyze_imports_in_test_file(test_file_path: Path, target_functions: set[str]) -> tuple[bool, set[str]]:
212+
def analyze_imports_in_test_file(test_file_path: Path | str, target_functions: set[str]) -> tuple[bool, set[str]]:
214213
"""Analyze imports in a test file to determine if it might test any target functions.
215214
216215
Args:
@@ -221,6 +220,9 @@ def analyze_imports_in_test_file(test_file_path: Path, target_functions: set[str
221220
Tuple of (should_process_with_jedi, found_function_names)
222221
223222
"""
223+
if isinstance(test_file_path, str):
224+
test_file_path = Path(test_file_path)
225+
224226
try:
225227
with test_file_path.open("r", encoding="utf-8") as f:
226228
content = f.read()
@@ -263,7 +265,6 @@ def analyze_imports_in_test_file(test_file_path: Path, target_functions: set[str
263265

264266
except (SyntaxError, UnicodeDecodeError, OSError) as e:
265267
logger.debug(f"Failed to analyze imports in {test_file_path}: {e}")
266-
# If we can't parse the file, be conservative and process it
267268
return True, set()
268269

269270

0 commit comments

Comments
 (0)