diff options
Diffstat (limited to 'tests/backends/postgresql/tests.py')
| -rw-r--r-- | tests/backends/postgresql/tests.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/backends/postgresql/tests.py b/tests/backends/postgresql/tests.py index ab8ad4bb93..1dcb14b964 100644 --- a/tests/backends/postgresql/tests.py +++ b/tests/backends/postgresql/tests.py @@ -114,8 +114,8 @@ class Tests(TestCase): try: # Open a database connection. - new_connection.cursor() - self.assertFalse(new_connection.get_autocommit()) + with new_connection.cursor(): + self.assertFalse(new_connection.get_autocommit()) finally: new_connection.close() @@ -149,9 +149,12 @@ class Tests(TestCase): def test_connect_no_is_usable_checks(self): new_connection = connection.copy() - with mock.patch.object(new_connection, 'is_usable') as is_usable: - new_connection.connect() - is_usable.assert_not_called() + try: + with mock.patch.object(new_connection, 'is_usable') as is_usable: + new_connection.connect() + is_usable.assert_not_called() + finally: + new_connection.close() def _select(self, val): with connection.cursor() as cursor: |
