diff options
| author | Girish Sontakke <61848210+girishsontakke@users.noreply.github.com> | 2021-03-25 11:07:01 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-25 06:37:01 +0100 |
| commit | 5388ff2a52ec87dae6638f5c1b85d1580f02a526 (patch) | |
| tree | f9f87771d9b1d718c91784e6b1baf22880d887c5 | |
| parent | f5a22442176878d07e80ae5ba0af1dd8d6910fbd (diff) | |
Fixed #32582 -- Removed unnecessary dot in names of cloned test databases on SQLite.
| -rw-r--r-- | django/db/backends/sqlite3/creation.py | 2 | ||||
| -rw-r--r-- | tests/backends/sqlite/test_creation.py | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/django/db/backends/sqlite3/creation.py b/django/db/backends/sqlite3/creation.py index f3bb8dd3b2..4a4046c670 100644 --- a/django/db/backends/sqlite3/creation.py +++ b/django/db/backends/sqlite3/creation.py @@ -55,7 +55,7 @@ class DatabaseCreation(BaseDatabaseCreation): return orig_settings_dict else: root, ext = os.path.splitext(orig_settings_dict['NAME']) - return {**orig_settings_dict, 'NAME': '{}_{}.{}'.format(root, suffix, ext)} + return {**orig_settings_dict, 'NAME': '{}_{}{}'.format(root, suffix, ext)} def _clone_test_db(self, suffix, verbosity, keepdb=False): source_database_name = self.connection.settings_dict['NAME'] diff --git a/tests/backends/sqlite/test_creation.py b/tests/backends/sqlite/test_creation.py index 723e481077..6ec4262f73 100644 --- a/tests/backends/sqlite/test_creation.py +++ b/tests/backends/sqlite/test_creation.py @@ -14,3 +14,20 @@ class TestDbSignatureTests(SimpleTestCase): 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')) + + def test_get_test_db_clone_settings_name(self): + test_connection = copy.copy(connections[DEFAULT_DB_ALIAS]) + test_connection.settings_dict = copy.deepcopy( + connections[DEFAULT_DB_ALIAS].settings_dict, + ) + tests = [ + ('test.sqlite3', 'test_1.sqlite3'), + ('test', 'test_1'), + ] + for test_db_name, expected_clone_name in tests: + with self.subTest(test_db_name=test_db_name): + test_connection.settings_dict['NAME'] = test_db_name + test_connection.settings_dict['TEST']['NAME'] = test_db_name + creation_class = test_connection.creation_class(test_connection) + clone_settings_dict = creation_class.get_test_db_clone_settings('1') + self.assertEqual(clone_settings_dict['NAME'], expected_clone_name) |
