1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #27787 -- Made call_command() validate the options it receives.

This commit is contained in:
Chandrakant Kumar
2017-01-28 16:02:33 +05:30
committed by Tim Graham
parent 92e286498a
commit 2b09e4c88e
8 changed files with 57 additions and 3 deletions

View File

@@ -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):
"""