~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: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
17
17
"""Tests for the test framework."""
18
18
 
19
19
from cStringIO import StringIO
 
20
from doctest import ELLIPSIS
20
21
import os
21
22
import signal
22
23
import sys
24
25
import unittest
25
26
import warnings
26
27
 
 
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
 
27
36
import bzrlib
28
37
from bzrlib import (
29
38
    branchbuilder,
52
61
    deprecated_method,
53
62
    )
54
63
from bzrlib.tests import (
55
 
    SubUnitFeature,
 
64
    features,
 
65
    stub_sftp,
56
66
    test_lsprof,
57
67
    test_sftp_transport,
58
68
    TestUtil,
78
88
                          TestUtil._load_module_by_name,
79
89
                          'bzrlib.no-name-yet')
80
90
 
 
91
 
81
92
class MetaTestLog(tests.TestCase):
82
93
 
83
94
    def test_logging(self):
84
95
        """Test logs are captured when a test fails."""
85
96
        self.log('a test message')
86
 
        self._log_file.flush()
87
 
        self.assertContainsRe(self._get_log(keep_log_file=True),
88
 
                              'a test message\n')
 
97
        details = self.getDetails()
 
98
        log = details['log']
 
99
        self.assertThat(log.content_type, Equals(ContentType(
 
100
            "text", "plain", {"charset": "utf8"})))
 
101
        self.assertThat(u"".join(log.iter_text()), Equals(self.get_log()))
 
102
        self.assertThat(self.get_log(),
 
103
            DocTestMatches(u"...a test message\n", ELLIPSIS))
89
104
 
90
105
 
91
106
class TestUnicodeFilename(tests.TestCase):
490
505
        self.assertEqualStat(real, fake)
491
506
 
492
507
    def test_assertEqualStat_notequal(self):
493
 
        self.build_tree(["foo", "bar"])
 
508
        self.build_tree(["foo", "longname"])
494
509
        self.assertRaises(AssertionError, self.assertEqualStat,
495
 
            os.lstat("foo"), os.lstat("bar"))
 
510
            os.lstat("foo"), os.lstat("longname"))
496
511
 
497
512
 
498
513
class TestTestCaseWithMemoryTransport(tests.TestCaseWithMemoryTransport):
516
531
        cwd = osutils.getcwd()
517
532
        self.assertIsSameRealPath(self.test_dir, cwd)
518
533
 
 
534
    def test_BZR_HOME_and_HOME_are_bytestrings(self):
 
535
        """The $BZR_HOME and $HOME environment variables should not be unicode.
 
536
 
 
537
        See https://bugs.launchpad.net/bzr/+bug/464174
 
538
        """
 
539
        self.assertIsInstance(os.environ['BZR_HOME'], str)
 
540
        self.assertIsInstance(os.environ['HOME'], str)
 
541
 
519
542
    def test_make_branch_and_memory_tree(self):
