summaryrefslogtreecommitdiff
path: root/tests/initial_sql_regress
diff options
context:
space:
mode:
authorMichael Manfre <mmanfre@gmail.com>2014-01-09 10:05:15 -0500
committerMichael Manfre <mmanfre@gmail.com>2014-02-02 12:47:21 -0500
commit3ffeb931869cc68a8e0916219702ee282afc6e9d (patch)
treef24020307dd5b529989329bfabfc95effcecffe8 /tests/initial_sql_regress
parent0837eacc4e1fa7916e48135e8ba43f54a7a64997 (diff)
Ensure cursors are closed when no longer needed.
This commit touchs various parts of the code base and test framework. Any found usage of opening a cursor for the sake of initializing a connection has been replaced with 'ensure_connection()'.
Diffstat (limited to 'tests/initial_sql_regress')
-rw-r--r--tests/initial_sql_regress/tests.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/initial_sql_regress/tests.py b/tests/initial_sql_regress/tests.py
index e725f4b102..428d993667 100644
--- a/tests/initial_sql_regress/tests.py
+++ b/tests/initial_sql_regress/tests.py
@@ -28,9 +28,9 @@ class InitialSQLTests(TestCase):
connection = connections[DEFAULT_DB_ALIAS]
custom_sql = custom_sql_for_model(Simple, no_style(), connection)
self.assertEqual(len(custom_sql), 9)
- cursor = connection.cursor()
- for sql in custom_sql:
- cursor.execute(sql)
+ with connection.cursor() as cursor:
+ for sql in custom_sql:
+ cursor.execute(sql)
self.assertEqual(Simple.objects.count(), 9)
self.assertEqual(
Simple.objects.get(name__contains='placeholders').name,