~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:56:05 UTC
  • mfrom: (6615.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201195605-o7rl92wf6uyum3fk
(vila) Open trunk again as 2.8b1 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2013, 2016 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
43
43
from bzrlib import (
44
44
    branchbuilder,
45
45
    bzrdir,
 
46
    controldir,
46
47
    errors,
47
48
    hooks,
48
49
    lockdir,
334
335
        server1 = "a"
335
336
        server2 = "b"
336
337
        formats = [workingtree_4.WorkingTreeFormat4(),
337
 
                   workingtree_3.WorkingTreeFormat3(),]
338
 
        scenarios = make_scenarios(server1, server2, formats)
 
338
                   workingtree_3.WorkingTreeFormat3(),
 
339
                   workingtree_4.WorkingTreeFormat6()]
 
340
        scenarios = make_scenarios(server1, server2, formats,
 
341
            remote_server='c', remote_readonly_server='d',
 
342
            remote_backing_server='e')
339
343
        self.assertEqual([
340
344
            ('WorkingTreeFormat4',
341
345
             {'bzrdir_format': formats[0]._matchingbzrdir,
346
350
             {'bzrdir_format': formats[1]._matchingbzrdir,
347
351
              'transport_readonly_server': 'b',
348
352
              'transport_server': 'a',
349
 
              'workingtree_format': formats[1]})],
350
 
            scenarios)
 
353
              'workingtree_format': formats[1]}),
 
354
            ('WorkingTreeFormat6',
 
355
             {'bzrdir_format': formats[2]._matchingbzrdir,
 
356
              'transport_readonly_server': 'b',
 
357
              'transport_server': 'a',
 
358
              'workingtree_format': formats[2]}),
 
359
            ('WorkingTreeFormat6,remote',
 
360
             {'bzrdir_format': formats[2]._matchingbzrdir,
 
361
              'repo_is_remote': True,
 
362
              'transport_readonly_server': 'd',
 
363
              'transport_server': 'c',
 
364
              'vfs_transport_factory': 'e',
 
365
              'workingtree_format': formats[2]}),
 
366
            ], scenarios)
351
367
 
352
368
 
353
369
class TestTreeScenarios(tests.TestCase):
354
370
 
355
371
    def test_scenarios(self):
356
372
        # the tree implementation scenario generator is meant to setup one
357
 
        # instance for each working tree format, and one additional instance
 
373
        # instance for each working tree format, one additional instance
358
374
        # that will use the default wt format, but create a revision tree for
359
 
        # the tests.  this means that the wt ones should have the
360
 
        # workingtree_to_test_tree attribute set to 'return_parameter' and the
361
 
        # revision one set to revision_tree_from_workingtree.
 
375
        # the tests, and one more that uses the default wt format as a
 
376
        # lightweight checkout of a remote repository.  This means that the wt
 
377
        # ones should have the workingtree_to_test_tree attribute set to
 
378
        # 'return_parameter' and the revision one set to
 
379
        # revision_tree_from_workingtree.
362
380
 
363
381
        from bzrlib.tests.per_tree import (
364
382
            _dirstate_tree_from_workingtree,
370
388
            )
371
389
        server1 = "a"
372
390
        server2 = "b"
 
391
        smart_server = test_server.SmartTCPServer_for_testing
 
392
        smart_readonly_server = test_server.ReadonlySmartTCPServer_for_testing
 
393
        mem_server = memory.MemoryServer
373
394
        formats = [workingtree_4.WorkingTreeFormat4(),
374
395
                   workingtree_3.WorkingTreeFormat3(),]
375
396
        scenarios = make_scenarios(server1, server2, formats)
376
 
        self.assertEqual(7, len(scenarios))
 
397
        self.assertEqual(8, len(scenarios))
377
398
        default_wt_format = workingtree.format_registry.get_default()
378
399
        wt4_format = workingtree_4.WorkingTreeFormat4()
379
400
        wt5_format = workingtree_4.WorkingTreeFormat5()
 
401
        wt6_format = workingtree_4.WorkingTreeFormat6()
