1 # Copyright (c) 2009 Jonathan M. Lange. See LICENSE for details.
3 """Test ConcurrentTestSuite and related things."""
9 from testtools import (
14 from testtools.matchers import (
17 from testtools.tests.helpers import LoggingResult
20 class TestConcurrentTestSuiteRun(TestCase):
22 def test_trivial(self):
24 result = LoggingResult(log)
25 class Sample(TestCase):
29 def test_method1(self):
31 def test_method2(self):
33 test1 = Sample('test_method1')
34 test2 = Sample('test_method2')
35 original_suite = unittest.TestSuite([test1, test2])
36 suite = ConcurrentTestSuite(original_suite, self.split_suite)
40 self.assertIsInstance(test1, Sample)
41 self.assertIsInstance(test2, Sample)
42 self.assertNotEqual(test1.id(), test2.id())
43 # We expect the start/outcome/stop to be grouped
44 expected = [('startTest', test1), ('addSuccess', test1),
45 ('stopTest', test1), ('startTest', test2), ('addSuccess', test2),
47 self.assertThat(log, Equals(expected))
49 def split_suite(self, suite):
50 tests = list(iterate_tests(suite))
51 return tests[0], tests[1]
55 from unittest import TestLoader
56 return TestLoader().loadTestsFromName(__name__)