~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Jelmer Vernooij
  • Date: 2009-10-27 21:54:26 UTC
  • mfrom: (4771 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4833.
  • Revision ID: jelmer@samba.org-20091027215426-72164bkd4mq9dsd4
merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for the test framework."""
18
18
 
19
19
from cStringIO import StringIO
20
 
from doctest import ELLIPSIS
21
20
import os
22
21
import signal
23
22
import sys
25
24
import unittest
26
25
import warnings
27
26
 
28
 
from testtools import MultiTestResult
29
 
from testtools.content_type import ContentType
30
 
from testtools.matchers import (
31
 
    DocTestMatches,
32
 
    Equals,
33
 
    )
34
 
import testtools.tests.helpers
35
 
 
36
27
import bzrlib
37
28
from bzrlib import (
38
29
    branchbuilder,
61
52
    deprecated_method,
62
53
    )
63
54
from bzrlib.tests import (
64
 
    features,
 
55
    SubUnitFeature,
65
56
    test_lsprof,
66
57
    test_sftp_transport,
67
58
    TestUtil,
87
78
                          TestUtil._load_module_by_name,
88
79
                          'bzrlib.no-name-yet')
89
80
 
90
 
 
91
81
class MetaTestLog(tests.TestCase):
92
82
 
93
83
    def test_logging(self):
94
84
        """Test logs are captured when a test fails."""
95
85
        self.log('a test message')
96
 
        details = self.getDetails()
97
 
        log = details['log']
98
 
        self.assertThat(log.content_type, Equals(ContentType(
99
 
            "text", "plain", {"charset": "utf8"})))
100
 
        self.assertThat(u"".join(log.iter_text()), Equals(self.get_log()))
101
 
        self.assertThat(self.get_log(),
102
 
            DocTestMatches(u"...a test message\n", ELLIPSIS))
 
86
        self._log_file.flush()
 
87
        self.assertContainsRe(self._get_log(keep_log_file=True),
 
88
                              'a test message\n')
103
89
 
104
90
 
105
91
class TestUnicodeFilename(tests.TestCase):
504
490
        self.assertEqualStat(real, fake)
505
491
 
506
492
    def test_assertEqualStat_notequal(self):
507
 
        self.build_tree(["foo", "longname"])
 
493
        self.build_tree(["foo", "bar"])
508
494
        self.assertRaises(AssertionError, self.assertEqualStat,
509
 
            os.lstat("foo"), os.lstat("longname"))
 
495
            os.lstat("foo"), os.lstat("bar"))
510
496
 
511
497
 
512
498
class TestTestCaseWithMemoryTransport(tests.TestCaseWithMemoryTransport):
530
516
        cwd = osutils.getcwd()
531
517
        self.assertIsSameRealPath(self.test_dir, cwd)
532
518
 
533
 
    def test_BZR_HOME_and_HOME_are_bytestrings(self):
534
 
        """The $BZR_HOME and $HOME environment variables should not be unicode.
535
 
 
536
 
        See https://bugs.launchpad.net/bzr/+bug/464174
537
 
        """
538
 
        self.assertIsInstance(os.environ['BZR_HOME'], str)
539
 
        self.assertIsInstance(os.environ['HOME'], str)
540
 
 
541
519
    def test_make_branch_and_memory_tree(self):
542
520
        """In TestCaseWithMemoryTransport we should not make the branch on disk.
543
521
 
701
679
 
702
680
    def test_profiles_tests(self):
703
681
        self.requireFeature(test_lsprof.LSProfFeature)
704
 
        terminal = testtools.tests.helpers.ExtendedTestResult()
 
682
        terminal = unittest.TestResult()
705
683
        result = tests.ProfileResult(terminal)
706
684
        class Sample(tests.TestCase):
707
685
            def a(self):
709
687
            def sample_function(self):
710
688
                pass
711
689
        test = Sample("a")
 
690
        test.attrs_to_keep = test.attrs_to_keep + ('_benchcalls',)
712
691
        test.run(result)
713
 
        case = terminal._events[0][1]
714
 
        self.assertLength(1, case._benchcalls)
 
692
        self.assertLength(1, test._benchcalls)
715
693
        # We must be able to unpack it as the test reporting code wants
716
 
        (_, _, _), stats = case._benchcalls[0]
 
694
        (_, _, _), stats = test._benchcalls[0]
717
695
        self.assertTrue(callable(stats.pprint))
718
696
 
719
697
 
724
702
                descriptions=0,
725
703
                verbosity=1,
726
704
                )
