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/cache/tests.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tests/cache') diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 94790ed740..bc0f705375 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -896,10 +896,9 @@ class DBCacheTests(BaseCacheTests, TransactionTestCase): management.call_command('createcachetable', verbosity=0, interactive=False) def drop_table(self): - cursor = connection.cursor() - table_name = connection.ops.quote_name('test cache table') - cursor.execute('DROP TABLE %s' % table_name) - cursor.close() + with connection.cursor() as cursor: + table_name = connection.ops.quote_name('test cache table') + cursor.execute('DROP TABLE %s' % table_name) def test_zero_cull(self): self._perform_cull_test(caches['zero_cull'], 50, 18) -- cgit v1.3