diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-08-23 09:09:23 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-23 09:09:23 +0200 |
| commit | dd45d5223b3c5640baefcb591782bbcff873b6bf (patch) | |
| tree | cc5f61b2c82e6a1f0c605e91f788dc7b39f4806f /tests/test_runner | |
| parent | a9e0f3d3014461c2199123721899162c0876959d (diff) | |
Fixed ResourceWarning from unclosed SQLite connection on Python 3.13+.
- backends.sqlite.tests.ThreadSharing.test_database_sharing_in_threads
- backends.tests.ThreadTests.test_default_connection_thread_local:
on SQLite, close() doesn't explicitly close in-memory connections.
- servers.tests.LiveServerInMemoryDatabaseLockTest
- test_runner.tests.SQLiteInMemoryTestDbs.test_transaction_support
Check out https://github.com/python/cpython/pull/108015.
Diffstat (limited to 'tests/test_runner')
| -rw-r--r-- | tests/test_runner/tests.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py index 28145be3db..0643bf93a1 100644 --- a/tests/test_runner/tests.py +++ b/tests/test_runner/tests.py @@ -779,16 +779,21 @@ class SQLiteInMemoryTestDbs(TransactionTestCase): ) with mock.patch("django.test.utils.connections", new=tested_connections): other = tested_connections["other"] - DiscoverRunner(verbosity=0).setup_databases() - msg = ( - "DATABASES setting '%s' option set to sqlite3's ':memory:' value " - "shouldn't interfere with transaction support detection." - % option_key - ) - # Transaction support is properly initialized for the 'other' DB. - self.assertTrue(other.features.supports_transactions, msg) - # And all the DBs report that they support transactions. - self.assertTrue(connections_support_transactions(), msg) + try: + new_test_connections = DiscoverRunner(verbosity=0).setup_databases() + msg = ( + f"DATABASES setting '{option_key}' option set to sqlite3's " + "':memory:' value shouldn't interfere with transaction support " + "detection." + ) + # Transaction support is properly initialized for the + # 'other' DB. + self.assertTrue(other.features.supports_transactions, msg) + # And all the DBs report that they support transactions. + self.assertTrue(connections_support_transactions(), msg) + finally: + for test_connection, _, _ in new_test_connections: + test_connection._close() class DummyBackendTest(unittest.TestCase): |
