/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« 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:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 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
862
862
 
863
863
    def get_knit_index(self, transport, name, mode):
864
864
        mapper = ConstantMapper(name)
 
865
        self.addAttrCleanup(knit, '_load_data')
865
866
        from bzrlib._knit_load_data_py import _load_data_py
866
 
        self.overrideAttr(knit, '_load_data', _load_data_py)
 
867
        knit._load_data = _load_data_py
867
868
        allow_writes = lambda: 'w' in mode
868
869
        return _KndxIndex(transport, mapper, lambda:None, allow_writes, lambda:True)
869
870
 
1298
1299
 
1299
1300
    def get_knit_index(self, transport, name, mode):
1300
1301
        mapper = ConstantMapper(name)
 
1302
        self.addAttrCleanup(knit, '_load_data')
1301
1303
        from bzrlib._knit_load_data_pyx import _load_data_c
1302
 
        self.overrideAttr(knit, '_load_data', _load_data_c)
 
1304
        knit._load_data = _load_data_c
1303
1305
        allow_writes = lambda: mode == 'w'
1304
1306
        return _KndxIndex(transport, mapper, lambda:None,
1305
1307
                          allow_writes, lambda:True)