520
543
        """In TestCaseWithMemoryTransport we should not make the branch on disk.
521
544
 
679
702
 
680
703
    def test_profiles_tests(self):
681
704
        self.requireFeature(test_lsprof.LSProfFeature)
682
 
        terminal = unittest.TestResult()
 
705
        terminal = testtools.tests.helpers.ExtendedTestResult()
683
706
        result = tests.ProfileResult(terminal)
684
707
        class Sample(tests.TestCase):
685
708
            def a(self):
687
710
            def sample_function(self):
688
711
                pass
689
712
        test = Sample("a")
690
 
        test.attrs_to_keep = test.attrs_to_keep + ('_benchcalls',)
691
713
        test.run(result)
692
 
        self.assertLength(1, test._benchcalls)
 
714
        case = terminal._events[0][1]
 
715
        self.assertLength(1, case._benchcalls)
693
716
        # We must be able to unpack it as the test reporting code wants
694
 
        (_, _, _), stats = test._benchcalls[0]
 
717
        (_, _, _), stats = case._benchcalls[0]
695
718
        self.assertTrue(callable(stats.pprint))
696
719
 
697
720
 
702
725
                descriptions=0,
703
726
                verbosity=1,
704
727
                )
705
 
        test_case.run(result)
706
 
        timed_string = result._testTimeString(test_case)
 
728
        capture = testtools.tests.helpers.ExtendedTestResult()
 
729
        test_case.run(MultiTestResult(result, capture))
 
730
        run_case = capture._events[0][1]
 
731
        timed_string = result._testTimeString(run_case)
707
732
        self.assertContainsRe(timed_string, expected_re)
708
733
 
709
734
    def test_test_reporting(self):
824
849
            def stopTestRun(self): pass
825
850
            def startTests(self): pass
826
851
            def report_test_start(self, test): pass
827
 
            def report_known_failure(self, test, err):
828
 
                self._call = test, err
 
852
            def report_known_failure(self, test, err=None, details=None):
 
853
                self._call = test, 'known failure'
829
854
        result = InstrumentedTestResult(None, None, None, None)
830
 
        def test_function():
831
 
            raise tests.KnownFailure('failed!')
832
 
        test = unittest.FunctionTestCase(test_function)
 
855
        class Test(tests.TestCase):
 
856
            def test_function(self):
 
857
                raise tests.KnownFailure('failed!')
 
858
        test = Test("test_function")
833
859
        test.run(result)
834
860
        # it should invoke 'report_known_failure'.
835
861
        self.assertEqual(2, len(result._call))
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)
 
862
        self.assertEqual(test.id(), result._call[0].id())
 
863
        self.assertEqual('known failure', result._call[1])
839
864
        # we dont introspec the traceback, if the rest is ok, it would be
840
865
        # exceptional for it not to be.
841
866
        # it should update the known_failure_count on the object.
913
938
        result.report_unsupported(test, feature)
914
939
        output = result_stream.getvalue()[prefix:]
915
940
        lines = output.splitlines()
916
 
        self.assertEqual(lines, ['NODEP        0ms',
917
 
                                 "    The feature 'Feature' is not available."])
 
941
        # We don't check for the final '0ms' since it may fail on slow hosts
 
942
        self.assertStartsWith(lines[0], 'NODEP')
 
943
        self.assertEqual(lines[1],
 
944
                         "    The feature 'Feature' is not available.")
918
945
 
919
946
    def test_unavailable_exception(self):
920
947
        """An UnavailableFeature being raised should invoke addNotSupported."""
926
953
                self._call = test, feature
927
954
        result = InstrumentedTestResult(None, None, None, None)
928
955
        feature = tests.Feature()
929
 
        def test_function():
930
 
            raise tests.UnavailableFeature(feature)
931
 
        test = unittest.FunctionTestCase(test_function)
 
956
        class Test(tests.TestCase):
 
957
            def test_function(self):
 
958
                raise tests.UnavailableFeature(feature)
 
959
        test = Test("test_function")
932
960
        test.run(result)
933
961
        # it should invoke 'addNotSupported'.
934
962
        self.assertEqual(2, len(result._call))
935
 
        self.assertEqual(test, result._call[0])
 
963
        self.assertEqual(test.id(), result._call[0].id())
936
964
        self.assertEqual(feature, result._call[1])
937
965
        # and not count as an error
938
966
        self.assertEqual(0, result.error_count)
951
979
                                             verbosity=1)
952
980
        test = self.get_passing_test()
953
981
        err = (tests.KnownFailure, tests.KnownFailure('foo'), None)
954
 
        result._addKnownFailure(test, err)
 
982
        result.addExpectedFailure(test, err)
955
983
        self.assertFalse(result.wasStrictlySuccessful())
956
984
        self.assertEqual(None, result._extractBenchmarkTime(test))
957
985
 
1014
1042
    def test_known_failure_failed_run(self):
1015
1043
        # run a test that generates a known failure which should be printed in
1016
1044
        # the final output when real failures occur.
1017
 
        def known_failure_test():
1018
 
            raise tests.KnownFailure('failed')
 
1045
        class Test(tests.TestCase):
 
1046
            def known_failure_test(self):
 
1047
                self.expectFailure('failed', self.assertTrue, False)
1019
1048
        test = unittest.TestSuite()
1020
 
        test.addTest(unittest.FunctionTestCase(known_failure_test))
 
1049
        test.addTest(Test("known_failure_test"))
1021
1050
        def failing_test():
1022
 
            raise AssertionError('foo')
 
1051
            self.fail('foo')
1023
1052
        test.addTest(unittest.FunctionTestCase(failing_test))
1024
1053
        stream = StringIO()
1025
1054
        runner = tests.TextTestRunner(stream=stream)
1026
1055
        result = self.run_test_runner(runner, test)
1027
1056
        lines = stream.getvalue().splitlines()
1028
1057
        self.assertContainsRe(stream.getvalue(),
1029
 
            '(?sm)^testing.*$'
 
1058
            '(?sm)^bzr selftest.*$'
1030
1059
            '.*'
1031
1060
            '^======================================================================\n'
1032
 
            '^FAIL: unittest.FunctionTestCase \\(failing_test\\)\n'
 
1061
            '^FAIL: failing_test\n'
1033
1062
            '^----------------------------------------------------------------------\n'
1034
1063
            'Traceback \\(most recent call last\\):\n'
1035
1064
            '  .*' # File .*, line .*, in failing_test' - but maybe not from .pyc
1036
 
            '    raise AssertionError\\(\'foo\'\\)\n'
 
1065
            '    self.fail\\(\'foo\'\\)\n'
1037
1066
            '.*'
1038
1067
            '^----------------------------------------------------------------------\n'
1039
1068
            '.*'
1041
1070
            )
1042
1071
 
1043
1072
    def test_known_failure_ok_run(self):
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)
 
1073
        # run a test that generates a known failure which should be printed in
 
1074
        # the final output.
 
1075
        class Test(tests.TestCase):
 
1076
            def known_failure_test(self):
 
1077
                self.expectFailure('failed', self.assertTrue, False)
 
1078
        test = Test("known_failure_test")
1048
1079
        stream = StringIO()
1049
1080
        runner = tests.TextTestRunner(stream=stream)
1050
1081
        result = self.run_test_runner(runner, test)
1127
1158
 
1128
1159
    def test_not_applicable(self):
1129
1160
        # run a test that is skipped because it's not applicable
1130
 
        def not_applicable_test():
1131
 
            raise tests.TestNotApplicable('this test never runs')
 
1161
        class Test(tests.TestCase):
 
1162
            def not_applicable_test(self):
 
1163
                raise tests.TestNotApplicable('this test never runs')
1132
1164
        out = StringIO()
1133
1165
        runner = tests.TextTestRunner(stream=out, verbosity=2)
1134
 
        test = unittest.FunctionTestCase(not_applicable_test)
 
1166
        test = Test("not_applicable_test")
1135
1167
        result = self.run_test_runner(runner, test)
1136
1168
        self._log_file.write(out.getvalue())
1137
1169
        self.assertTrue(result.wasSuccessful())
1193
1225
        self.assertContainsRe(output_string, "--date [0-9.]+")
1194
1226
        self.assertLength(1, self._get_source_tree_calls)
1195
1227
 
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
 
 
1309
1228
    def test_startTestRun(self):
1310
1229
        """run should call result.startTestRun()"""
1311
1230
        calls = []
1475
1394
        self.assertEqual(set(['original-state']), bzrlib.debug.debug_flags)
1476
1395
 
1477
1396
    def make_test_result(self):
 
1397
        """Get a test result that writes to the test log file."""
1478
1398
        return tests.TextTestResult(self._log_file, descriptions=0, verbosity=1)
1479
1399
 
1480
1400
    def inner_test(self):
1488
1408
        result = self.make_test_result()
1489
1409
        self.inner_test.run(result)
1490
1410
        note("outer finish")
 
1411
        self.addCleanup(osutils.delete_any, self._log_file_name)
1491
1412
 
1492
1413
    def test_trace_nesting(self):
1493
1414
        # this tests that each test case nests its trace facility correctly.
1505
1426
        outer_test = TestTestCase("outer_child")
1506
1427
        result = self.make_test_result()
1507
1428
        outer_test.run(result)
1508
 
        self.addCleanup(osutils.delete_any, outer_test._log_file_name)
1509
1429
        self.assertEqual(original_trace, bzrlib.trace._trace_file)
1510
1430
 
1511
1431
    def method_that_times_a_bit_twice(self):
1566
1486
        # Manually set one up (TestCase doesn't and shouldn't provide magic
1567
1487
        # machinery)
1568
1488
        transport_server = MemoryServer()
1569
 
        transport_server.setUp()
1570
 
        self.addCleanup(transport_server.tearDown)
 
1489
        transport_server.start_server()
 
1490
        self.addCleanup(transport_server.stop_server)
1571
1491
        t = transport.get_transport(transport_server.get_url())
1572
1492
        bzrdir.BzrDir.create(t.base)
1573
1493
        self.assertRaises(errors.BzrError,
1626
1546
        """Test disabled tests behaviour with support aware results."""
1627
1547
        test = SampleTestCase('_test_pass')
1628
1548
        class DisabledFeature(object):
 
1549
            def __eq__(self, other):
 
1550
                return isinstance(other, DisabledFeature)
1629
1551
            def available(self):
1630
1552
                return False
1631
1553
        the_feature = DisabledFeature()
1642
1564
                self.calls.append(('addNotSupported', test, feature))
1643
1565
        result = InstrumentedTestResult()
1644
1566
        test.run(result)
 
1567
        case = result.calls[0][1]
1645
1568
        self.assertEqual([
1646
 
            ('startTest', test),
1647
 
            ('addNotSupported', test, the_feature),
1648
 
            ('stopTest', test),
 
1569
            ('startTest', case),
 
1570
            ('addNotSupported', case, the_feature),
 
1571
            ('stopTest', case),
1649
1572
            ],
1650
1573
            result.calls)
1651
1574
 
1966
1889
        self.assertEqual(expected.getvalue(), repeated.getvalue())
1967
1890
 
1968
1891
    def test_runner_class(self):
1969
 
        self.requireFeature(SubUnitFeature)
 
1892
        self.requireFeature(features.subunit)
1970
1893
        from subunit import ProtocolTestCase
1971
1894
        stream = self.run_selftest(runner_class=tests.SubUnitBzrRunner,
1972
1895
            test_suite_factory=self.factory)
2004
1927
        self.assertEqual(transport_server, captured_transport[0])
2005
1928
 
2006
1929
    def test_transport_sftp(self):
2007
 
        try:
2008
 
            import bzrlib.transport.sftp
2009
 
        except errors.ParamikoNotPresent:
2010
 
            raise tests.TestSkipped("Paramiko not present")
2011
 
        self.check_transport_set(bzrlib.transport.sftp.SFTPAbsoluteServer)
 
1930
        self.requireFeature(features.paramiko)
 
1931
        self.check_transport_set(stub_sftp.SFTPAbsoluteServer)
2012
1932
 
2013
1933
    def test_transport_memory(self):
2014
1934
        self.check_transport_set(bzrlib.transport.memory.MemoryServer)
2418
2338
        self.assertEqual('bzr: interrupted\n', result[1])
2419
2339
 
2420
2340
 
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
 
 
2443
2341
class TestFeature(tests.TestCase):
2444
2342
 
2445
2343
    def test_caching(self):
2481
2379
        self.assertIs(feature, exception.args[0])
2482
2380
 
2483
2381
 
 
2382
simple_thunk_feature = tests._CompatabilityThunkFeature(
 
2383
    'bzrlib.tests', 'UnicodeFilename',
 
2384
    'bzrlib.tests.test_selftest.simple_thunk_feature',
 
2385
    deprecated_in((2,1,0)))
 
2386
 
 
2387
class Test_CompatibilityFeature(tests.TestCase):
 
2388
 
 
2389
    def test_does_thunk(self):
 
2390
        res = self.callDeprecated(
 
2391
            ['bzrlib.tests.test_selftest.simple_thunk_feature was deprecated'
 
2392
             ' in version 2.1.0. Use bzrlib.tests.UnicodeFilename instead.'],
 
2393
            simple_thunk_feature.available)
 
2394
        self.assertEqual(tests.UnicodeFilename.available(), res)
 
2395
 
 
2396
        
 
2397
class TestModuleAvailableFeature(tests.TestCase):
 
2398
 
 
2399
    def test_available_module(self):
 
2400
        feature = tests.ModuleAvailableFeature('bzrlib.tests')
 
2401
        self.assertEqual('bzrlib.tests', feature.module_name)
 
2402
        self.assertEqual('bzrlib.tests', str(feature))
 
2403
        self.assertTrue(feature.available())
 
2404
        self.assertIs(tests, feature.module)
 
2405
 
 
2406
    def test_unavailable_module(self):
 
2407
        feature = tests.ModuleAvailableFeature('bzrlib.no_such_module_exists')
 
2408
        self.assertEqual('bzrlib.no_such_module_exists', str(feature))
 
2409
        self.assertFalse(feature.available())
 
2410
        self.assertIs(None, feature.module)
 
2411
 
 
2412
 
2484
2413
class TestSelftestFiltering(tests.TestCase):
2485
2414
 
2486
2415
    def setUp(self):
2665
2594
        # the test framework
2666
2595
        self.assertEquals('always fails', str(e))
2667
2596
        # check that there's no traceback in the test log
2668
 
        self.assertNotContainsRe(self._get_log(keep_log_file=True),
2669
 
            r'Traceback')
 
2597
        self.assertNotContainsRe(self.get_log(), r'Traceback')
2670
2598
 
2671
2599
    def test_run_bzr_user_error_caught(self):
2672
2600
        # Running bzr in blackbox mode, normal/expected/user errors should be
2673
2601
        # caught in the regular way and turned into an error message plus exit
2674
2602
        # code.
2675
2603
        transport_server = MemoryServer()
2676
 
        transport_server.setUp()
2677
 
        self.addCleanup(transport_server.tearDown)
 
2604
        transport_server.start_server()
 
2605
        self.addCleanup(transport_server.stop_server)
2678
2606
        url = transport_server.get_url()
2679
2607
        self.permit_url(url)
2680
2608
        out, err = self.run_bzr(["log", "%s/nonexistantpath" % url], retcode=3)
2925
2853
    def test_load_tests(self):
2926
2854
        test_list = ['bzrlib.tests.test_sampler.DemoTest.test_nothing']
2927
2855
        loader = self._create_loader(test_list)
2928
 
 
2929
2856
        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
2930
2857
        self.assertEquals(test_list, _test_ids(suite))
2931
2858
 
2932
2859
    def test_exclude_tests(self):
2933
2860
        test_list = ['bogus']
2934
2861
        loader = self._create_loader(test_list)
2935
 
 
2936
2862
        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
2937
2863
        self.assertEquals([], _test_ids(suite))
2938
2864
 
2983
2909
        tpr.register('bar', 'bbb.aaa.rrr')
2984
2910
        tpr.register('bar', 'bBB.aAA.rRR')
2985
2911
        self.assertEquals('bbb.aaa.rrr', tpr.get('bar'))
2986
 
        self.assertContainsRe(self._get_log(keep_log_file=True),
2987
 
                              r'.*bar.*bbb.aaa.rrr.*bBB.aAA.rRR')
 
2912
        self.assertThat(self.get_log(),
 
2913
            DocTestMatches("...bar...bbb.aaa.rrr...BB.aAA.rRR", ELLIPSIS))
2988
2914
 
2989
2915
    def test_get_unknown_prefix(self):
2990
2916
        tpr = self._get_registry()