From c159bacebaa256a7d171d00a3eb14c4ef8357f7c Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 31 Dec 2019 12:09:50 +0100 Subject: [PATCH] Refs #31117 -- Isolated backends.sqlite.test_creation.TestDbSignatureTests. --- tests/backends/sqlite/test_creation.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/backends/sqlite/test_creation.py b/tests/backends/sqlite/test_creation.py index 72d032440f3..723e481077e 100644 --- a/tests/backends/sqlite/test_creation.py +++ b/tests/backends/sqlite/test_creation.py @@ -1,18 +1,16 @@ import copy import unittest -from django.db import connection +from django.db import DEFAULT_DB_ALIAS, connection, connections from django.test import SimpleTestCase @unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite tests') class TestDbSignatureTests(SimpleTestCase): def test_custom_test_name(self): - saved_settings = copy.deepcopy(connection.settings_dict) - try: - connection.settings_dict['NAME'] = None - connection.settings_dict['TEST']['NAME'] = 'custom.sqlite.db' - signature = connection.creation.test_db_signature() - self.assertEqual(signature, (None, 'custom.sqlite.db')) - finally: - connection.settings_dict = saved_settings + test_connection = copy.copy(connections[DEFAULT_DB_ALIAS]) + test_connection.settings_dict = copy.deepcopy(connections[DEFAULT_DB_ALIAS].settings_dict) + test_connection.settings_dict['NAME'] = None + test_connection.settings_dict['TEST']['NAME'] = 'custom.sqlite.db' + signature = test_connection.creation_class(test_connection).test_db_signature() + self.assertEqual(signature, (None, 'custom.sqlite.db'))