380
402
        expected_scenarios = [
381
403
            ('WorkingTreeFormat4',
382
404
             {'bzrdir_format': formats[0]._matchingbzrdir,
392
414
              'workingtree_format': formats[1],
393
415
              '_workingtree_to_test_tree': return_parameter,
394
416
             }),
 
417
            ('WorkingTreeFormat6,remote',
 
418
             {'bzrdir_format': wt6_format._matchingbzrdir,
 
419
              'repo_is_remote': True,
 
420
              'transport_readonly_server': smart_readonly_server,
 
421
              'transport_server': smart_server,
 
422
              'vfs_transport_factory': mem_server,
 
423
              'workingtree_format': wt6_format,
 
424
              '_workingtree_to_test_tree': return_parameter,
 
425
             }),
395
426
            ('RevisionTree',
396
427
             {'_workingtree_to_test_tree': revision_tree_from_workingtree,
397
428
              'bzrdir_format': default_wt_format._matchingbzrdir,
609
640
        # Guard against regression into MemoryTransport leaking
610
641
        # files to disk instead of keeping them in memory.
611
642
        self.assertFalse(osutils.lexists('dir'))
612
 
        dir_format = bzrdir.format_registry.make_bzrdir('knit')
 
643
        dir_format = controldir.format_registry.make_bzrdir('knit')
613
644
        self.assertEqual(dir_format.repository_format.__class__,
614
645
                         the_branch.repository._format.__class__)
615
646
        self.assertEqual('Bazaar-NG Knit Repository Format 1',
678
709
        builder = self.make_branch_builder('dir')
679
710
        rev_id = builder.build_commit()
680
711
        self.assertPathExists('dir')
681
 
        a_dir = bzrdir.BzrDir.open('dir')
 
712
        a_dir = controldir.ControlDir.open('dir')
682
713
        self.assertRaises(errors.NoWorkingTree, a_dir.open_workingtree)
683
714
        a_branch = a_dir.open_branch()
684
715
        builder_branch = builder.get_branch()
971
1002
            pass
972
1003
        test = unittest.FunctionTestCase(test_function)
973
1004
        test.run(result)
974
 
        self.assertEquals(1, result.calls)
 
1005
        self.assertEqual(1, result.calls)
975
1006
 
976
1007
    def test_startTests_only_once(self):
977
1008
        """With multiple tests startTests should still only be called once"""
983
1014
            unittest.FunctionTestCase(lambda: None),
984
1015
            unittest.FunctionTestCase(lambda: None)])
985
1016
        suite.run(result)
986
 
        self.assertEquals(1, result.calls)
987
 
        self.assertEquals(2, result.count)
 
1017
        self.assertEqual(1, result.calls)
 
1018
        self.assertEqual(2, result.count)
988
1019
 
989
1020
 
990
1021
class TestRunner(tests.TestCase):
1130
1161
        class SkippedTest(tests.TestCase):
1131
1162
 
1132
1163
            def setUp(self):
1133
 
                tests.TestCase.setUp(self)
 
1164
                super(SkippedTest, self).setUp()
1134
1165
                calls.append('setUp')
1135
1166
                self.addCleanup(self.cleanup)
1136
1167
 
1477
1508
        transport_server.start_server()
1478
1509
        self.addCleanup(transport_server.stop_server)
1479
1510
        t = transport.get_transport_from_url(transport_server.get_url())
1480
 
        bzrdir.BzrDir.create(t.base)
 
1511
        controldir.ControlDir.create(t.base)
1481
1512
        self.assertRaises(errors.BzrError,
1482
 
            bzrdir.BzrDir.open_from_transport, t)
 
1513
            controldir.ControlDir.open_from_transport, t)
1483
1514
        # But if we declare this as safe, we can open the bzrdir.
1484
1515
        self.permit_url(t.base)
1485
1516
        self._bzr_selftest_roots.append(t.base)
1486
 
        bzrdir.BzrDir.open_from_transport(t)
 
1517
        controldir.ControlDir.open_from_transport(t)
1487
1518
 
1488
1519
    def test_requireFeature_available(self):
1489
1520
        """self.requireFeature(available) is a no-op."""
1623
1654
        self.assertRaises(AssertionError,
1624
1655
            self.assertListRaises, _TestException, success_generator)
1625
1656
 
 
1657
    def _run_successful_test(self, test):
 
1658
        result = testtools.TestResult()
 
1659
        test.run(result)
 
1660
        self.assertTrue(result.wasSuccessful())
 
1661
        return result
 
1662
 
1626
1663
    def test_overrideAttr_without_value(self):
1627
1664
        self.test_attr = 'original' # Define a test attribute
1628
1665
        obj = self # Make 'obj' visible to the embedded test
1629
1666
        class Test(tests.TestCase):
1630
1667
 
1631
1668
            def setUp(self):
1632
 
                tests.TestCase.setUp(self)
 
1669
                super(Test, self).setUp()
1633
1670
                self.orig = self.overrideAttr(obj, 'test_attr')
1634
1671
 
1635
1672
            def test_value(self):
1638
1675
                obj.test_attr = 'modified'
1639
1676
                self.assertEqual('modified', obj.test_attr)
1640
1677
 
1641
 
        test = Test('test_value')
1642
 
        test.run(unittest.TestResult())
 
1678
        self._run_successful_test(Test('test_value'))
1643
1679
        self.assertEqual('original', obj.test_attr)
1644
1680
 
1645
1681
    def test_overrideAttr_with_value(self):
1648
1684
        class Test(tests.TestCase):
1649
1685
 
1650
1686
            def setUp(self):
1651
 
                tests.TestCase.setUp(self)
 
1687
                super(Test, self).setUp()
1652
1688
                self.orig = self.overrideAttr(obj, 'test_attr', new='modified')
1653
1689
 
1654
1690
            def test_value(self):
1655
1691
                self.assertEqual('original', self.orig)
1656
1692
                self.assertEqual('modified', obj.test_attr)
1657
1693
 
1658
 
        test = Test('test_value')
1659
 
        test.run(unittest.TestResult())
 
1694
        self._run_successful_test(Test('test_value'))
1660
1695
        self.assertEqual('original', obj.test_attr)
1661
1696
 
 
1697
    def test_overrideAttr_with_no_existing_value_and_value(self):
 
1698
        # Do not define the test_attribute
 
1699
        obj = self # Make 'obj' visible to the embedded test
 
1700
        class Test(tests.TestCase):
 
1701
 
 
1702
            def setUp(self):
 
1703
                tests.TestCase.setUp(self)
 
1704
                self.orig = self.overrideAttr(obj, 'test_attr', new='modified')
 
1705
 
 
1706
            def test_value(self):
 
1707
                self.assertEqual(tests._unitialized_attr, self.orig)
 
1708
                self.assertEqual('modified', obj.test_attr)
 
1709
 
 
1710
        self._run_successful_test(Test('test_value'))
 
1711
        self.assertRaises(AttributeError, getattr, obj, 'test_attr')
 
1712
 
 
1713
    def test_overrideAttr_with_no_existing_value_and_no_value(self):
 
1714
        # Do not define the test_attribute
 
1715
        obj = self # Make 'obj' visible to the embedded test
 
1716
        class Test(tests.TestCase):
 
1717
 
 
1718
            def setUp(self):
 
1719
                tests.TestCase.setUp(self)
 
1720
                self.orig = self.overrideAttr(obj, 'test_attr')
 
1721
 
 
1722
            def test_value(self):
 
1723
                self.assertEqual(tests._unitialized_attr, self.orig)
 
1724
                self.assertRaises(AttributeError, getattr, obj, 'test_attr')
 
1725
 
 
1726
        self._run_successful_test(Test('test_value'))
 
1727
        self.assertRaises(AttributeError, getattr, obj, 'test_attr')
 
1728
 
1662
1729
    def test_recordCalls(self):
1663
1730
        from bzrlib.tests import test_selftest
1664
1731
        calls = self.recordCalls(
1665
1732
            test_selftest, '_add_numbers')
1666
1733
        self.assertEqual(test_selftest._add_numbers(2, 10),
1667
1734
            12)
1668
 
        self.assertEquals(calls, [((2, 10), {})])
 
1735
        self.assertEqual(calls, [((2, 10), {})])
1669
1736
 
1670
1737
 
1671
1738
def _add_numbers(a, b):
1845
1912
        self.assertIsInstance(2, int)
1846
1913
        self.assertIsInstance(u'', basestring)
1847
1914
        e = self.assertRaises(AssertionError, self.assertIsInstance, None, int)
1848
 
        self.assertEquals(str(e),
 
1915
        self.assertEqual(str(e),
1849
1916
            "None is an instance of <type 'NoneType'> rather than <type 'int'>")
1850
1917
        self.assertRaises(AssertionError, self.assertIsInstance, 23.3, int)
1851
1918
        e = self.assertRaises(AssertionError,
1852
1919
            self.assertIsInstance, None, int, "it's just not")
1853
 
        self.assertEquals(str(e),
 
1920
        self.assertEqual(str(e),
1854
1921
            "None is an instance of <type 'NoneType'> rather than <type 'int'>"
1855
1922
            ": it's just not")
1856
1923
 
1861
1928
    def test_assertEqualDiff(self):
1862
1929
        e = self.assertRaises(AssertionError,
1863
1930
                              self.assertEqualDiff, '', '\n')
1864
 
        self.assertEquals(str(e),
 
1931
        self.assertEqual(str(e),
1865
1932
                          # Don't blink ! The '+' applies to the second string
1866
1933
                          'first string is missing a final newline.\n+ \n')
1867
1934
        e = self.assertRaises(AssertionError,
1868
1935
                              self.assertEqualDiff, '\n', '')
1869
 
        self.assertEquals(str(e),
 
1936
        self.assertEqual(str(e),
1870
1937
                          # Don't blink ! The '-' applies to the second string
1871
1938
                          'second string is missing a final newline.\n- \n')
1872
1939
 
1929
1996
            warnings.warn("this is your last warning")
1930
1997
            return a + b
1931
1998
        wlist, result = self.callCatchWarnings(meth, 1, 2)
1932
 
        self.assertEquals(3, result)
 
1999
        self.assertEqual(3, result)
1933
2000
        # would like just to compare them, but UserWarning doesn't implement
1934
2001
        # eq well
1935
2002
        w0, = wlist
1936
2003
        self.assertIsInstance(w0, UserWarning)
1937
 
        self.assertEquals("this is your last warning", str(w0))
 
2004
        self.assertEqual("this is your last warning", str(w0))
1938
2005
 
1939
2006
 
1940
2007
class TestConvenienceMakers(tests.TestCaseWithTransport):
1943
2010
    def test_make_branch_and_tree_with_format(self):
1944
2011
        # we should be able to supply a format to make_branch_and_tree
1945
2012
        self.make_branch_and_tree('a', format=bzrlib.bzrdir.BzrDirMetaFormat1())
1946
 
        self.assertIsInstance(bzrlib.bzrdir.BzrDir.open('a')._format,
 
2013
        self.assertIsInstance(bzrlib.controldir.ControlDir.open('a')._format,
1947
2014
                              bzrlib.bzrdir.BzrDirMetaFormat1)
1948
2015
 
1949
2016
    def test_make_branch_and_memory_tree(self):
1961
2028
        tree = self.make_branch_and_tree('t1')
1962
2029
        base = tree.bzrdir.root_transport.base
1963
2030
        self.assertStartsWith(base, 'file://')
1964
 
        self.assertEquals(tree.bzrdir.root_transport,
 
2031
        self.assertEqual(tree.bzrdir.root_transport,
1965
2032
                tree.branch.bzrdir.root_transport)
1966
 
        self.assertEquals(tree.bzrdir.root_transport,
 
2033
        self.assertEqual(tree.bzrdir.root_transport,
1967
2034
                tree.branch.repository.bzrdir.root_transport)
1968
2035
 
1969
2036
 
2233
2300
        self.assertEqual(['rocks'], self.argv)
2234
2301
        self.assertEqual(34, self.retcode)
2235
2302
        self.assertEqual('It sure does!\n', out)
2236
 
        self.assertEquals(out, self.out)
 
2303
        self.assertEqual(out, self.out)
2237
2304
        self.assertEqual('', err)
2238
 
        self.assertEquals(err, self.err)
 
2305
        self.assertEqual(err, self.err)
2239
2306
 
2240
2307
    def test_run_bzr_error_regexes(self):
2241
2308
        self.out = ''
2381
2448
    """Base class for tests testing how we might run bzr."""
2382
2449
 
2383
2450
    def setUp(self):
2384
 
        tests.TestCaseWithTransport.setUp(self)
 
2451
        super(TestWithFakedStartBzrSubprocess, self).setUp()
2385
2452
        self.subprocess_calls = []
2386
2453
 
2387
2454
    def start_bzr_subprocess(self, process_args, env_changes=None,
2601
2668
class TestSelftestFiltering(tests.TestCase):
2602
2669
 
2603
2670
    def setUp(self):
2604
 
        tests.TestCase.setUp(self)
 
2671
        super(TestSelftestFiltering, self).setUp()
2605
2672
        self.suite = TestUtil.TestSuite()
2606
2673
        self.loader = TestUtil.TestLoader()
2607
2674
        self.suite.addTest(self.loader.loadTestsFromModule(
2780
2847
            self.run_bzr, ['assert-fail'])
2781
2848
        # make sure we got the real thing, not an error from somewhere else in
2782
2849
        # the test framework
2783
 
        self.assertEquals('always fails', str(e))
 
2850
        self.assertEqual('always fails', str(e))
2784
2851
        # check that there's no traceback in the test log
2785
2852
        self.assertNotContainsRe(self.get_log(), r'Traceback')
2786
2853
 
2835
2902
    def test_load_tests_from_module_name_smoke_test(self):
2836
2903
        loader = TestUtil.TestLoader()
2837
2904
        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
2838
 
        self.assertEquals(['bzrlib.tests.test_sampler.DemoTest.test_nothing'],
 
2905
        self.assertEqual(['bzrlib.tests.test_sampler.DemoTest.test_nothing'],
2839
2906
                          _test_ids(suite))
2840
2907
 
2841
2908
    def test_load_tests_from_module_name_with_bogus_module_name(self):
2870
2937
 
2871
2938
    def test_empty_list(self):
2872
2939
        id_list = self._create_id_list([])
2873
 
        self.assertEquals({}, id_list.tests)
2874
 
        self.assertEquals({}, id_list.modules)
 
2940
        self.assertEqual({}, id_list.tests)
 
2941
        self.assertEqual({}, id_list.modules)
2875
2942
 
2876
2943
    def test_valid_list(self):
2877
2944
        id_list = self._create_id_list(
2904
2971
        test_list = ['bzrlib.tests.test_sampler.DemoTest.test_nothing',
2905
2972
                     'bogus']
2906
2973
        not_found, duplicates = tests.suite_matches_id_list(suite, test_list)
2907
 
        self.assertEquals(['bogus'], not_found)
2908
 
        self.assertEquals([], duplicates)
 
2974
        self.assertEqual(['bogus'], not_found)
 
2975
        self.assertEqual([], duplicates)
2909
2976
 
2910
2977
    def test_suite_matches_id_list_with_duplicates(self):
2911
2978
        loader = TestUtil.TestLoader()
2918
2985
        test_list = ['bzrlib.tests.test_sampler.DemoTest.test_nothing',]
2919
2986
        not_found, duplicates = tests.suite_matches_id_list(
2920
2987
            dupes, test_list)
2921
 
        self.assertEquals([], not_found)
2922
 
        self.assertEquals(['bzrlib.tests.test_sampler.DemoTest.test_nothing'],
 
2988
        self.assertEqual([], not_found)
 
2989
        self.assertEqual(['bzrlib.tests.test_sampler.DemoTest.test_nothing'],
2923
2990
                          duplicates)
2924
2991
 
2925
2992
 
2998
3065
        suite = tests.test_suite(test_list,
2999
3066
                                 ['bzrlib.tests.test_selftest.TestTestSuite'])
3000
3067
        # test_test_suite_list_and_start is not included 
3001
 
        self.assertEquals(test_list, _test_ids(suite))
 
3068
        self.assertEqual(test_list, _test_ids(suite))
3002
3069
 
3003
3070
 
3004
3071
class TestLoadTestIdList(tests.TestCaseInTempDir):
3017
3084
        self._create_test_list_file(test_list_fname,
3018
3085
                                    'mod1.cl1.meth1\nmod2.cl2.meth2\n')
3019
3086
        tlist = tests.load_test_id_list(test_list_fname)
3020
 
        self.assertEquals(2, len(tlist))
3021
 
        self.assertEquals('mod1.cl1.meth1', tlist[0])
3022
 
        self.assertEquals('mod2.cl2.meth2', tlist[1])
 
3087
        self.assertEqual(2, len(tlist))
 
3088
        self.assertEqual('mod1.cl1.meth1', tlist[0])
 
3089
        self.assertEqual('mod2.cl2.meth2', tlist[1])
3023
3090
 
3024
3091
    def test_load_dirty_file(self):
3025
3092
        test_list_fname = 'test.list'
3027
3094
                                    '  mod1.cl1.meth1\n\nmod2.cl2.meth2  \n'
3028
3095
                                    'bar baz\n')
3029
3096
        tlist = tests.load_test_id_list(test_list_fname)
3030
 
        self.assertEquals(4, len(tlist))
3031
 
        self.assertEquals('mod1.cl1.meth1', tlist[0])
3032
 
        self.assertEquals('', tlist[1])
3033
 
        self.assertEquals('mod2.cl2.meth2', tlist[2])
3034
 
        self.assertEquals('bar baz', tlist[3])
 
3097
        self.assertEqual(4, len(tlist))
 
3098
        self.assertEqual('mod1.cl1.meth1', tlist[0])
 
3099
        self.assertEqual('', tlist[1])
 
3100
        self.assertEqual('mod2.cl2.meth2', tlist[2])
 
3101
        self.assertEqual('bar baz', tlist[3])
3035
3102
 
3036
3103
 
3037
3104
class TestFilteredByModuleTestLoader(tests.TestCase):
3045
3112
        test_list = ['bzrlib.tests.test_sampler.DemoTest.test_nothing']
3046
3113
        loader = self._create_loader(test_list)
3047
3114
        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
3048
 
        self.assertEquals(test_list, _test_ids(suite))
 
3115
        self.assertEqual(test_list, _test_ids(suite))
3049
3116
 
3050
3117
    def test_exclude_tests(self):
3051
3118
        test_list = ['bogus']
3052
3119
        loader = self._create_loader(test_list)
3053
3120
        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
3054
 
        self.assertEquals([], _test_ids(suite))
 
3121
        self.assertEqual([], _test_ids(suite))
3055
3122
 
3056
3123
 
3057
3124
class TestFilteredByNameStartTestLoader(tests.TestCase):
3067
3134
        loader = self._create_loader('bzrlib.tests.test_samp')
3068
3135
 
3069
3136
        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
3070
 
        self.assertEquals(test_list, _test_ids(suite))
 
3137
        self.assertEqual(test_list, _test_ids(suite))
3071
3138
 
3072
3139
    def test_load_tests_inside_module(self):
3073
3140
        test_list = ['bzrlib.tests.test_sampler.DemoTest.test_nothing']
3074
3141
        loader = self._create_loader('bzrlib.tests.test_sampler.Demo')
3075
3142
 
3076
3143
        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
3077
 
        self.assertEquals(test_list, _test_ids(suite))
 
3144
        self.assertEqual(test_list, _test_ids(suite))
3078
3145
 
3079
3146
    def test_exclude_tests(self):
3080
3147
        test_list = ['bogus']
3081
3148
        loader = self._create_loader('bogus')
3082
3149
 
3083
3150
        suite = loader.loadTestsFromModuleName('bzrlib.tests.test_sampler')
3084
 
        self.assertEquals([], _test_ids(suite))
 
3151
        self.assertEqual([], _test_ids(suite))
3085
3152
 
3086
3153
 
3087
3154
class TestTestPrefixRegistry(tests.TestCase):
3093
3160
    def test_register_new_prefix(self):
3094
3161
        tpr = self._get_registry()
3095
3162
        tpr.register('foo', 'fff.ooo.ooo')
3096
 
        self.assertEquals('fff.ooo.ooo', tpr.get('foo'))
 
3163
        self.assertEqual('fff.ooo.ooo', tpr.get('foo'))
3097
3164
 
3098
3165
    def test_register_existing_prefix(self):
3099
3166
        tpr = self._get_registry()
3100
3167
        tpr.register('bar', 'bbb.aaa.rrr')
3101
3168
        tpr.register('bar', 'bBB.aAA.rRR')
3102
 
        self.assertEquals('bbb.aaa.rrr', tpr.get('bar'))
 
3169
        self.assertEqual('bbb.aaa.rrr', tpr.get('bar'))
3103
3170
        self.assertThat(self.get_log(),
3104
3171
            DocTestMatches("...bar...bbb.aaa.rrr...BB.aAA.rRR",
3105
3172
                           doctest.ELLIPSIS))
3111
3178
    def test_resolve_prefix(self):
3112
3179
        tpr = self._get_registry()
3113
3180
        tpr.register('bar', 'bb.aa.rr')
3114
 
        self.assertEquals('bb.aa.rr', tpr.resolve_alias('bar'))
 
3181
        self.assertEqual('bb.aa.rr', tpr.resolve_alias('bar'))
3115
3182
 
3116
3183
    def test_resolve_unknown_alias(self):
3117
3184
        tpr = self._get_registry()
3120
3187
 
3121
3188
    def test_predefined_prefixes(self):
3122
3189
        tpr = tests.test_prefix_alias_registry
3123
 
        self.assertEquals('bzrlib', tpr.resolve_alias('bzrlib'))
3124
 
        self.assertEquals('bzrlib.doc', tpr.resolve_alias('bd'))
3125
 
        self.assertEquals('bzrlib.utils', tpr.resolve_alias('bu'))
3126
 
        self.assertEquals('bzrlib.tests', tpr.resolve_alias('bt'))
3127
 
        self.assertEquals('bzrlib.tests.blackbox', tpr.resolve_alias('bb'))
3128
 
        self.assertEquals('bzrlib.plugins', tpr.resolve_alias('bp'))
 
3190
        self.assertEqual('bzrlib', tpr.resolve_alias('bzrlib'))
 
3191
        self.assertEqual('bzrlib.doc', tpr.resolve_alias('bd'))
 
3192
        self.assertEqual('bzrlib.utils', tpr.resolve_alias('bu'))
 
3193
        self.assertEqual('bzrlib.tests', tpr.resolve_alias('bt'))
 
3194
        self.assertEqual('bzrlib.tests.blackbox', tpr.resolve_alias('bb'))
 
3195
        self.assertEqual('bzrlib.plugins', tpr.resolve_alias('bp'))
3129
3196
 
3130
3197
 
3131
3198
class TestThreadLeakDetection(tests.TestCase):
3454
3521
            def test_me(self):
3455
3522
                # The first call save the 42 value
3456
3523
                self.overrideEnv('MYVAR', None)
3457
 
                self.assertEquals(None, os.environ.get('MYVAR'))
 
3524
                self.assertEqual(None, os.environ.get('MYVAR'))
3458
3525
                # Make sure we can call it twice
3459
3526
                self.overrideEnv('MYVAR', None)
3460
 
                self.assertEquals(None, os.environ.get('MYVAR'))
 
3527
                self.assertEqual(None, os.environ.get('MYVAR'))
3461
3528
        output = StringIO()
3462
3529
        result = tests.TextTestResult(output, 0, 1)
3463
3530
        Test('test_me').run(result)
3464
3531
        if not result.wasStrictlySuccessful():
3465
3532
            self.fail(output.getvalue())
3466
3533
        # We get our value back
3467
 
        self.assertEquals('42', os.environ.get('MYVAR'))
 
3534
        self.assertEqual('42', os.environ.get('MYVAR'))
3468
3535
 
3469
3536
 
3470
3537
class TestIsolatedEnv(tests.TestCase):
3486
3553
        # Make sure we know the definition of BZR_HOME: not part of os.environ
3487
3554
        # for tests.TestCase.
3488
3555
        self.assertTrue('BZR_HOME' in tests.isolated_environ)
3489
 
        self.assertEquals(None, tests.isolated_environ['BZR_HOME'])
 
3556
        self.assertEqual(None, tests.isolated_environ['BZR_HOME'])
3490
3557
        # Being part of isolated_environ, BZR_HOME should not appear here
3491
3558
        self.assertFalse('BZR_HOME' in os.environ)
3492
3559
        # Make sure we know the definition of LINES: part of os.environ for
3493
3560
        # tests.TestCase
3494
3561
        self.assertTrue('LINES' in tests.isolated_environ)
3495
 
        self.assertEquals('25', tests.isolated_environ['LINES'])
3496
 
        self.assertEquals('25', os.environ['LINES'])
 
3562
        self.assertEqual('25', tests.isolated_environ['LINES'])
 
3563
        self.assertEqual('25', os.environ['LINES'])
3497
3564
 
3498
3565
    def test_injecting_unknown_variable(self):
3499
3566
        # BZR_HOME is known to be absent from os.environ
3500
3567
        test = self.ScratchMonkey('test_me')
3501
3568
        tests.override_os_environ(test, {'BZR_HOME': 'foo'})
3502
 
        self.assertEquals('foo', os.environ['BZR_HOME'])
 
3569
        self.assertEqual('foo', os.environ['BZR_HOME'])
3503
3570
        tests.restore_os_environ(test)
3504
3571
        self.assertFalse('BZR_HOME' in os.environ)
3505
3572
 
3507
3574
        test = self.ScratchMonkey('test_me')
3508
3575
        # LINES is known to be present in os.environ
3509
3576
        tests.override_os_environ(test, {'LINES': '42'})
3510
 
        self.assertEquals('42', os.environ['LINES'])
 
3577
        self.assertEqual('42', os.environ['LINES'])
3511
3578
        tests.restore_os_environ(test)
3512
 
        self.assertEquals('25', os.environ['LINES'])
 
3579
        self.assertEqual('25', os.environ['LINES'])
3513
3580
 
3514
3581
    def test_deleting_variable(self):
3515
3582
        test = self.ScratchMonkey('test_me')
3517
3584
        tests.override_os_environ(test, {'LINES': None})
3518
3585
        self.assertTrue('LINES' not in os.environ)
3519
3586
        tests.restore_os_environ(test)
3520
 
        self.assertEquals('25', os.environ['LINES'])
 
3587
        self.assertEqual('25', os.environ['LINES'])
3521
3588
 
3522
3589
 
3523
3590
class TestDocTestSuiteIsolation(tests.TestCase):
3610
3677
        # test at the command level without loading the whole test suite
3611
3678
        out, err = self.run_bzr(('selftest', '--list') + selftest_args)
3612
3679
        actual = out.splitlines()
3613
 
        self.assertEquals(expected, actual)
 
3680
        self.assertEqual(expected, actual)
3614
3681
 
3615
3682
    def test_full_list(self):
3616
3683
        self.assertTestList(['a', 'b', 'c'])
3651
3718
        test.run(result)
3652
3719
        self.assertTrue(hasattr(test, '_counters'))
3653
3720
        self.assertTrue(test._counters.has_key('myhook'))
3654
 
        self.assertEquals(expected_calls, test._counters['myhook'])
 
3721
        self.assertEqual(expected_calls, test._counters['myhook'])
3655
3722
 
3656
3723
    def test_no_hook(self):
3657
3724
        self.assertHookCalls(0, 'no_hook')