727
 
        capture = testtools.tests.helpers.ExtendedTestResult()
728
 
        test_case.run(MultiTestResult(result, capture))
729
 
        run_case = capture._events[0][1]
730
 
        timed_string = result._testTimeString(run_case)
 
705
        test_case.run(result)
 
706
        timed_string = result._testTimeString(test_case)
731
707
        self.assertContainsRe(timed_string, expected_re)
732
708
 
733
709
    def test_test_reporting(self):
848
824
            def stopTestRun(self): pass
849
825
            def startTests(self): pass
850
826
            def report_test_start(self, test): pass
851
 
            def report_known_failure(self, test, err=None, details=None):
852
 
                self._call = test, 'known failure'
 
827
            def report_known_failure(self, test, err):
 
828
                self._call = test, err
853
829
        result = InstrumentedTestResult(None, None, None, None)
854
 
        class Test(tests.TestCase):
855
 
            def test_function(self):
856
 
                raise tests.KnownFailure('failed!')
857
 
        test = Test("test_function")
 
830
        def test_function():
 
831
            raise tests.KnownFailure('failed!')
 
832
        test = unittest.FunctionTestCase(test_function)
858
833
        test.run(result)
859
834
        # it should invoke 'report_known_failure'.
860
835
        self.assertEqual(2, len(result._call))
861
 
        self.assertEqual(test.id(), result._call[0].id())
862
 
        self.assertEqual('known failure', result._call[1])
 
836
        self.assertEqual(test, result._call[0])
 
837
        self.assertEqual(tests.KnownFailure, result._call[1][0])
 
838
        self.assertIsInstance(result._call[1][1], tests.KnownFailure)
863
839
        # we dont introspec the traceback, if the rest is ok, it would be
864
840
        # exceptional for it not to be.
865
841
        # it should update the known_failure_count on the object.
937
913
        result.report_unsupported(test, feature)
938
914
        output = result_stream.getvalue()[prefix:]
939
915
        lines = output.splitlines()
940
 
        # We don't check for the final '0ms' since it may fail on slow hosts
941
 
        self.assertStartsWith(lines[0], 'NODEP')
942
 
        self.assertEqual(lines[1],
943
 
                         "    The feature 'Feature' is not available.")
 
916
        self.assertEqual(lines, ['NODEP        0ms',
 
917
                                 "    The feature 'Feature' is not available."])
944
918
 
945
919
    def test_unavailable_exception(self):
946
920
        """An UnavailableFeature being raised should invoke addNotSupported."""
952
926
                self._call = test, feature
953
927
        result = InstrumentedTestResult(None, None, None, None)
954
928
        feature = tests.Feature()
955
 
        class Test(tests.TestCase):
956
 
            def test_function(self):
957
 
                raise tests.UnavailableFeature(feature)
958
 
        test = Test("test_function")
 
929
        def test_function():
 
930
            raise tests.UnavailableFeature(feature)
 
931
        test = unittest.FunctionTestCase(test_function)
959
932
        test.run(result)
960
933
        # it should invoke 'addNotSupported'.
961
934
        self.assertEqual(2, len(result._call))
962
 
        self.assertEqual(test.id(), result._call[0].id())
 
935
        self.assertEqual(test, result._call[0])
963
936
        self.assertEqual(feature, result._call[1])
964
937
        # and not count as an error
965
938
        self.assertEqual(0, result.error_count)
978
951
                                             verbosity=1)
979
952
        test = self.get_passing_test()
980
953
        err = (tests.KnownFailure, tests.KnownFailure('foo'), None)
981
 
        result.addExpectedFailure(test, err)
 
954
        result._addKnownFailure(test, err)
982
955
        self.assertFalse(result.wasStrictlySuccessful())
983
956
        self.assertEqual(None, result._extractBenchmarkTime(test))
984
957
 
1041
1014
    def test_known_failure_failed_run(self):
1042
1015
        # run a test that generates a known failure which should be printed in
1043
1016
        # the final output when real failures occur.
1044
 
        class Test(tests.TestCase):
1045
 
            def known_failure_test(self):
1046
 
                self.expectFailure('failed', self.assertTrue, False)
 
1017
        def known_failure_test():
 
1018
            raise tests.KnownFailure('failed')
