diff options
| author | Chandrakant Kumar <k.03chandra@gmail.com> | 2017-01-28 16:02:33 +0530 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-06-16 21:28:38 -0400 |
| commit | 2b09e4c88e96cb03b29f5a6b0e4838ab4271e631 (patch) | |
| tree | e5c7322c72e80add326cce75dc3b5cfbc3f52189 /tests/user_commands | |
| parent | 92e286498acd4f4562be11c21879856de8f47252 (diff) | |
Fixed #27787 -- Made call_command() validate the options it receives.
Diffstat (limited to 'tests/user_commands')
| -rw-r--r-- | tests/user_commands/tests.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py index 6d11068f5b..19ae51b096 100644 --- a/tests/user_commands/tests.py +++ b/tests/user_commands/tests.py @@ -175,6 +175,25 @@ class CommandTests(SimpleTestCase): finally: dance.Command.requires_migrations_checks = requires_migrations_checks + def test_call_command_unrecognized_option(self): + msg = ( + 'Unknown option(s) for dance command: unrecognized. Valid options ' + 'are: example, help, integer, no_color, opt_3, option3, ' + 'pythonpath, settings, skip_checks, stderr, stdout, style, ' + 'traceback, verbosity, version.' + ) + with self.assertRaisesMessage(TypeError, msg): + management.call_command('dance', unrecognized=1) + + msg = ( + 'Unknown option(s) for dance command: unrecognized, unrecognized2. ' + 'Valid options are: example, help, integer, no_color, opt_3, ' + 'option3, pythonpath, settings, skip_checks, stderr, stdout, ' + 'style, traceback, verbosity, version.' + ) + with self.assertRaisesMessage(TypeError, msg): + management.call_command('dance', unrecognized=1, unrecognized2=1) + class CommandRunTests(AdminScriptTestCase): """ |
