Compare commits

...
Author SHA1 Message Date
Vito Sansevero ef53014ec1 fix(tests): close the twin database before the bulk-delete temp dir goes (#510)
tearDown removed the temp folder before the test's addCleanup closed
twin.db, so Windows refused the delete (WinError 32). Register the folder
and main database cleanups in setUp so they run after every cleanup a
test adds.
2026-10-29 15:17:31 -07:00
+5 -4
View File
@@ -64,14 +64,15 @@ def table_dump(db):
class LibraryDeleteCase(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
# Cleanups run last-in first-out and after every cleanup a test adds,
# so a database a test opens (and closes via addCleanup) is closed
# before the folder goes; Windows cannot delete an open file (#510).
self.addCleanup(self.temp.cleanup)
self.root = Path(self.temp.name)
self.db = PromptDatabase(str(self.root / "delete.db"))
self.addCleanup(self.db.close_all)
self.epoch = self.db.get_library_options()["library_epoch"]
def tearDown(self):
self.db.close_all()
self.temp.cleanup()
def paired(self, positive, negative="blur"):
pair = self.db.save_prompt_pair(positive, negative)
found = self.db.get_prompt_pair(pair)