1047
1019
        test = unittest.TestSuite()
1048
 
        test.addTest(Test("known_failure_test"))
 
1020
        test.addTest(unittest.FunctionTestCase(known_failure_test))
1049
1021
        def failing_test():
1050
 
            self.fail('foo')
 
1022
            raise AssertionError('foo')
1051
1023
        test.addTest(unittest.FunctionTestCase(failing_test))
1052
1024
        stream = StringIO()
1053
1025
        runner = tests.TextTestRunner(stream=stream)
1054
1026
        result = self.run_test_runner(runner, test)
1055
1027
        lines = stream.getvalue().splitlines()
1056
1028
        self.assertContainsRe(stream.getvalue(),
1057
 
            '(?sm)^bzr selftest.*$'
 
1029
            '(?sm)^testing.*$'
1058
1030
            '.*'
1059
1031
            '^======================================================================\n'
1060
1032
            '^FAIL: unittest.FunctionTestCase \\(failing_test\\)\n'
1061
1033
            '^----------------------------------------------------------------------\n'
1062
1034
            'Traceback \\(most recent call last\\):\n'
1063
1035
            '  .*' # File .*, line .*, in failing_test' - but maybe not from .pyc
1064
 
            '    self.fail\\(\'foo\'\\)\n'
 
1036
            '    raise AssertionError\\(\'foo\'\\)\n'
1065
1037
            '.*'
1066
1038
            '^----------------------------------------------------------------------\n'
1067
1039
            '.*'
1069
1041
            )
1070
1042
 
1071
1043
    def test_known_failure_ok_run(self):
1072
 
        # run a test that generates a known failure which should be printed in
1073
 
        # the final output.
1074
 
        class Test(tests.TestCase):
1075
 
            def known_failure_test(self):
1076
 
                self.expectFailure('failed', self.assertTrue, False)
1077
 
        test = Test("known_failure_test")
 
1044
        # run a test that generates a known failure which should be printed in the final output.
 
1045
        def known_failure_test():
 
1046
            raise tests.KnownFailure('failed')
 
1047
        test = unittest.FunctionTestCase(known_failure_test)
1078
1048
        stream = StringIO()
1079
1049
        runner = tests.TextTestRunner(stream=stream)
1080
1050
        result = self.run_test_runner(runner, test)
1157
1127
 
1158
1128
    def test_not_applicable(self):
1159
1129
        # run a test that is skipped because it's not applicable
1160
 
        class Test(tests.TestCase):
1161
 
            def not_applicable_test(self):
1162
 
                raise tests.TestNotApplicable('this test never runs')
 
1130
        def not_applicable_test():
 
1131
            raise tests.TestNotApplicable('this test never runs')
1163
1132
        out = StringIO()
1164
1133
        runner = tests.TextTestRunner(stream=out, verbosity=2)
1165
 
        test = Test("not_applicable_test")
 
1134
        test = unittest.FunctionTestCase(not_applicable_test)
1166
1135
        result = self.run_test_runner(runner, test)
1167
1136
        self._log_file.write(out.getvalue())
1168
1137
        self.assertTrue(result.wasSuccessful())
1224
1193
        self.assertContainsRe(output_string, "--date [0-9.]+")
1225
1194
        self.assertLength(1, self._get_source_tree_calls)
1226
1195
 
 
1196
    def assertLogDeleted(self, test):
 
1197
        log = test._get_log()
 
1198
        self.assertEqual("DELETED log file to reduce memory footprint", log)
 
1199
        self.assertEqual('', test._log_contents)
 
1200
        self.assertIs(None, test._log_file_name)
 
1201
 
 
1202
    def test_success_log_deleted(self):
 
1203
        """Successful tests have their log deleted"""
 
1204
 
 
1205
        class LogTester(tests.TestCase):
 
1206
 
 
1207
            def test_success(self):
 
1208
                self.log('this will be removed\n')
 
1209
 
 
1210
        sio = StringIO()
 
1211
        runner = tests.TextTestRunner(stream=sio)
 
1212
        test = LogTester('test_success')
 
1213
        result = self.run_test_runner(runner, test)
 
1214
 
 
1215
        self.assertLogDeleted(test)
 
1216
 
 
1217
    def test_skipped_log_deleted(self):
 
1218
        """Skipped tests have their log deleted"""
 
1219
 
 
1220
        class LogTester(tests.TestCase):
 
1221
 
 
1222
            def test_skipped(self):
 
