def test__run_core_called(self):
     case = self.make_case()
     log = []
     run = RunTest(case, lambda x: x)
     run._run_core = lambda: log.append('foo')
     run.run()
     self.assertEqual(['foo'], log)
 def test__run_prepared_result_calls_start_and_stop_test(self):
     result = ExtendedTestResult()
     case = self.make_case()
     run = RunTest(case, lambda x: x)
     run.run(result)
     self.assertEqual([
         ('startTest', case),
         ('addSuccess', case),
         ('stopTest', case),
         ], result._events)
 def test_run_with_result(self):
     # test.run passes result down to _run_test_method.
     log = []
     class Case(TestCase):
         def _run_test_method(self, result):
             log.append(result)
     case = Case('_run_test_method')
     run = RunTest(case, lambda x: log.append(x))
     result = TestResult()
     run.run(result)
     self.assertEqual(1, len(log))
     self.assertEqual(result, log[0].decorated)
 def test__run_prepared_result_calls_stop_test_always(self):
     result = ExtendedTestResult()
     case = self.make_case()
     def inner():
         raise Exception("foo")
     run = RunTest(case, lambda x: x)
     run._run_core = inner
     self.assertThat(lambda: run.run(result),
         Raises(MatchesException(Exception("foo"))))
     self.assertEqual([
         ('startTest', case),
         ('stopTest', case),
         ], result._events)
Esempio n. 5
0
 def test_run_no_result_manages_new_result(self):
     log = []
     run = RunTest(self.make_case(), lambda x: log.append(x) or x)
     result = run.run()
     self.assertIsInstance(result.decorated, TestResult)
 def test_run_no_result_manages_new_result(self):
     log = []
     run = RunTest(self.make_case(), lambda x: log.append(x) or x)
     result = run.run()
     self.assertIsInstance(result.decorated, TestResult)