Skip to content

Commit

Permalink
Fixed ResourceWarning from unclosed SQLite connection in test_utils o…
Browse files Browse the repository at this point in the history
…n Python 3.13+.

On SQLite, close() doesn't explicitly close in-memory connections.

Follow up to 921670c and
dd45d52.
  • Loading branch information
felixxm authored Mar 20, 2024
1 parent f2388a4 commit 6f7c0a4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/test_utils/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 6f7c0a4

Please sign in to comment.