mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #10080: call_command
now takes option defaults into account, sparing individual commands from any difference between call_command
and being run from the shell. Thanks, Alex Koshelev.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10400 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
20b598bf3e
commit
8da2322cad
3 changed files with 24 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
|||
from optparse import make_option
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
@ -5,5 +6,9 @@ class Command(BaseCommand):
|
|||
args = ''
|
||||
requires_model_validation = True
|
||||
|
||||
option_list =[
|
||||
make_option("-s", "--style", default="Rock'n'Roll")
|
||||
]
|
||||
|
||||
def handle(self, *args, **options):
|
||||
print "I don't feel like dancing."
|
||||
print "I don't feel like dancing %s." % options["style"]
|
||||
|
|
|
@ -17,8 +17,8 @@ __test__ = {'API_TESTS': """
|
|||
>>> from django.core import management
|
||||
|
||||
# Invoke a simple user-defined command
|
||||
>>> management.call_command('dance')
|
||||
I don't feel like dancing.
|
||||
>>> management.call_command('dance', style="Jive")
|
||||
I don't feel like dancing Jive.
|
||||
|
||||
# Invoke a command that doesn't exist
|
||||
>>> management.call_command('explode')
|
||||
|
@ -26,5 +26,8 @@ Traceback (most recent call last):
|
|||
...
|
||||
CommandError: Unknown command: 'explode'
|
||||
|
||||
# Invoke a command with default option `style`
|
||||
>>> management.call_command('dance')
|
||||
I don't feel like dancing Rock'n'Roll.
|
||||
|
||||
"""}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue