~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Robert J. Tanner
  • Date: 2009-04-20 08:37:32 UTC
  • mfrom: (4299 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4300.
  • Revision ID: tanner@real-time.com-20090420083732-bzx919oo7wpmqc2u
[merge] 1.14rc2 back into bzr.dev (Bob Tanner)

Show diffs side-by-side

added added

removed removed

Lines of Context:
836
836
    def test_known_failure(self):
837
837
        """A KnownFailure being raised should trigger several result actions."""
838
838
        class InstrumentedTestResult(ExtendedTestResult):
839
 
 
 
839
            def done(self): pass
 
840
            def startTests(self): pass
840
841
            def report_test_start(self, test): pass
841
842
            def report_known_failure(self, test, err):
842
843
                self._call = test, err
884
885
        # text test output formatting
885
886
        pb = MockProgress()
886
887
        result = bzrlib.tests.TextTestResult(
887
 
            None,
 
888
            StringIO(),
888
889
            descriptions=0,
889
890
            verbosity=1,
890
891
            pb=pb,
924
925
    def test_add_not_supported(self):
925
926
        """Test the behaviour of invoking addNotSupported."""
926
927
        class InstrumentedTestResult(ExtendedTestResult):
 
928
            def done(self): pass
 
929
            def startTests(self): pass
927
930
            def report_test_start(self, test): pass
928
931
            def report_unsupported(self, test, feature):
929
932
                self._call = test, feature
966
969
        # text test output formatting
967
970
        pb = MockProgress()
968
971
        result = bzrlib.tests.TextTestResult(
969
 
            None,
 
972
            StringIO(),
970
973
            descriptions=0,
971
974
            verbosity=1,
972
975
            pb=pb,
994
997
    def test_unavailable_exception(self):
995
998
        """An UnavailableFeature being raised should invoke addNotSupported."""
996
999
        class InstrumentedTestResult(ExtendedTestResult):
997
 
 
 
1000
            def done(self): pass
 
1001
            def startTests(self): pass
998
1002
            def report_test_start(self, test): pass
999
1003
            def addNotSupported(self, test, feature):
1000
1004
                self._call = test, feature
1037
1041
        self.assertTrue(result.wasStrictlySuccessful())
1038
1042
        self.assertEqual(None, result._extractBenchmarkTime(test))
1039
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
            def report_test_start(self, test): pass
 
1050
        result = InstrumentedTestResult(None, None, None, None)
 
1051
        def test_function():
 
1052
            pass
 
1053
        test = unittest.FunctionTestCase(test_function)
 
1054
        test.run(result)
 
1055
        self.assertEquals(1, result.calls)
 
1056
 
1040
1057
 
1041
1058
class TestUnicodeFilenameFeature(TestCase):
1042
1059
 
1094
1111
            '----------------------------------------------------------------------',
1095
1112
            '',
1096
1113
            'FAILED (failures=1, known_failure_count=1)'],
1097
 
            lines[0:5] + lines[6:10] + lines[11:])
 
1114
            lines[3:8] + lines[9:13] + lines[14:])
1098
1115
 
1099
1116
    def test_known_failure_ok_run(self):
1100
1117
        # run a test that generates a known failure which should be printed in the final output.
2348
2365
                calls.append(test)
2349
2366
                return ExtendedTestResult(self.stream, self.descriptions,
2350
2367
                    self.verbosity)
2351
 
        run_suite(suite, runner_class=MyRunner)
 
2368
        run_suite(suite, runner_class=MyRunner, stream=StringIO())
2352
2369
        self.assertEqual(calls, [suite])
 
2370
 
 
2371
    def test_done(self):
 
2372
        """run_suite should call result.done()"""
 
2373
        self.calls = 0
 
2374
        def one_more_call(): self.calls += 1
 
2375
        def test_function():
 
2376
            pass
 
2377
        test = unittest.FunctionTestCase(test_function)
 
2378
        class InstrumentedTestResult(ExtendedTestResult):
 
2379
            def done(self): one_more_call()
 
2380
        class MyRunner(TextTestRunner):
 
2381
            def run(self, test):
 
2382
                return InstrumentedTestResult(self.stream, self.descriptions,
 
2383
                                              self.verbosity)
 
2384
        run_suite(test, runner_class=MyRunner, stream=StringIO())
 
2385
        self.assertEquals(1, self.calls)