Rev 3139: Fix bug #175886: version_info deprecated functions should be tested to still work. in http://bzr.arbash-meinel.com/branches/bzr/jam-integration

John Arbash Meinel john at arbash-meinel.com
Fri Dec 21 15:06:28 GMT 2007


At http://bzr.arbash-meinel.com/branches/bzr/jam-integration

------------------------------------------------------------
revno: 3139
revision-id:john at arbash-meinel.com-20071221150525-sv1c6goq0634nczi
parent: pqm at pqm.ubuntu.com-20071221064933-tsmn13951il1c01q
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: jam-integration
timestamp: Fri 2007-12-21 09:05:25 -0600
message:
  Fix bug #175886: version_info deprecated functions should be tested to still work.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/test_version_info.py test_version_info.py-20051228204928-2c364e30b702b41b
  bzrlib/version_info_formats/__init__.py generate_version_info.py-20051228204928-8358edabcddcd97e
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2007-12-21 05:52:38 +0000
+++ b/NEWS	2007-12-21 15:05:25 +0000
@@ -65,6 +65,15 @@
      user:pass embedded in the urls.
      (Vincent Ladeuil, #177643)
 
+   * ``reconfigure`` is able to convert trees into lightweight checkouts.
+     (Aaron Bentley)
+
+   * Reduce lockdir timeout to 0 when running ``bzr serve``.  (Andrew Bennetts,
+     #148087)
+
+   * Test that the old ``version_info_format`` functions still work, even
+     though they are deprecated. (John Arbash Meinel, ShenMaq, #177872)
+
    * Transform failures no longer cause ImmortalLimbo errors (Aaron Bentley,
      #137681)
 
@@ -76,12 +85,6 @@
      read the remaining bytes by chunks to avoid overflowing network buffers.
      (Vincent Ladeuil, #175886)
 
-   * ``reconfigure`` is able to convert trees into lightweight checkouts.
-     (Aaron Bentley)
-
-   * Reduce lockdir timeout to 0 when running ``bzr serve``.  (Andrew Bennetts,
-     #148087)
-
   DOCUMENTATION:
 
    * Reference material has now be moved out of the User Guide and added

=== modified file 'bzrlib/tests/test_version_info.py'
--- a/bzrlib/tests/test_version_info.py	2007-10-29 10:15:53 +0000
+++ b/bzrlib/tests/test_version_info.py	2007-12-21 15:05:25 +0000
@@ -21,6 +21,11 @@
 import os
 import sys
 
+from bzrlib import (
+    symbol_versioning,
+    tests,
+    version_info_formats,
+    )
 from bzrlib.tests import TestCaseWithTransport
 from bzrlib.rio import read_stanzas
 
@@ -251,3 +256,49 @@
         val = regen('clean: {clean}', check_for_clean=True)
         self.assertEqual(val, 'clean: 0')
         os.remove('branch/c')
+
+
+class TestBuilder(version_info_formats.VersionInfoBuilder):
+    pass
+
+
+class TestVersionInfoFormatRegistry(tests.TestCase):
+
+    def setUp(self):
+        super(TestVersionInfoFormatRegistry, self).setUp()
+        registry = version_info_formats.format_registry
+        self._default_key = registry._default_key
+        self._dict = registry._dict.copy()
+        self._help_dict = registry._help_dict.copy()
+        self._info_dict = registry._info_dict.copy()
+        self.addCleanup(self._cleanup)
+
+    def _cleanup(self):
+        # Restore the registry to pristine state after the test runs
+        registry = version_info_formats.format_registry
+        registry._default_key = self._default_key
+        registry._dict = self._dict
+        registry._help_dict = self._help_dict
+        registry._info_dict = self._info_dict
+
+    def test_register_remove(self):
+        registry = version_info_formats.format_registry
+        registry.register('testbuilder',
+            TestBuilder, 'a simple test builder')
+        self.assertIs(TestBuilder, registry.get('testbuilder'))
+        self.assertEqual('a simple test builder',
+                         registry.get_help('testbuilder'))
+        registry.remove('testbuilder')
+        self.assertRaises(KeyError, registry.get, 'testbuilder')
+
+    def test_old_functions(self):
+        self.applyDeprecated(symbol_versioning.one_zero,
+            version_info_formats.register_builder,
+            'test-builder', __name__, 'TestBuilder')
+        formats = self.applyDeprecated(symbol_versioning.one_zero,
+            version_info_formats.get_builder_formats)
+        self.failUnless('test-builder' in formats)
+        self.assertIs(TestBuilder,
+            self.applyDeprecated(symbol_versioning.one_zero,
+                version_info_formats.get_builder, 'test-builder'))
+        version_info_formats.format_registry.remove('test-builder')

=== modified file 'bzrlib/version_info_formats/__init__.py'
--- a/bzrlib/version_info_formats/__init__.py	2007-12-18 15:22:47 +0000
+++ b/bzrlib/version_info_formats/__init__.py	2007-12-21 15:05:25 +0000
@@ -186,7 +186,7 @@
         can be found
     :param class_name: The string name of the class to instantiate
     """
-    format_registry.regiser_lazy(format, module, class_names)
+    format_registry.register_lazy(format, module, class_name)
 
 
 @deprecated_function(one_zero)



More information about the bazaar-commits mailing list