~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-25 15:55:48 UTC
  • mto: (4985.1.4 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125155548-0l352pujvt5bzl5e
Deploy addAttrCleanup on the whole test suite.

Several use case worth mentioning:

- setting a module or any other object attribute is the majority
by far. In some cases the setting itself is deferred but most of
the time we want to set at the same time we add the cleanup.

- there multiple occurrences of protecting hooks or ui factory
which are now useless (the test framework takes care of that now),

- there was some lambda uses that can now be avoided.

That first cleanup already simplifies things a lot.

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)
 
865
        self.addAttrCleanup(knit, '_load_data')
869
866
        from bzrlib._knit_load_data_py import _load_data_py
870
867
        knit._load_data = _load_data_py
871
868
        allow_writes = lambda: 'w' in mode
1302
1299
 
1303
1300
    def get_knit_index(self, transport, name, mode):
1304
1301
        mapper = ConstantMapper(name)
1305
 
        orig = knit._load_data
1306
 
        def reset():
1307
 
            knit._load_data = orig
1308
 
        self.addCleanup(reset)
 
1302
        self.addAttrCleanup(knit, '_load_data')
1309
1303
        from bzrlib._knit_load_data_pyx import _load_data_c
1310
1304
        knit._load_data = _load_data_c
1311
1305
        allow_writes = lambda: mode == 'w'
1312
 
        return _KndxIndex(transport, mapper, lambda:None, allow_writes, lambda:True)
 
1306
        return _KndxIndex(transport, mapper, lambda:None,
 
1307
                          allow_writes, lambda:True)
1313
1308
 
1314
1309
 
1315
1310
class Test_KnitAnnotator(TestCaseWithMemoryTransport):