From 6f7c0a4d66f36c59ae9eafa168b455e462d81901 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 20 Mar 2024 11:44:30 +0100 Subject: [PATCH] Fixed ResourceWarning from unclosed SQLite connection in test_utils on Python 3.13+. On SQLite, close() doesn't explicitly close in-memory connections. Follow up to 921670c6943e9c532137b7d164885f2d3ab436b8 and dd45d5223b3c5640baefcb591782bbcff873b6bf. --- tests/test_utils/tests.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py index fab7f27aa11f..cd64c087c43d 100644 --- a/tests/test_utils/tests.py +++ b/tests/test_utils/tests.py @@ -2158,7 +2158,8 @@ def thread_func(): # closed on teardown). for conn in connections_dict.values(): if conn is not connection and conn.allow_thread_sharing: - conn.close() + conn.validate_thread_sharing() + conn._close() conn.dec_thread_sharing() def test_allowed_database_copy_queries(self): @@ -2169,7 +2170,8 @@ def test_allowed_database_copy_queries(self): cursor.execute(sql) self.assertEqual(cursor.fetchone()[0], 1) finally: - new_connection.close() + new_connection.validate_thread_sharing() + new_connection._close() class DatabaseAliasTests(SimpleTestCase):