From 0d1fa172de4d5ba0350f5329430bbb60b1bb54e2 Mon Sep 17 00:00:00 2001 From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com> Date: Thu, 4 May 2023 08:13:45 +0200 Subject: [PATCH] tests: explicitly close sqlite3 connections on Python 3.11, the Windows CI started crashing due to the database file remainig open unexpectly in test shutdown; this attemps to fix that --- test/test_dbcore.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/test_dbcore.py b/test/test_dbcore.py index 80d85c3bb..c25157b85 100644 --- a/test/test_dbcore.py +++ b/test/test_dbcore.py @@ -171,6 +171,7 @@ class MigrationTest(unittest.TestCase): 'insert into test (field_one, field_two) values (4, 2)' ) old_lib._connection().commit() + old_lib._connection().close() del old_lib @classmethod @@ -190,6 +191,7 @@ class MigrationTest(unittest.TestCase): c = new_lib._connection().cursor() c.execute("select * from test") row = c.fetchone() + c.connection.close() self.assertEqual(len(row.keys()), len(ModelFixture2._fields)) def test_open_with_new_field_adds_column(self): @@ -197,6 +199,7 @@ class MigrationTest(unittest.TestCase): c = new_lib._connection().cursor() c.execute("select * from test") row = c.fetchone() + c.connection.close() self.assertEqual(len(row.keys()), len(ModelFixture3._fields)) def test_open_with_fewer_fields_leaves_untouched(self): @@ -204,6 +207,7 @@ class MigrationTest(unittest.TestCase): c = new_lib._connection().cursor() c.execute("select * from test") row = c.fetchone() + c.connection.close() self.assertEqual(len(row.keys()), len(ModelFixture2._fields)) def test_open_with_multiple_new_fields(self): @@ -211,12 +215,15 @@ class MigrationTest(unittest.TestCase): c = new_lib._connection().cursor() c.execute("select * from test") row = c.fetchone() + c.connection.close() self.assertEqual(len(row.keys()), len(ModelFixture4._fields)) def test_extra_model_adds_table(self): new_lib = DatabaseFixtureTwoModels(self.libfile) try: - new_lib._connection().execute("select * from another") + c = new_lib._connection() + c.execute("select * from another") + c.close() except sqlite3.OperationalError: self.fail("select failed")