Author: russellm
Date: 2010-09-13 00:46:34 -0500 (Mon, 13 Sep 2010)
New Revision: 13832

Added:
   django/branches/releases/1.2.X/tests/modeltests/user_commands/tests.py
Modified:
   
django/branches/releases/1.2.X/tests/modeltests/user_commands/management/commands/dance.py
   django/branches/releases/1.2.X/tests/modeltests/user_commands/models.py
Log:
[1.2.X] Migrated user_commands doctests. Thanks to Eric Florenzano.

Backport of r13823 from trunk.

Modified: 
django/branches/releases/1.2.X/tests/modeltests/user_commands/management/commands/dance.py
===================================================================
--- 
django/branches/releases/1.2.X/tests/modeltests/user_commands/management/commands/dance.py
  2010-09-13 05:29:21 UTC (rev 13831)
+++ 
django/branches/releases/1.2.X/tests/modeltests/user_commands/management/commands/dance.py
  2010-09-13 05:46:34 UTC (rev 13832)
@@ -11,4 +11,4 @@
     ]
 
     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"])

Modified: 
django/branches/releases/1.2.X/tests/modeltests/user_commands/models.py
===================================================================
--- django/branches/releases/1.2.X/tests/modeltests/user_commands/models.py     
2010-09-13 05:29:21 UTC (rev 13831)
+++ django/branches/releases/1.2.X/tests/modeltests/user_commands/models.py     
2010-09-13 05:46:34 UTC (rev 13832)
@@ -12,22 +12,3 @@
 ``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.
-
-"""}

Added: django/branches/releases/1.2.X/tests/modeltests/user_commands/tests.py
===================================================================
--- django/branches/releases/1.2.X/tests/modeltests/user_commands/tests.py      
                        (rev 0)
+++ django/branches/releases/1.2.X/tests/modeltests/user_commands/tests.py      
2010-09-13 05:46:34 UTC (rev 13832)
@@ -0,0 +1,21 @@
+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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to