From 3ffeb931869cc68a8e0916219702ee282afc6e9d Mon Sep 17 00:00:00 2001 From: Michael Manfre Date: Thu, 9 Jan 2014 10:05:15 -0500 Subject: 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()'. --- tests/initial_sql_regress/tests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/initial_sql_regress') 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, -- cgit v1.3