~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-25 17:48:22 UTC
  • mto: (4987.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125174822-nce4l19sbwx83jvq
Deploying the new overrideAttr facility further reduces the complexity
and make the code clearer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
754
754
    def _patch_get_bzr_source_tree(self):
755
755
        # Reading from the actual source tree breaks isolation, but we don't
756
756
        # want to assume that thats *all* that would happen.
757
 
        def _get_bzr_source_tree():
758
 
            return None
759
 
        self.addAttrCleanup(bzrlib.version, '_get_bzr_source_tree')
760
 
        bzrlib.version._get_bzr_source_tree = _get_bzr_source_tree
 
757
        self.overrideAttr(bzrlib.version, '_get_bzr_source_tree', lambda: None)
761
758
 
762
759
    def test_assigned_benchmark_file_stores_date(self):
763
760
        self._patch_get_bzr_source_tree()
1198
1195
        # Reading from the actual source tree breaks isolation, but we don't
1199
1196
        # want to assume that thats *all* that would happen.
1200
1197
        self._get_source_tree_calls = []
1201
 
        def _get_bzr_source_tree():
 
1198
        def new_get():
1202
1199
            self._get_source_tree_calls.append("called")
1203
1200
            return None
1204
 
        self.addAttrCleanup(bzrlib.version, '_get_bzr_source_tree')
1205
 
        bzrlib.version._get_bzr_source_tree = _get_bzr_source_tree
 
1201
        self.overrideAttr(bzrlib.version, '_get_bzr_source_tree',  new_get)
1206
1202
 
1207
1203
    def test_bench_history(self):
1208
1204
        # tests that the running the benchmark passes bench_history into
1316
1312
        self.assertEqual(flags, bzrlib.debug.debug_flags)
1317
1313
 
1318
1314
    def change_selftest_debug_flags(self, new_flags):
1319
 
        self.addAttrCleanup(tests, 'selftest_debug_flags')
1320
 
        tests.selftest_debug_flags = set(new_flags)
 
1315
        self.overrideAttr(tests, 'selftest_debug_flags', set(new_flags))
1321
1316
 
1322
1317
    def test_allow_debug_flag(self):
1323
1318
        """The -Eallow_debug flag prevents bzrlib.debug.debug_flags from being
2789
2784
        # test doubles that supply a few sample tests to load, and check they
2790
2785
        # are loaded.
2791
2786
        calls = []
2792
 
        def _test_suite_testmod_names():
 
2787
        def testmod_names():
2793
2788
            calls.append("testmod_names")
2794
2789
            return [
2795
2790
                'bzrlib.tests.blackbox.test_branch',
2796
2791
                'bzrlib.tests.per_transport',
2797
2792
                'bzrlib.tests.test_selftest',
2798
2793
                ]
2799
 
        self.addAttrCleanup(tests, '_test_suite_testmod_names')
2800
 
        self.addAttrCleanup(tests, '_test_suite_modules_to_doctest')
2801
 
        def _test_suite_modules_to_doctest():
 
2794
        self.overrideAttr(tests, '_test_suite_testmod_names', testmod_names)
 
2795
        def doctests():
2802
2796
            calls.append("modules_to_doctest")
2803
2797
            return ['bzrlib.timestamp']
2804
 
        tests._test_suite_testmod_names = _test_suite_testmod_names
2805
 
        tests._test_suite_modules_to_doctest = _test_suite_modules_to_doctest
 
2798
        self.overrideAttr(tests, '_test_suite_modules_to_doctest', doctests)
2806
2799
        expected_test_list = [
2807
2800
            # testmod_names
2808
2801
            'bzrlib.tests.blackbox.test_branch.TestBranch.test_branch',