~bzr-pqm/bzr/bzr.dev

« 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:
148
148
        stanza = regen(check_for_clean=True, include_file_revisions=True)
149
149
        self.assertEqual(['False'], stanza.get_all('clean'))
150
150
 
151
 
        # XXX: This assumes it's being run against a repository that updates
152
 
        # the root revision on every commit.  Newer ones that use
153
 
        # RootCommitBuilder won't update it on each commit.
 
151
        # This assumes it's being run against a tree that does not update the
 
152
        # root revision on every commit.
154
153
        file_rev_stanza = get_one_stanza(stanza, 'file-revisions')
155
154
        self.assertEqual(['', 'a', 'b', 'c'], file_rev_stanza.get_all('path'))
156
 
        self.assertEqual(['r3', 'r3', 'r2', 'unversioned'],
 
155
        self.assertEqual(['r1', 'r3', 'r2', 'unversioned'],
157
156
            file_rev_stanza.get_all('revision'))
158
157
        os.remove('branch/c')
159
158
 
171
170
        file_rev_stanza = get_one_stanza(stanza, 'file-revisions')
172
171
        self.assertEqual(['', 'a', 'b', 'c', 'd'],
173
172
                          file_rev_stanza.get_all('path'))
174
 
        self.assertEqual(['r3', 'modified', 'renamed to d', 'new',
 
173
        self.assertEqual(['r1', 'modified', 'renamed to d', 'new',
175
174
                          'renamed from b'],
176
175
                         file_rev_stanza.get_all('revision'))
177
176
 
181
180
        stanza = regen(check_for_clean=True, include_file_revisions=True)
182
181
        file_rev_stanza = get_one_stanza(stanza, 'file-revisions')
183
182
        self.assertEqual(['', 'a', 'c', 'd'], file_rev_stanza.get_all('path'))
184
 
        self.assertEqual(['r4', 'r4', 'unversioned', 'removed'],
 
183
        self.assertEqual(['r1', 'r4', 'unversioned', 'removed'],
185
184
                         file_rev_stanza.get_all('revision'))
186
185
 
187
186
    def test_python_null(self):
327
326
    def setUp(self):
328
327
        super(TestVersionInfoFormatRegistry, self).setUp()
329
328
        registry = version_info_formats.format_registry
 
329
        self.addAttrCleanup(registry, '_default_key')
330
330
        self._default_key = registry._default_key
 
331
        self.addAttrCleanup(registry, '_dict')
331
332
        self._dict = registry._dict.copy()
 
333
        self.addAttrCleanup(registry, '_help_dict')
332
334
        self._help_dict = registry._help_dict.copy()
 
335
        self.addAttrCleanup(registry, '_info_dict')
333
336
        self._info_dict = registry._info_dict.copy()
334
 
        self.addCleanup(self._cleanup)
335
 
 
336
 
    def _cleanup(self):
337
 
        # Restore the registry to pristine state after the test runs
338
 
        registry = version_info_formats.format_registry
339
 
        registry._default_key = self._default_key
340
 
        registry._dict = self._dict
341
 
        registry._help_dict = self._help_dict
342
 
        registry._info_dict = self._info_dict
343
337
 
344
338
    def test_register_remove(self):
345
339
        registry = version_info_formats.format_registry