mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Fixed #30636 -- Fixed options ordering when cloning test database on MySQL.
--defaults-file must be given before other options.
This commit is contained in:
parent
c1b94e32fb
commit
e47b8293a7
2 changed files with 34 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
|||
import subprocess
|
||||
import unittest
|
||||
from io import StringIO
|
||||
from unittest import mock
|
||||
|
@ -50,3 +51,35 @@ class DatabaseCreationTests(SimpleTestCase):
|
|||
with mock.patch.object(DatabaseCreation, '_clone_db') as _clone_db:
|
||||
creation._clone_test_db('suffix', verbosity=0, keepdb=True)
|
||||
_clone_db.assert_not_called()
|
||||
|
||||
def test_clone_test_db_options_ordering(self):
|
||||
creation = DatabaseCreation(connection)
|
||||
try:
|
||||
saved_settings = connection.settings_dict
|
||||
connection.settings_dict = {
|
||||
'NAME': 'source_db',
|
||||
'USER': '',
|
||||
'PASSWORD': '',
|
||||
'PORT': '',
|
||||
'HOST': '',
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'OPTIONS': {
|
||||
'read_default_file': 'my.cnf',
|
||||
},
|
||||
}
|
||||
with mock.patch.object(subprocess, 'Popen') as mocked_popen:
|
||||
creation._clone_db('source_db', 'target_db')
|
||||
mocked_popen.assert_has_calls([
|
||||
mock.call(
|
||||
[
|
||||
'mysqldump',
|
||||
'--defaults-file=my.cnf',
|
||||
'--routines',
|
||||
'--events',
|
||||
'source_db',
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
),
|
||||
])
|
||||
finally:
|
||||
connection.settings_dict = saved_settings
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue