~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: John Arbash Meinel
  • Date: 2009-03-27 22:29:55 UTC
  • mto: (3735.39.2 clean)
  • mto: This revision was merged to the branch mainline in revision 4280.
  • Revision ID: john@arbash-meinel.com-20090327222955-utifmfm888zerixt
Implement apply_delta_to_source which doesn't have to malloc another string.

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