Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions code_review_graph/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ def _invalidate_cache(self) -> None:
self._stats_cache = None

def close(self) -> None:
if self._conn.in_transaction:
self._conn.commit()
self._conn.close()

# --- Write operations ---
Expand Down
26 changes: 26 additions & 0 deletions debug_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

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}")
1 change: 1 addition & 0 deletions tests/test_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def setup_method(self):

def teardown_method(self):
self.store.close()
self.tmp.close()
Path(self.tmp.name).unlink(missing_ok=True)

# -- helpers --
Expand Down
1 change: 1 addition & 0 deletions tests/test_communities.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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_two_clusters(self):
Expand Down
1 change: 1 addition & 0 deletions tests/test_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def setup_method(self):

def teardown_method(self):
self.store.close()
self.tmp.close()
Path(self.tmp.name).unlink(missing_ok=True)

# -- helpers --
Expand Down
3 changes: 3 additions & 0 deletions tests/test_graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for the graph storage and query engine."""

import gc
import tempfile
from pathlib import Path

Expand All @@ -14,6 +15,8 @@ def setup_method(self):

def teardown_method(self):
self.store.close()
self.tmp.close()
gc.collect()
Path(self.tmp.name).unlink(missing_ok=True)

def _make_file_node(self, path="/test/file.py"):
Expand Down
1 change: 1 addition & 0 deletions tests/test_integration_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def setup_method(self):

def teardown_method(self):
self.store.close()
self.tmp.close()
Path(self.tmp.name).unlink(missing_ok=True)

# -----------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,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_fresh_db_gets_latest_version(self):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_refactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def setup_method(self):

def teardown_method(self):
self.store.close()
self.tmp.close()
Path(self.tmp.name).unlink(missing_ok=True)
# Clean up pending refactors.
with _refactor_lock:
Expand Down Expand Up @@ -115,6 +116,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(self):
Expand Down Expand Up @@ -202,6 +204,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(self):
Expand Down
1 change: 1 addition & 0 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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):
Expand Down
1 change: 1 addition & 0 deletions tests/test_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def setup_method(self):

def teardown_method(self):
self.store.close()
self.tmp.close()
Path(self.tmp.name).unlink(missing_ok=True)
# Clean up wiki dir
wiki_path = Path(self.wiki_dir)
Expand Down
Loading