Skip to content

Commit 3d26769

Browse files
committed
PR review feedback
1 parent 6addecc commit 3d26769

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

codeflash/code_utils/compat.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@
1717

1818

1919
codeflash_cache_dir = Path(user_config_dir(appname="codeflash", appauthor="codeflash-ai", ensure_exists=True))
20+
21+
codeflash_cache_db = codeflash_cache_dir / "codeflash_cache.db"

codeflash/discovery/discover_unit_tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from codeflash.cli_cmds.console import console, logger, test_files_progress_bar
1919
from codeflash.code_utils.code_utils import get_run_tmp_file, module_name_from_file_path
20-
from codeflash.code_utils.compat import SAFE_SYS_EXECUTABLE, codeflash_cache_dir
20+
from codeflash.code_utils.compat import SAFE_SYS_EXECUTABLE, codeflash_cache_db
2121
from codeflash.models.models import CodePosition, FunctionCalledInTest, TestsInFile, TestType
2222

2323
if TYPE_CHECKING:
@@ -41,7 +41,7 @@ class TestFunction:
4141

4242
class TestsCache:
4343
def __init__(self) -> None:
44-
self.connection = sqlite3.connect(codeflash_cache_dir / "tests_cache.db")
44+
self.connection = sqlite3.connect(codeflash_cache_db)
4545
self.cur = self.connection.cursor()
4646

4747
self.cur.execute(
@@ -79,6 +79,7 @@ def insert_test(
7979
line_number: int,
8080
col_number: int,
8181
) -> None:
82+
self.cur.execute("DELETE FROM discovered_tests WHERE file_path = ?", (file_path,))
8283
test_type_value = test_type.value if hasattr(test_type, "value") else test_type
8384
self.cur.execute(
8485
"INSERT INTO discovered_tests VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
@@ -115,7 +116,7 @@ def get_tests_for_file(self, file_path: str, file_hash: str) -> list[FunctionCal
115116

116117
@staticmethod
117118
def compute_file_hash(path: str) -> str:
118-
h = hashlib.md5(usedforsecurity=False)
119+
h = hashlib.sha256(usedforsecurity=False)
119120
with Path(path).open("rb") as f:
120121
while True:
121122
chunk = f.read(8192)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ lxml = ">=5.3.0"
9393
crosshair-tool = ">=0.0.78"
9494
coverage = ">=7.6.4"
9595
line_profiler=">=4.2.0" #this is the minimum version which supports python 3.13
96+
platformdirs = "^4.3.7"
9697
[tool.poetry.group.dev]
9798
optional = true
9899

0 commit comments

Comments
 (0)