diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-01-01 18:05:12 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-01-01 18:11:15 +0100 |
| commit | 0ce945a67151acf2c58bc35a47f4c3d45ff30085 (patch) | |
| tree | 717f04846c00278778470f1b02162dbff1121aa0 /tests/admin_scripts | |
| parent | f17d00278ee4a22421dc8148588d94fe7fa17427 (diff) | |
Fixed #21018 -- Reversed precedence order for management commands.
Diffstat (limited to 'tests/admin_scripts')
7 files changed, 33 insertions, 1 deletions
diff --git a/tests/admin_scripts/complex_app/management/__init__.py b/tests/admin_scripts/complex_app/management/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/admin_scripts/complex_app/management/__init__.py diff --git a/tests/admin_scripts/complex_app/management/commands/__init__.py b/tests/admin_scripts/complex_app/management/commands/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/admin_scripts/complex_app/management/commands/__init__.py diff --git a/tests/admin_scripts/complex_app/management/commands/duplicate.py b/tests/admin_scripts/complex_app/management/commands/duplicate.py new file mode 100644 index 0000000000..11b183843f --- /dev/null +++ b/tests/admin_scripts/complex_app/management/commands/duplicate.py @@ -0,0 +1,7 @@ +from django.core.management.base import NoArgsCommand + + +class Command(NoArgsCommand): + + def handle_noargs(self, **options): + self.stdout.write('complex_app') diff --git a/tests/admin_scripts/simple_app/management/__init__.py b/tests/admin_scripts/simple_app/management/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/admin_scripts/simple_app/management/__init__.py diff --git a/tests/admin_scripts/simple_app/management/commands/__init__.py b/tests/admin_scripts/simple_app/management/commands/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/admin_scripts/simple_app/management/commands/__init__.py diff --git a/tests/admin_scripts/simple_app/management/commands/duplicate.py b/tests/admin_scripts/simple_app/management/commands/duplicate.py new file mode 100644 index 0000000000..a451f3991c --- /dev/null +++ b/tests/admin_scripts/simple_app/management/commands/duplicate.py @@ -0,0 +1,7 @@ +from django.core.management.base import NoArgsCommand + + +class Command(NoArgsCommand): + + def handle_noargs(self, **options): + self.stdout.write('simple_app') diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 3587748c8e..e052a1a6d7 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -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. |
