diff options
Diffstat (limited to 'tests/db_utils')
| -rw-r--r-- | tests/db_utils/tests.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/db_utils/tests.py b/tests/db_utils/tests.py index 2a45342df5..4e35e6bb8b 100644 --- a/tests/db_utils/tests.py +++ b/tests/db_utils/tests.py @@ -26,10 +26,10 @@ class DatabaseErrorWrapperTests(TestCase): @unittest.skipUnless(connection.vendor == 'postgresql', 'PostgreSQL test') def test_reraising_backend_specific_database_exception(self): - cursor = connection.cursor() - msg = 'table "X" does not exist' - with self.assertRaisesMessage(ProgrammingError, msg) as cm: - cursor.execute('DROP TABLE "X"') + with connection.cursor() as cursor: + msg = 'table "X" does not exist' + with self.assertRaisesMessage(ProgrammingError, msg) as cm: + cursor.execute('DROP TABLE "X"') self.assertNotEqual(type(cm.exception), type(cm.exception.__cause__)) self.assertIsNotNone(cm.exception.__cause__) self.assertIsNotNone(cm.exception.__cause__.pgcode) |
