Loading tests/modeltests/user_commands/management/commands/dance.py +1 −1 Original line number Diff line number Diff line Loading @@ -11,4 +11,4 @@ class Command(BaseCommand): ] def handle(self, *args, **options): print "I don't feel like dancing %s." % options["style"] self.stdout.write("I don't feel like dancing %s." % options["style"]) tests/modeltests/user_commands/models.py +0 −19 Original line number Diff line number Diff line Loading @@ -12,22 +12,3 @@ For more details on how to define your own ``manage.py`` commands, look at the ``django.core.management.commands`` directory. This directory contains the definitions for the base Django ``manage.py`` commands. """ __test__ = {'API_TESTS': """ >>> from django.core import management # Invoke a simple user-defined command >>> management.call_command('dance', style="Jive") I don't feel like dancing Jive. # Invoke a command that doesn't exist >>> management.call_command('explode') 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. """} tests/modeltests/user_commands/tests.py 0 → 100644 +21 −0 Original line number Diff line number Diff line from StringIO import StringIO from django.test import TestCase from django.core import management from django.core.management.base import CommandError class CommandTests(TestCase): def test_command(self): out = StringIO() management.call_command('dance', stdout=out) self.assertEquals(out.getvalue(), "I don't feel like dancing Rock'n'Roll.") def test_command_style(self): out = StringIO() management.call_command('dance', style='Jive', stdout=out) self.assertEquals(out.getvalue(), "I don't feel like dancing Jive.") def test_explode(self): self.assertRaises(CommandError, management.call_command, ('explode',)) No newline at end of file Loading
tests/modeltests/user_commands/management/commands/dance.py +1 −1 Original line number Diff line number Diff line Loading @@ -11,4 +11,4 @@ class Command(BaseCommand): ] def handle(self, *args, **options): print "I don't feel like dancing %s." % options["style"] self.stdout.write("I don't feel like dancing %s." % options["style"])
tests/modeltests/user_commands/models.py +0 −19 Original line number Diff line number Diff line Loading @@ -12,22 +12,3 @@ For more details on how to define your own ``manage.py`` commands, look at the ``django.core.management.commands`` directory. This directory contains the definitions for the base Django ``manage.py`` commands. """ __test__ = {'API_TESTS': """ >>> from django.core import management # Invoke a simple user-defined command >>> management.call_command('dance', style="Jive") I don't feel like dancing Jive. # Invoke a command that doesn't exist >>> management.call_command('explode') 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. """}
tests/modeltests/user_commands/tests.py 0 → 100644 +21 −0 Original line number Diff line number Diff line from StringIO import StringIO from django.test import TestCase from django.core import management from django.core.management.base import CommandError class CommandTests(TestCase): def test_command(self): out = StringIO() management.call_command('dance', stdout=out) self.assertEquals(out.getvalue(), "I don't feel like dancing Rock'n'Roll.") def test_command_style(self): out = StringIO() management.call_command('dance', style='Jive', stdout=out) self.assertEquals(out.getvalue(), "I don't feel like dancing Jive.") def test_explode(self): self.assertRaises(CommandError, management.call_command, ('explode',)) No newline at end of file