Rev 4915: Switch CHKMap to use ModuleAvailableFeature in http://bazaar.launchpad.net/~jameinel/bzr/2.1.0rc1-module-available

John Arbash Meinel john at arbash-meinel.com
Mon Dec 21 17:36:19 GMT 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.1.0rc1-module-available

------------------------------------------------------------
revno: 4915
revision-id: john at arbash-meinel.com-20091221173611-udyhtty1s2wp0wvc
parent: john at arbash-meinel.com-20091221173602-pqmnqpc57vetwn09
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1.0rc1-module-available
timestamp: Mon 2009-12-21 11:36:11 -0600
message:
  Switch CHKMap to use ModuleAvailableFeature
-------------- next part --------------
=== modified file 'bzrlib/tests/test__chk_map.py'
--- a/bzrlib/tests/test__chk_map.py	2009-10-20 22:13:23 +0000
+++ b/bzrlib/tests/test__chk_map.py	2009-12-21 17:36:11 +0000
@@ -29,32 +29,19 @@
     suite = loader.suiteClass()
     import bzrlib._chk_map_py as py_module
     scenarios = [('python', {'module': py_module})]
-    if CompiledChkMapFeature.available():
-        import bzrlib._chk_map_pyx as c_module
-        scenarios.append(('C', {'module': c_module}))
+    if compiled_chkmap.available():
+        scenarios.append(('C', {'module': compiled_chkmap.module}))
     else:
         # the compiled module isn't available, so we add a failing test
         class FailWithoutFeature(tests.TestCase):
             def test_fail(self):
-                self.requireFeature(CompiledChkMapFeature)
+                self.requireFeature(compiled_chkmap)
         suite.addTest(loader.loadTestsFromTestCase(FailWithoutFeature))
     tests.multiply_tests(standard_tests, scenarios, suite)
     return suite
 
 
-class _CompiledChkMapFeature(tests.Feature):
-
-    def _probe(self):
-        try:
-            import bzrlib._chk_map_pyx
-        except ImportError:
-            return False
-        return True
-
-    def feature_name(self):
-        return 'bzrlib._chk_map_pyx'
-
-CompiledChkMapFeature = _CompiledChkMapFeature()
+compiled_chkmap = tests.ModuleAvailableFeature('bzrlib._chk_map_pyx')
 
 
 class TestSearchKeys(tests.TestCase):



More information about the bazaar-commits mailing list