From 1e7653117f273391705b10c78214e27703e484b8 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 11 Dec 2020 15:06:33 -0500 Subject: [PATCH] Refs #32178 -- Fixed test_mark_expected_failures_and_skips_call teardown. Test isolation failure observed on CockroachDB and PostgreSQL. --- tests/backends/base/test_creation.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/backends/base/test_creation.py b/tests/backends/base/test_creation.py index 6c98556f1e..3a1164557b 100644 --- a/tests/backends/base/test_creation.py +++ b/tests/backends/base/test_creation.py @@ -120,9 +120,14 @@ class TestDbCreationTests(SimpleTestCase): if connection.vendor == 'oracle': # Don't close connection on Oracle. creation.connection.close = mock.Mock() - with mock.patch.object(creation, '_create_test_db'): - creation.create_test_db(verbosity=0, autoclobber=True, serialize=False) - self.assertIs(mark_expected_failures_and_skips.called, False) + old_database_name = test_connection.settings_dict['NAME'] + try: + with mock.patch.object(creation, '_create_test_db'): + creation.create_test_db(verbosity=0, autoclobber=True, serialize=False) + self.assertIs(mark_expected_failures_and_skips.called, False) + finally: + with mock.patch.object(creation, '_destroy_test_db'): + creation.destroy_test_db(old_database_name, verbosity=0) class TestDeserializeDbFromString(TransactionTestCase):