~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-24 20:07:12 UTC
  • mfrom: (5901.1.2 bzr.dev-good)
  • Revision ID: pqm@pqm.ubuntu.com-20110524200712-z0ay7c4lsbg1x7qs
(jam) Tell bzr.dev that we really do want mgz's changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    DocTestMatches,
37
37
    Equals,
38
38
    )
39
 
import testtools.tests.helpers
 
39
import testtools.testresult.doubles
40
40
 
41
41
import bzrlib
42
42
from bzrlib import (
721
721
 
722
722
    def test_profiles_tests(self):
723
723
        self.requireFeature(test_lsprof.LSProfFeature)
724
 
        terminal = testtools.tests.helpers.ExtendedTestResult()
 
724
        terminal = testtools.testresult.doubles.ExtendedTestResult()
725
725
        result = tests.ProfileResult(terminal)
726
726
        class Sample(tests.TestCase):
727
727
            def a(self):
744
744
                descriptions=0,
745
745
                verbosity=1,
746
746
                )
747
 
        capture = testtools.tests.helpers.ExtendedTestResult()
 
747
        capture = testtools.testresult.doubles.ExtendedTestResult()
748
748
        test_case.run(MultiTestResult(result, capture))
749
749
        run_case = capture._events[0][1]
750
750
        timed_string = result._testTimeString(run_case)
1045
1045
        test = unittest.TestSuite()
1046
1046
        test.addTest(Test("known_failure_test"))
1047
1047
        def failing_test():
1048
 
            self.fail('foo')
 
1048
            raise AssertionError('foo')
1049
1049
        test.addTest(unittest.FunctionTestCase(failing_test))
1050
1050
        stream = StringIO()
1051
1051
        runner = tests.TextTestRunner(stream=stream)
1059
1059
            '^----------------------------------------------------------------------\n'
1060
1060
            'Traceback \\(most recent call last\\):\n'
1061
1061
            '  .*' # File .*, line .*, in failing_test' - but maybe not from .pyc
1062
 
            '    self.fail\\(\'foo\'\\)\n'
 
1062
            '    raise AssertionError\\(\'foo\'\\)\n'
1063
1063
            '.*'
1064
1064
            '^----------------------------------------------------------------------\n'
1065
1065
            '.*'
1071
1071
        # the final output.
1072
1072
        class Test(tests.TestCase):
1073
1073
            def known_failure_test(self):
1074
 
                self.expectFailure('failed', self.assertTrue, False)
 
1074
                self.knownFailure("Never works...")
1075
1075
        test = Test("known_failure_test")
1076
1076
        stream = StringIO()
1077
1077
        runner = tests.TextTestRunner(stream=stream)
2037
2037
 
2038
2038
    def test_lsprof_tests(self):
2039
2039
        self.requireFeature(test_lsprof.LSProfFeature)
2040
 
        calls = []
 
2040
        results = []
2041
2041
        class Test(object):
2042
2042
            def __call__(test, result):
2043
2043
                test.run(result)
2044
2044
            def run(test, result):
2045
 
                self.assertIsInstance(result, ExtendedToOriginalDecorator)
2046
 
                calls.append("called")
 
2045
                results.append(result)
2047
2046
            def countTestCases(self):
2048
2047
                return 1
2049
2048
        self.run_selftest(test_suite_factory=Test, lsprof_tests=True)
2050
 
        self.assertLength(1, calls)
 
2049
        self.assertLength(1, results)
 
2050
        self.assertIsInstance(results.pop(), ExtendedToOriginalDecorator)
2051
2051
 
2052
2052
    def test_random(self):
2053
2053
        # test randomising by listing a number of tests.