1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #31233 -- Closed database connections and cursors after use.

This commit is contained in:
Jon Dufresne
2020-02-03 19:07:00 -08:00
committed by Mariusz Felisiak
parent f48f671223
commit 3259983f56
14 changed files with 86 additions and 55 deletions

View File

@@ -226,7 +226,8 @@ class AssertNumQueriesUponConnectionTests(TransactionTestCase):
if is_opening_connection:
# Avoid infinite recursion. Creating a cursor calls
# ensure_connection() which is currently mocked by this method.
connection.cursor().execute('SELECT 1' + connection.features.bare_select_suffix)
with connection.cursor() as cursor:
cursor.execute('SELECT 1' + connection.features.bare_select_suffix)
ensure_connection = 'django.db.backends.base.base.BaseDatabaseWrapper.ensure_connection'
with mock.patch(ensure_connection, side_effect=make_configuration_query):