mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #21018 -- Reversed precedence order for management commands.
This commit is contained in:
parent
f17d00278e
commit
0ce945a671
10 changed files with 50 additions and 2 deletions
0
tests/admin_scripts/complex_app/management/__init__.py
Normal file
0
tests/admin_scripts/complex_app/management/__init__.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.core.management.base import NoArgsCommand
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
self.stdout.write('complex_app')
|
0
tests/admin_scripts/simple_app/management/__init__.py
Normal file
0
tests/admin_scripts/simple_app/management/__init__.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from django.core.management.base import NoArgsCommand
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
|
||||
def handle_noargs(self, **options):
|
||||
self.stdout.write('simple_app')
|
|
@ -25,7 +25,7 @@ from django.test.utils import str_prefix
|
|||
from django.utils.encoding import force_text
|
||||
from django.utils._os import upath
|
||||
from django.utils.six import StringIO
|
||||
from django.test import LiveServerTestCase
|
||||
from django.test import LiveServerTestCase, TestCase
|
||||
|
||||
|
||||
test_dir = os.path.realpath(os.path.join(os.environ['DJANGO_TEST_TEMP_DIR'], 'test_project'))
|
||||
|
@ -1469,6 +1469,24 @@ class CommandTypes(AdminScriptTestCase):
|
|||
self.assertOutput(out, str_prefix("EXECUTE:LabelCommand label=anotherlabel, options=[('no_color', False), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', %(_)s'1')]"))
|
||||
|
||||
|
||||
class Discovery(TestCase):
|
||||
|
||||
def test_precedence(self):
|
||||
"""
|
||||
Apps listed first in INSTALLED_APPS have precendence.
|
||||
"""
|
||||
with self.settings(INSTALLED_APPS=['admin_scripts.complex_app',
|
||||
'admin_scripts.simple_app']):
|
||||
out = StringIO()
|
||||
call_command('duplicate', stdout=out)
|
||||
self.assertEqual(out.getvalue().strip(), 'complex_app')
|
||||
with self.settings(INSTALLED_APPS=['admin_scripts.simple_app',
|
||||
'admin_scripts.complex_app']):
|
||||
out = StringIO()
|
||||
call_command('duplicate', stdout=out)
|
||||
self.assertEqual(out.getvalue().strip(), 'simple_app')
|
||||
|
||||
|
||||
class ArgumentOrder(AdminScriptTestCase):
|
||||
"""Tests for 2-stage argument parsing scheme.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue