Fix Windows file locking in repository tests

This commit is contained in:
2025-11-16 20:13:43 +00:00
parent 4ca0496200
commit 3fbd069891

View File

@@ -14,7 +14,8 @@ from py_dvt_ate.data.repository import SQLiteRepository
@pytest.fixture
def temp_db():
"""Create a temporary database for testing."""
with tempfile.TemporaryDirectory() as tmpdir:
# Use ignore_cleanup_errors=True for Windows file locking issues
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as tmpdir:
db_path = Path(tmpdir) / "test.db"
yield db_path
@@ -27,6 +28,7 @@ def repository(temp_db):
yield repo
# Ensure all connections and file handles are closed before cleanup
# This is critical on Windows to prevent PermissionError
repo.close()
del repo
gc.collect()