~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-26 10:17:22 UTC
  • mfrom: (4985.1.5 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100126101722-y213sv39buw3dgi2
Implement TestCase.overrideAttr to simplify tests setUp/cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
862
862
 
863
863
    def get_knit_index(self, transport, name, mode):
864
864
        mapper = ConstantMapper(name)
865
 
        orig = knit._load_data
866
 
        def reset():
867
 
            knit._load_data = orig
868
 
        self.addCleanup(reset)
869
865
        from bzrlib._knit_load_data_py import _load_data_py
870
 
        knit._load_data = _load_data_py
 
866
        self.overrideAttr(knit, '_load_data', _load_data_py)
871
867
        allow_writes = lambda: 'w' in mode
872
868
        return _KndxIndex(transport, mapper, lambda:None, allow_writes, lambda:True)
873
869
 
1302
1298
 
1303
1299
    def get_knit_index(self, transport, name, mode):
1304
1300
        mapper = ConstantMapper(name)
1305
 
        orig = knit._load_data
1306
 
        def reset():
1307
 
            knit._load_data = orig
1308
 
        self.addCleanup(reset)
1309
1301
        from bzrlib._knit_load_data_pyx import _load_data_c
1310
 
        knit._load_data = _load_data_c
 
1302
        self.overrideAttr(knit, '_load_data', _load_data_c)
1311
1303
        allow_writes = lambda: mode == 'w'
1312
 
        return _KndxIndex(transport, mapper, lambda:None, allow_writes, lambda:True)
 
1304
        return _KndxIndex(transport, mapper, lambda:None,
 
1305
                          allow_writes, lambda:True)
1313
1306
 
1314
1307
 
1315
1308
class Test_KnitAnnotator(TestCaseWithMemoryTransport):