2009-12-14 01:08:36 +08:00
|
|
|
"""
|
|
|
|
Tests for django test runner
|
|
|
|
"""
|
|
|
|
import StringIO
|
|
|
|
import unittest
|
|
|
|
import django
|
2009-12-22 14:00:57 +08:00
|
|
|
from django.test import simple
|
|
|
|
|
|
|
|
class DjangoTestRunnerTests(unittest.TestCase):
|
2009-12-14 01:08:36 +08:00
|
|
|
|
|
|
|
def test_failfast(self):
|
2009-12-22 14:00:57 +08:00
|
|
|
class MockTestOne(unittest.TestCase):
|
2009-12-14 01:08:36 +08:00
|
|
|
def runTest(self):
|
|
|
|
assert False
|
2009-12-22 14:00:57 +08:00
|
|
|
class MockTestTwo(unittest.TestCase):
|
2009-12-14 01:08:36 +08:00
|
|
|
def runTest(self):
|
|
|
|
assert False
|
2009-12-22 14:00:57 +08:00
|
|
|
|
2009-12-14 01:08:36 +08:00
|
|
|
suite = unittest.TestSuite([MockTestOne(), MockTestTwo()])
|
|
|
|
mock_stream = StringIO.StringIO()
|
|
|
|
dtr = simple.DjangoTestRunner(verbosity=0, failfast=False, stream=mock_stream)
|
|
|
|
result = dtr.run(suite)
|
|
|
|
self.assertEqual(2, result.testsRun)
|
|
|
|
self.assertEqual(2, len(result.failures))
|
2009-12-22 14:00:57 +08:00
|
|
|
|
2009-12-14 01:08:36 +08:00
|
|
|
dtr = simple.DjangoTestRunner(verbosity=0, failfast=True, stream=mock_stream)
|
|
|
|
result = dtr.run(suite)
|
|
|
|
self.assertEqual(1, result.testsRun)
|
|
|
|
self.assertEqual(1, len(result.failures))
|