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:
committed by
Tim Graham
parent
92e286498a
commit
2b09e4c88e
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user