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
- Forcing unit test runner to abort after failed test by simonbun 4 years, 8 months ago
- Variable._resolve_lookup monkeypatch by showell 2 years, 2 months ago
- Django and Twill by spookylukey 3 years, 10 months ago
- "Zoom in" on rendered HTML that the test client returns by peterbe 2 years, 9 months ago
- Stop tests at the first failure by akaihola 4 years, 1 month ago
Comments