|
@@ -1,3 +1,4 @@
|
|
|
+import gc
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
|
|
from django.db import DEFAULT_DB_ALIAS, connection, connections, transaction
|
|
@@ -60,6 +61,36 @@ class DatabaseWrapperTests(SimpleTestCase):
|
|
|
with patch.object(connection.features, "minimum_database_version", None):
|
|
|
connection.check_database_version_supported()
|
|
|
|
|
|
+ def test_release_memory_without_garbage_collection(self):
|
|
|
+
|
|
|
+ self.addCleanup(gc.set_debug, 0)
|
|
|
+ self.addCleanup(gc.enable)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ gc.disable()
|
|
|
+ gc.collect()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ gc.set_debug(gc.DEBUG_SAVEALL)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ test_connection = connection.copy()
|
|
|
+ with test_connection.wrap_database_errors:
|
|
|
+ self.assertEqual(test_connection.queries, [])
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ test_connection.close()
|
|
|
+ test_connection = None
|
|
|
+
|
|
|
+
|
|
|
+ gc.collect()
|
|
|
+ self.assertEqual(gc.garbage, [])
|
|
|
+
|
|
|
|
|
|
class DatabaseWrapperLoggingTests(TransactionTestCase):
|
|
|
available_apps = ["backends"]
|