1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import cStrinIO
import sys
from django.test import TestCase
class MyCommandTestCase(TestCase):
def test_mycommand_failure(self):
old_stderr = sys.stderr
sys.stderr = cStringIO.StringIO()
self.assertRaises(BaseException, management.call_command, 'mycommand')
self.assertTrue('Error: Some error condition here' in sys.stderr.getvalue())
sys.stderr = old_stderr
|
More like this
- Django and Twill by spookylukey 5 years, 1 month ago
- Forcing unit test runner to abort after failed test by simonbun 6 years ago
- Add example contact with BaseCommand by magik_cypress 9 months, 1 week ago
- Add example content with BaseCommand by magik_cypress 9 months, 1 week ago
- Monitoring django-sphinx for Nagios by johnnoone 4 years, 1 month ago
Comments