~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__dirstate_helpers.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:
831
831
 
832
832
    def setUp(self):
833
833
        super(TestUpdateEntry, self).setUp()
834
 
        orig = dirstate.update_entry
835
 
        def cleanup():
836
 
            dirstate.update_entry = orig
837
 
        self.addCleanup(cleanup)
 
834
        self.addAttrCleanup(dirstate, 'update_entry')
838
835
        dirstate.update_entry = self.update_entry
839
836
 
840
837
    def get_state_with_a(self):
1278
1275
 
1279
1276
    def setUp(self):
1280
1277
        super(TestProcessEntry, self).setUp()
1281
 
        orig = dirstate._process_entry
1282
 
        def cleanup():
1283
 
            dirstate._process_entry = orig
1284
 
        self.addCleanup(cleanup)
 
1278
        self.addAttrCleanup(dirstate, '_process_entry')
1285
1279
        dirstate._process_entry = self._process_entry
1286
1280
 
1287
1281
    def assertChangedFileIds(self, expected, tree):
1307
1301
        tree.lock_read()
1308
1302
        self.addCleanup(tree.unlock)
1309
1303
        basis_tree = tree.basis_tree()
1310
 
        orig = osutils.is_inside
1311
 
        self.addCleanup(setattr, osutils, 'is_inside', orig)
 
1304
        self.addAttrCleanup(osutils, 'is_inside')
1312
1305
        osutils.is_inside = is_inside_raises
1313
1306
        self.assertListRaises(RuntimeError, tree.iter_changes, basis_tree)
1314
1307