1223
                self.log('this will be removed\n')
 
1224
                raise tests.TestSkipped()
 
1225
 
 
1226
        sio = StringIO()
 
1227
        runner = tests.TextTestRunner(stream=sio)
 
1228
        test = LogTester('test_skipped')
 
1229
        result = self.run_test_runner(runner, test)
 
1230
 
 
1231
        self.assertLogDeleted(test)
 
1232
 
 
1233
    def test_not_aplicable_log_deleted(self):
 
1234
        """Not applicable tests have their log deleted"""
 
1235
 
 
1236
        class LogTester(tests.TestCase):
 
1237
 
 
1238
            def test_not_applicable(self):
 
1239
                self.log('this will be removed\n')
 
1240
                raise tests.TestNotApplicable()
 
1241
 
 
1242
        sio = StringIO()
 
1243
        runner = tests.TextTestRunner(stream=sio)
 
1244
        test = LogTester('test_not_applicable')
 
1245
        result = self.run_test_runner(runner, test)
 
1246
 
 
1247
        self.assertLogDeleted(test)
 
1248
 
 
1249
    def test_known_failure_log_deleted(self):
 
1250
        """Know failure tests have their log deleted"""
 
1251
 
 
1252
        class LogTester(tests.TestCase):
 
1253
 
 
1254
            def test_known_failure(self):
 
1255
                self.log('this will be removed\n')
 
1256
                raise tests.KnownFailure()
 
1257
 
 
1258
        sio = StringIO()
 
1259
        runner = tests.TextTestRunner(stream=sio)
 
1260
        test = LogTester('test_known_failure')
 
1261
        result = self.run_test_runner(runner, test)
 
1262
 
 
1263
        self.assertLogDeleted(test)
 
1264
 
 
1265
    def test_fail_log_kept(self):
 
1266
        """Failed tests have their log kept"""
 
1267
 
 
1268
        class LogTester(tests.TestCase):
 
1269
 
 
1270
            def test_fail(self):
 
1271
                self.log('this will be kept\n')
 
1272
                self.fail('this test fails')
 
1273
 
 
1274
        sio = StringIO()
 
1275
        runner = tests.TextTestRunner(stream=sio)
 
1276
        test = LogTester('test_fail')
 
1277
        result = self.run_test_runner(runner, test)
 
1278
 
 
1279
        text = sio.getvalue()
 
1280
        self.assertContainsRe(text, 'this will be kept')
 
1281
        self.assertContainsRe(text, 'this test fails')
 
1282
 
 
1283
        log = test._get_log()
 
1284
        self.assertContainsRe(log, 'this will be kept')
 
1285
        self.assertEqual(log, test._log_contents)
 
1286
 
 
1287
    def test_error_log_kept(self):
 
1288
        """Tests with errors have their log kept"""
 
1289
 
 
1290
        class LogTester(tests.TestCase):
 
1291
 
 
1292
            def test_error(self):
 
1293
                self.log('this will be kept\n')
 
1294
                raise ValueError('random exception raised')
 
1295
 
 
1296
        sio = StringIO()
 
1297
        runner = tests.TextTestRunner(stream=sio)
 
1298
        test = LogTester('test_error')
 
1299
        result = self.run_test_runner(runner, test)
 
1300
 
 
1301
        text = sio.getvalue()
 
1302
        self.assertContainsRe(text, 'this will be kept')
 
1303
        self.assertContainsRe(text, 'random exception raised')
 
1304
 
 
1305
        log = test._get_log()
 
1306
        self.assertContainsRe(log, 'this will be kept')
 
1307
        self.assertEqual(log, test._log_contents)
 
1308
 
1227
1309
    def test_startTestRun(self):
1228
1310
        """run should call result.startTestRun()"""
1229
1311
        calls = []
1393
1475
        self.assertEqual(set(['original-state']), bzrlib.debug.debug_flags)
1394
1476
 
1395
1477
    def make_test_result(self):
1396
 
        """Get a test result that writes to the test log file."""
1397
1478
        return tests.TextTestResult(self._log_file, descriptions=0, verbosity=1)
1398
1479
 
1399
1480
    def inner_test(self):
1407
1488
        result = self.make_test_result()
1408
1489
        self.inner_test.run(result)
1409
1490
        note("outer finish")
1410
 
        self.addCleanup(osutils.delete_any, self._log_file_name)
1411
1491
 
