Commit 5e5b003
authored
[BUG] Fix SQLite temp DB file on Windows (#691)
Summary:
- Make the test `engine` fixture create the sqlite file with
`NamedTemporaryFile(delete=False, suffix=".db")`,
close the handle before creating the SQLAlchemy engine, and explicitly
dispose & unlink the file in teardown.
- Add a regression test that ensures the temp `.db` exists while the
fixture is active and is removed after teardown.
Files changed:
- src/tests/testutils/default_sqlalchemy.py
- src/tests/testutils/test_default_sqlalchemy.py
Reason:
On Windows, `NamedTemporaryFile()` deletes the file on close by default,
causing SQLAlchemy to fail to open the DB path. This change ensures the
DB file remains accessible for the engine and is cleaned up after tests.
Tests:
- Added `test_engine_fixture_uses_non_deleting_temp_file_and_cleans_up`
to validate behavior.
Fixes: #6871 parent 57a85c1 commit 5e5b003
File tree
2 files changed
+42
-3
lines changed- src/tests/testutils
2 files changed
+42
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
109 | | - | |
110 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| |||
116 | 120 | | |
117 | 121 | | |
118 | 122 | | |
119 | | - | |
120 | 123 | | |
121 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
122 | 129 | | |
123 | 130 | | |
124 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
0 commit comments