diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-01-20 10:47:02 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-01-20 11:00:05 +0100 |
commit | f34be5294d8bd9530079525fb56e661816a63e20 (patch) | |
tree | f12062bca57a45eb8a4dee1c03106ec44bdb8260 /tests/backends | |
parent | a920c0b852371d7cae4aacd5c67b62fe3c4e2d55 (diff) | |
download | django-f34be5294d8bd9530079525fb56e661816a63e20.tar.gz |
Refs #31117 -- Moved get_connection_copy() test hook to a module level.
Diffstat (limited to 'tests/backends')
-rw-r--r-- | tests/backends/base/test_creation.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/backends/base/test_creation.py b/tests/backends/base/test_creation.py index 340eaafc89..eb6004f898 100644 --- a/tests/backends/base/test_creation.py +++ b/tests/backends/base/test_creation.py @@ -8,19 +8,21 @@ from django.db.backends.base.creation import ( from django.test import SimpleTestCase -class TestDbSignatureTests(SimpleTestCase): +def get_connection_copy(): + # Get a copy of the default connection. (Can't use django.db.connection + # because it'll modify the default connection itself.) + test_connection = copy.copy(connections[DEFAULT_DB_ALIAS]) + test_connection.settings_dict = copy.deepcopy( + connections[DEFAULT_DB_ALIAS].settings_dict + ) + return test_connection - def get_connection_copy(self): - # Get a copy of the default connection. (Can't use django.db.connection - # because it'll modify the default connection itself.) - test_connection = copy.copy(connections[DEFAULT_DB_ALIAS]) - test_connection.settings_dict = copy.copy(connections[DEFAULT_DB_ALIAS].settings_dict) - return test_connection +class TestDbSignatureTests(SimpleTestCase): def test_default_name(self): # A test db name isn't set. prod_name = 'hodor' - test_connection = self.get_connection_copy() + test_connection = get_connection_copy() test_connection.settings_dict['NAME'] = prod_name test_connection.settings_dict['TEST'] = {'NAME': None} signature = BaseDatabaseCreation(test_connection).test_db_signature() @@ -29,7 +31,7 @@ class TestDbSignatureTests(SimpleTestCase): def test_custom_test_name(self): # A regular test db name is set. test_name = 'hodor' - test_connection = self.get_connection_copy() + test_connection = get_connection_copy() test_connection.settings_dict['TEST'] = {'NAME': test_name} signature = BaseDatabaseCreation(test_connection).test_db_signature() self.assertEqual(signature[3], test_name) @@ -37,7 +39,7 @@ class TestDbSignatureTests(SimpleTestCase): def test_custom_test_name_with_test_prefix(self): # A test db name prefixed with TEST_DATABASE_PREFIX is set. test_name = TEST_DATABASE_PREFIX + 'hodor' - test_connection = self.get_connection_copy() + test_connection = get_connection_copy() test_connection.settings_dict['TEST'] = {'NAME': test_name} signature = BaseDatabaseCreation(test_connection).test_db_signature() self.assertEqual(signature[3], test_name) |