2009-12-13 17:08:36 +00:00
|
|
|
"""
|
|
|
|
Tests for django test runner
|
|
|
|
"""
|
|
|
|
import StringIO
|
2010-10-11 12:55:17 +00:00
|
|
|
|
2009-12-22 06:00:57 +00:00
|
|
|
from django.test import simple
|
2010-10-11 12:55:17 +00:00
|
|
|
from django.utils import unittest
|
2009-12-22 06:00:57 +00:00
|
|
|
|
|
|
|
class DjangoTestRunnerTests(unittest.TestCase):
|
2009-12-13 17:08:36 +00:00
|
|
|
|
|
|
|
def test_failfast(self):
|
2009-12-22 06:00:57 +00:00
|
|
|
class MockTestOne(unittest.TestCase):
|
2009-12-13 17:08:36 +00:00
|
|
|
def runTest(self):
|
|
|
|
assert False
|
2009-12-22 06:00:57 +00:00
|
|
|
class MockTestTwo(unittest.TestCase):
|
2009-12-13 17:08:36 +00:00
|
|
|
def runTest(self):
|
|
|
|
assert False
|
2009-12-22 06:00:57 +00:00
|
|
|
|
2009-12-13 17:08:36 +00: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 06:00:57 +00:00
|
|
|
|
2009-12-13 17:08:36 +00: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))
|