tests.py 706 B

123456789101112131415161718192021
  1. from StringIO import StringIO
  2. from django.test import TestCase
  3. from django.core import management
  4. from django.core.management.base import CommandError
  5. class CommandTests(TestCase):
  6. def test_command(self):
  7. out = StringIO()
  8. management.call_command('dance', stdout=out)
  9. self.assertEqual(out.getvalue(),
  10. "I don't feel like dancing Rock'n'Roll.")
  11. def test_command_style(self):
  12. out = StringIO()
  13. management.call_command('dance', style='Jive', stdout=out)
  14. self.assertEqual(out.getvalue(),
  15. "I don't feel like dancing Jive.")
  16. def test_explode(self):
  17. self.assertRaises(CommandError, management.call_command, ('explode',))