~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_version_info.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-26 10:49:57 UTC
  • mfrom: (4987.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100126104957-dmtqnc0pckuruyla
(vila,
        jam) Implement TestCase.overrideAttr to simplify tests setUp/cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
from bzrlib import (
25
25
    errors,
 
26
    registry,
26
27
    symbol_versioning,
27
28
    tests,
28
29
    version_info_formats,
325
326
 
326
327
    def setUp(self):
327
328
        super(TestVersionInfoFormatRegistry, self).setUp()
328
 
        registry = version_info_formats.format_registry
329
 
        self._default_key = registry._default_key
330
 
        self._dict = registry._dict.copy()
331
 
        self._help_dict = registry._help_dict.copy()
332
 
        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
 
329
        self.overrideAttr(version_info_formats,
 
330
                          'format_registry', registry.Registry())
342
331
 
343
332
    def test_register_remove(self):
344
333
        registry = version_info_formats.format_registry