/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Vincent Ladeuil
  • Date: 2009-04-08 19:06:40 UTC
  • mto: (4276.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4277.
  • Revision ID: v.ladeuil+lp@free.fr-20090408190640-ra8frcx4hj55qj02
Fix failure, add tests.

* bzrlib/tests/test_selftest.py:
(TestTestResult.test_startTests.InstrumentedTestResult): Check
that startTests is called once.
(TestRunSuite.test_runner_class): Check that
ExtendedTestResult.done() is called once.

* bzrlib/tests/blackbox/test_selftest.py:
(TestBenchmarkTests.test_benchmark_runs_benchmark_tests): Output
order has changed.

* bzrlib/tests/__init__.py:
(run_suite): At least subunit.TestProtocolClient doesn't define
done().

Show diffs side-by-side

added added

removed removed

Lines of Context:
1041
1041
        self.assertTrue(result.wasStrictlySuccessful())
1042
1042
        self.assertEqual(None, result._extractBenchmarkTime(test))
1043
1043
 
 
1044
    def test_startTests(self):
 
1045
        """Starting the first test should trigger startTests."""
 
1046
        class InstrumentedTestResult(ExtendedTestResult):
 
1047
            calls = 0
 
1048
            def startTests(self): self.calls += 1
 
1049
        result = InstrumentedTestResult(None, None, None, None)
 
1050
        def test_function():
 
1051
            pass
 
1052
        test = unittest.FunctionTestCase(test_function)
 
1053
        test.run(result)
 
1054
        self.assertEquals(1, result.calls)
 
1055
 
1044
1056
 
1045
1057
class TestUnicodeFilenameFeature(TestCase):
1046
1058
 
2354
2366
                    self.verbosity)
2355
2367
        run_suite(suite, runner_class=MyRunner, stream=StringIO())
2356
2368
        self.assertEqual(calls, [suite])
 
2369
 
 
2370
    def test_done(self):
 
2371
        """run_suite should call result.done()"""
 
2372
        self.calls = 0
 
2373
        def one_more_call(): self.calls += 1
 
2374
        def test_function():
 
2375
            pass
 
2376
        test = unittest.FunctionTestCase(test_function)
 
2377
        class InstrumentedTestResult(ExtendedTestResult):
 
2378
            def done(self): one_more_call()
 
2379
        class MyRunner(TextTestRunner):
 
2380
            def run(self, test):
 
2381
                return InstrumentedTestResult(self.stream, self.descriptions,
 
2382
                                              self.verbosity)
 
2383
        run_suite(test, runner_class=MyRunner, stream=StringIO())
 
2384
        self.assertEquals(1, self.calls)