Rev 4914: Switch Annotator to use the 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:10 GMT 2009


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

------------------------------------------------------------
revno: 4914
revision-id: john at arbash-meinel.com-20091221173602-pqmnqpc57vetwn09
parent: pqm at pqm.ubuntu.com-20091221060307-uvja3vdy1o6dzzy0
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1.0rc1-module-available
timestamp: Mon 2009-12-21 11:36:02 -0600
message:
  Switch Annotator to use the ModuleAvailableFeature
-------------- next part --------------
=== modified file 'bzrlib/tests/test__annotator.py'
--- a/bzrlib/tests/test__annotator.py	2009-07-08 17:09:03 +0000
+++ b/bzrlib/tests/test__annotator.py	2009-12-21 17:36:02 +0000
@@ -32,32 +32,19 @@
         ('python', {'module': _annotator_py}),
     ]
     suite = loader.suiteClass()
-    if CompiledAnnotator.available():
-        from bzrlib import _annotator_pyx
-        scenarios.append(('C', {'module': _annotator_pyx}))
+    if compiled_annotator.available():
+        scenarios.append(('C', {'module': compiled_annotator.module}))
     else:
         # the compiled module isn't available, so we add a failing test
         class FailWithoutFeature(tests.TestCase):
             def test_fail(self):
-                self.requireFeature(CompiledAnnotator)
+                self.requireFeature(compiled_annotator)
         suite.addTest(loader.loadTestsFromTestCase(FailWithoutFeature))
     result = tests.multiply_tests(standard_tests, scenarios, suite)
     return result
 
 
-class _CompiledAnnotator(tests.Feature):
-
-    def _probe(self):
-        try:
-            import bzrlib._annotator_pyx
-        except ImportError:
-            return False
-        return True
-
-    def feature_name(self):
-        return 'bzrlib._annotator_pyx'
-
-CompiledAnnotator = _CompiledAnnotator()
+compiled_annotator = tests.ModuleAvailableFeature('bzrlib._annotator_pyx')
 
 
 class TestAnnotator(tests.TestCaseWithMemoryTransport):



More information about the bazaar-commits mailing list