1412
1492
    def test_trace_nesting(self):
1413
1493
        # this tests that each test case nests its trace facility correctly.
1425
1505
        outer_test = TestTestCase("outer_child")
1426
1506
        result = self.make_test_result()
1427
1507
        outer_test.run(result)
 
1508
        self.addCleanup(osutils.delete_any, outer_test._log_file_name)
1428
1509
        self.assertEqual(original_trace, bzrlib.trace._trace_file)
1429
1510
 
1430
1511
    def method_that_times_a_bit_twice(self):
1485
1566
        # Manually set one up (TestCase doesn't and shouldn't provide magic
1486
1567
        # machinery)
1487
1568
        transport_server = MemoryServer()
1488
 
        transport_server.start_server()
1489
 
        self.addCleanup(transport_server.stop_server)
 
1569
        transport_server.setUp()
 
1570
        self.addCleanup(transport_server.tearDown)
1490
1571
        t = transport.get_transport(transport_server.get_url())
1491
1572
        bzrdir.BzrDir.create(t.base)
1492
1573
        self.assertRaises(errors.BzrError,
1545
1626
        """Test disabled tests behaviour with support aware results."""
1546
1627
        test = SampleTestCase('_test_pass')
1547
1628
        class DisabledFeature(object):
1548
 
            def __eq__(self, other):
1549
 
                return isinstance(other, DisabledFeature)
1550
1629
            def available(self):
1551
1630
                return False
1552
1631
        the_feature = DisabledFeature()
1563
1642
                self.calls.append(('addNotSupported', test, feature))
1564
1643
        result = InstrumentedTestResult()
1565
1644
        test.run(result)
1566
 
        case = result.calls[0][1]
1567
1645
        self.assertEqual([
1568
 
            ('startTest', case),
1569
 
            ('addNotSupported', case, the_feature),
1570
 
            ('stopTest', case),
 
1646
            ('startTest', test),
 
1647
            ('addNotSupported', test, the_feature),
 
1648
            ('stopTest', test),
1571
1649
            ],
1572
1650
            result.calls)
1573
1651
 
1888
1966
        self.assertEqual(expected.getvalue(), repeated.getvalue())
1889
1967
 
1890
1968
    def test_runner_class(self):
1891
 
        self.requireFeature(features.subunit)
 
1969
        self.requireFeature(SubUnitFeature)
1892
1970
        from subunit import ProtocolTestCase
1893
1971
        stream = self.run_selftest(runner_class=tests.SubUnitBzrRunner,
1894
1972
            test_suite_factory=self.factory)
1926
2004
        self.assertEqual(transport_server, captured_transport[0])
1927
2005
 
1928
2006
    def test_transport_sftp(self):
1929
 
        self.requireFeature(features.paramiko)
 
2007
        try:
 
2008
            import bzrlib.transport.sftp
 
2009
        except errors.ParamikoNotPresent:
 
2010
            raise tests.TestSkipped("Paramiko not present")
1930
2011
        self.check_transport_set(bzrlib.transport.sftp.SFTPAbsoluteServer)
1931
2012
 
1932
2013
    def test_transport_memory(self):
2337
2418
        self.assertEqual('bzr: interrupted\n', result[1])
2338
2419
 
2339
2420
 
 
2421
class TestKnownFailure(tests.TestCase):
 
2422
 
 
2423
    def test_known_failure(self):
 
2424
        """Check that KnownFailure is defined appropriately."""
 
2425
        # a KnownFailure is an assertion error for compatability with unaware
 
2426
        # runners.
 
2427
        self.assertIsInstance(tests.KnownFailure(""), AssertionError)
 
2428
 
 
2429
    def test_expect_failure(self):
 
2430
        try:
 
2431
            self.expectFailure("Doomed to failure", self.assertTrue, False)
 
2432
        except tests.KnownFailure, e:
 
2433
            self.assertEqual('Doomed to failure', e.args[0])
 
2434
        try:
 
2435
            self.expectFailure("Doomed to failure", self.assertTrue, True)
 
2436
        except AssertionError, e:
 
2437
            self.assertEqual('Unexpected success.  Should have failed:'
 
2438
                             ' Doomed to failure', e.args[0])
 
2439
        else:
 
2440
            self.fail('Assertion not raised')
 
2441
 
 
2442
 
2340
2443
class TestFeature(tests.TestCase):
2341
2444
 
2342
2445
    def test_caching(self):
2378
2481
        self.assertIs(feature, exception.args[0])
2379
2482
 
2380
2483
 
2381
 
simple_thunk_feature = tests._CompatabilityThunkFeature(
2382
 
    'bzrlib.tests', 'UnicodeFilename',
2383
 
    'bzrlib.tests.test_selftest.simple_thunk_feature',
2384
 
    deprecated_in((2,1,0)))
2385
 
 
2386
 
class Test_CompatibilityFeature(tests.TestCase):
2387
 
 
2388
 
    def test_does_thunk(self):
2389
 
        res = self.callDeprecated(
2390
 
            ['bzrlib.tests.test_selftest.simple_thunk_feature was deprecated'
2391
 
             ' in version 2.1.0. Use bzrlib.tests.UnicodeFilename instead.'],
2392
 
            simple_thunk_feature.available)
2393
 
        self.assertEqual(tests.UnicodeFilename.available(), res)
2394
 
 
2395
 
        
2396
 
class TestModuleAvailableFeature(tests.TestCase):
2397
 
 
2398
 
    def test_available_module(self):
2399
 
        feature = tests.ModuleAvailableFeature('bzrlib.tests')
2400
 
        self.assertEqual('bzrlib.tests', feature.module_name)
2401
 
        self.assertEqual('bzrlib.tests', str(feature))
2402
 
        self.assertTrue(feature.available())
2403
 
        self.assertIs(tests, feature.module)
2404
 
 
2405
 
    def test_unavailable_module(self):
2406
 
        feature = tests.ModuleAvailableFeature('bzrlib.no_such_module_exists')
2407
 
        self.assertEqual('bzrlib.no_such_module_exists', str(feature))
2408
 
        self.assertFalse(feature.available())
2409
 
        self.assertIs(None, feature.module)
2410
 
 
2411
 
 
2412
2484
class TestSelftestFiltering(tests.TestCase):
2413
2485
 
2414
2486
    def setUp(self):
2593
2665
        # the test framework
2594
2666
        self.assertEquals('always fails', str(e))
2595
2667
        # check that there's no traceback in the test log
2596
 
        self.assertNotContainsRe(self.get_log(), r'Traceback')
 
2668
        self.assertNotContainsRe(self._get_log(keep_log_file=True),
 
2669
            r'Traceback')
2597
2670
 
2598
2671
    def test_run_bzr_user_error_caught(self):
2599
2672
        # Running bzr in blackbox mode, normal/expected/user errors should be
2600
2673
        # caught in the regular way and turned into an error message plus exit
2601
2674
        # code.
2602
2675
        transport_server = MemoryServer()
2603
 
        transport_server.start_server()
2604
 
        self.addCleanup(transport_server.stop_server)
 
2676
        transport_server.setUp()
 
2677
        self.addCleanup(transport_server.tearDown)
2605
2678
        url = transport_server.get_url()
2606
2679
        self.permit_url(url)
2607
2680
        out, err = self.run_bzr(["log", "%s/nonexistantpath" % url], retcode=3)
2852
2925
    def test_load_tests(self):
2853
2926
        test_list = ['bzrlib.tests.test_sampler.DemoTest.test_nothing']
2854
2927
        loader = self._create_loader(test_list)
 
2928
 
2855
2929
        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
2856
2930
        self.assertEquals(test_list, _test_ids(suite))
2857
2931
 
2858
2932
    def test_exclude_tests(self):
2859
2933
        test_list = ['bogus']
2860
2934
        loader = self._create_loader(test_list)
 
2935
 
2861
2936
        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
2862
2937
        self.assertEquals([], _test_ids(suite))
2863
2938
 
2908
2983
        tpr.register('bar', 'bbb.aaa.rrr')
2909
2984
        tpr.register('bar', 'bBB.aAA.rRR')
2910
2985
        self.assertEquals('bbb.aaa.rrr', tpr.get('bar'))
2911
 
        self.assertThat(self.get_log(),
2912
 
            DocTestMatches("...bar...bbb.aaa.rrr...BB.aAA.rRR", ELLIPSIS))
 
2986
        self.assertContainsRe(self._get_log(keep_log_file=True),
 
2987
                              r'.*bar.*bbb.aaa.rrr.*bBB.aAA.rRR')
2913
2988
 
2914
2989
    def test_get_unknown_prefix(self):
2915
2990
        tpr = self._get_registry()