Rev 4927: Fix ModuleFeature() side-effect. in file:///home/vila/src/bzr/cleanup/various/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Dec 30 12:09:47 GMT 2009


At file:///home/vila/src/bzr/cleanup/various/

------------------------------------------------------------
revno: 4927
revision-id: v.ladeuil+lp at free.fr-20091230120947-wm3nlgx0dq48np4m
parent: pqm at pqm.ubuntu.com-20091225133303-vdy4zelx2xdoccfp
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: various
timestamp: Wed 2009-12-30 13:09:47 +0100
message:
  Fix ModuleFeature() side-effect.
  
  * bzrlib/tests/test_http.py:
  (TestHttps_pycurl.test_pycurl_without_https_support): With the new
  ModuleFeature design, the module is not imported in the global
  namespace anymore.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_http.py'
--- a/bzrlib/tests/test_http.py	2009-12-21 19:44:51 +0000
+++ b/bzrlib/tests/test_http.py	2009-12-30 12:09:47 +0000
@@ -449,30 +449,31 @@
         support it.
         """
         self.requireFeature(features.pycurl)
+        # Import the module locally now that we now it's available.
+        pycurl = features.pycurl.module
 
         version_info_orig = pycurl.version_info
-        try:
-            # Now that we have pycurl imported, we can fake its version_info
-            # This was taken from a windows pycurl without SSL
-            # (thanks to bialix)
-            pycurl.version_info = lambda : (2,
-                                            '7.13.2',
-                                            462082,
-                                            'i386-pc-win32',
-                                            2576,
-                                            None,
-                                            0,
-                                            None,
-                                            ('ftp', 'gopher', 'telnet',
-                                             'dict', 'ldap', 'http', 'file'),
-                                            None,
-                                            0,
-                                            None)
-            self.assertRaises(errors.DependencyNotPresent, self._transport,
-                              'https://launchpad.net')
-        finally:
-            # Restore the right function
+        def restore():
             pycurl.version_info = version_info_orig
+        self.addCleanup(restore)
+
+        # Fake the pycurl version_info This was taken from a windows pycurl
+        # without SSL (thanks to bialix)
+        pycurl.version_info = lambda : (2,
+                                        '7.13.2',
+                                        462082,
+                                        'i386-pc-win32',
+                                        2576,
+                                        None,
+                                        0,
+                                        None,
+                                        ('ftp', 'gopher', 'telnet',
+                                         'dict', 'ldap', 'http', 'file'),
+                                        None,
+                                        0,
+                                        None)
+        self.assertRaises(errors.DependencyNotPresent, self._transport,
+                          'https://launchpad.net')
 
 
 class TestHTTPConnections(http_utils.TestCaseWithWebserver):



More information about the bazaar-commits mailing list