/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_version_info.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:
326
326
    def setUp(self):
327
327
        super(TestVersionInfoFormatRegistry, self).setUp()
328
328
        registry = version_info_formats.format_registry
 
329
        self.addAttrCleanup(registry, '_default_key')
329
330
        self._default_key = registry._default_key
 
331
        self.addAttrCleanup(registry, '_dict')
330
332
        self._dict = registry._dict.copy()
 
333
        self.addAttrCleanup(registry, '_help_dict')
331
334
        self._help_dict = registry._help_dict.copy()
 
335
        self.addAttrCleanup(registry, '_info_dict')
332
336
        self._info_dict = registry._info_dict.copy()
333
 
        self.addCleanup(self._cleanup)
334
 
 
335
 
    def _cleanup(self):
336
 
        # Restore the registry to pristine state after the test runs
337
 
        registry = version_info_formats.format_registry
338
 
        registry._default_key = self._default_key
339
 
        registry._dict = self._dict
340
 
        registry._help_dict = self._help_dict
341
 
        registry._info_dict = self._info_dict
342
337
 
343
338
    def test_register_remove(self):
344
339
        registry = version_info_formats.format_registry