diff --git a/debug_test.py b/debug_test.py deleted file mode 100644 index 97701b9..0000000 --- a/debug_test.py +++ /dev/null @@ -1,26 +0,0 @@ - -import tempfile -import gc -import time -from pathlib import Path - -def test_foo(): - # Exact pattern from the test - tmp = tempfile.NamedTemporaryFile(suffix='.db', delete=False) - path = tmp.name - - # Don't close tmp, but use its name to open another connection - import sqlite3 - conn = sqlite3.connect(path) - conn.execute('CREATE TABLE test (id INTEGER PRIMARY KEY)') - conn.commit() - - # Close the sqlite connection - conn.close() - - # Now try to delete via Path - try: - Path(path).unlink() - print("Deleted successfully") - except PermissionError as e: - print(f"Failed to delete: {e}") diff --git a/tests/test_changes.py b/tests/test_changes.py index c7649b7..fa40bd1 100644 --- a/tests/test_changes.py +++ b/tests/test_changes.py @@ -399,6 +399,7 @@ def test_detect_changes_tool_no_changes(self): # Patch _get_store to use our test store, # and get_changed_files/get_staged_and_unstaged to return empty. + original_close = self.store.close with ( patch("code_review_graph.tools.review._get_store") as mock_get_store, patch("code_review_graph.tools.review.get_changed_files", return_value=[]), @@ -414,6 +415,8 @@ def test_detect_changes_tool_no_changes(self): assert result["risk_score"] == 0.0 assert result["changed_functions"] == [] assert result["test_gaps"] == [] + # Restore close method for teardown + self.store.close = original_close def test_detect_changes_tool_with_changes(self): """detect_changes_func returns full analysis for changed files.""" @@ -421,6 +424,7 @@ def test_detect_changes_tool_with_changes(self): self._add_func("my_func", path="/fake/repo/app.py", line_start=1, line_end=10) + original_close = self.store.close with ( patch("code_review_graph.tools.review._get_store") as mock_get_store, patch("code_review_graph.tools.review.get_changed_files", return_value=["app.py"]), @@ -438,3 +442,5 @@ def test_detect_changes_tool_with_changes(self): assert "risk_score" in result assert "test_gaps" in result assert "review_priorities" in result + # Restore close method for teardown + self.store.close = original_close diff --git a/tests/test_tools.py b/tests/test_tools.py index 72d2142..4c3285a 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -24,6 +24,7 @@ def setup_method(self): def teardown_method(self): self.store.close() + self.tmp.close() Path(self.tmp.name).unlink(missing_ok=True) def _seed_data(self): @@ -201,6 +202,7 @@ def setup_method(self): def teardown_method(self): self.store.close() + self.tmp.close() Path(self.tmp.name).unlink(missing_ok=True) def test_finds_large_functions(self):