diff options
| author | Claude Paroz <claude@2xlibre.net> | 2015-01-02 17:58:58 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2015-01-05 17:19:35 +0100 |
| commit | 6e1c9c6568c405bfa481dda4249abe2960173547 (patch) | |
| tree | 12810d919e3f0e35cd8e277ec996fb9e851a786e /tests | |
| parent | d94fe42ae5e67e9fd600d204a08eef00cc10a7df (diff) | |
Fixed #8280 -- Allowed management command discovery for eggs
Thanks jdetaeye for the report, bhuztez and jdetaeye for the
initial patches, Tim Graham and Berker Peksag for the reviews.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/user_commands/eggs/basic.egg | bin | 0 -> 3465 bytes | |||
| -rw-r--r-- | tests/user_commands/tests.py | 17 |
2 files changed, 15 insertions, 2 deletions
diff --git a/tests/user_commands/eggs/basic.egg b/tests/user_commands/eggs/basic.egg Binary files differnew file mode 100644 index 0000000000..cb25c6d8cf --- /dev/null +++ b/tests/user_commands/eggs/basic.egg diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py index 6a5677f2c9..dff7dcaed5 100644 --- a/tests/user_commands/tests.py +++ b/tests/user_commands/tests.py @@ -1,13 +1,15 @@ import os +from django.apps import apps from django.db import connection from django.core import management -from django.core.management import BaseCommand, CommandError +from django.core.management import BaseCommand, CommandError, find_commands from django.core.management.utils import find_command, popen_wrapper from django.test import SimpleTestCase, ignore_warnings -from django.test.utils import captured_stderr, captured_stdout +from django.test.utils import captured_stderr, captured_stdout, extend_sys_path from django.utils import translation from django.utils.deprecation import RemovedInDjango20Warning +from django.utils._os import upath from django.utils.six import StringIO @@ -72,6 +74,17 @@ class CommandTests(SimpleTestCase): if current_path is not None: os.environ['PATH'] = current_path + def test_discover_commands_in_eggs(self): + """ + Test that management commands can also be loaded from Python eggs. + """ + egg_dir = '%s/eggs' % os.path.dirname(upath(__file__)) + egg_name = '%s/basic.egg' % egg_dir + with extend_sys_path(egg_name): + with self.settings(INSTALLED_APPS=['commandegg']): + cmds = find_commands(os.path.join(apps.get_app_config('commandegg').path, 'management')) + self.assertEqual(cmds, ['eggcommand']) + def test_call_command_option_parsing(self): """ When passing the long option name to call_command, the available option |
