summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-04-05 17:28:09 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-04-05 17:28:09 +0000
commit33173e98c1c9bbf0fd7c9ad3592f85c4be505dfb (patch)
tree7740653fb4ff296e56440ee45e9a8c902ddb2aa2 /tests
parent35c30ee957156a0dc3e58b3eb2cd900d4fe965e5 (diff)
[1.0.X] 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. Backport of 10400 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10401 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/user_commands/management/commands/dance.py7
-rw-r--r--tests/modeltests/user_commands/models.py7
2 files changed, 11 insertions, 3 deletions
diff --git a/tests/modeltests/user_commands/management/commands/dance.py b/tests/modeltests/user_commands/management/commands/dance.py
index 5886cd1d8f..a504d486d6 100644
--- a/tests/modeltests/user_commands/management/commands/dance.py
+++ b/tests/modeltests/user_commands/management/commands/dance.py
@@ -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." \ No newline at end of file
+ print "I don't feel like dancing %s." % options["style"]
diff --git a/tests/modeltests/user_commands/models.py b/tests/modeltests/user_commands/models.py
index 8dd7205f98..10ccdb8e2c 100644
--- a/tests/modeltests/user_commands/models.py
+++ b/tests/modeltests/user_commands/models.py
@@ -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.
"""}