~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__static_tuple.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-12-22 18:18:20 UTC
  • mfrom: (4913.2.26 2.1.0rc1-module-available)
  • Revision ID: pqm@pqm.ubuntu.com-20091222181820-qfolh2sy2nevoxxj
(jam) Switch many test features over to ModuleAvailable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
        ('python', {'module': _static_tuple_py}),
37
37
    ]
38
38
    suite = loader.suiteClass()
39
 
    if CompiledStaticTuple.available():
40
 
        from bzrlib import _static_tuple_c
41
 
        scenarios.append(('C', {'module': _static_tuple_c}))
 
39
    if compiled_static_tuple_feature.available():
 
40
        scenarios.append(('C', {'module':
 
41
                                compiled_static_tuple_feature.module}))
42
42
    else:
43
43
        # the compiled module isn't available, so we add a failing test
44
44
        class FailWithoutFeature(tests.TestCase):
45
45
            def test_fail(self):
46
 
                self.requireFeature(CompiledStaticTuple)
 
46
                self.requireFeature(compiled_static_tuple_feature)
47
47
        suite.addTest(loader.loadTestsFromTestCase(FailWithoutFeature))
48
48
    result = tests.multiply_tests(standard_tests, scenarios, suite)
49
49
    return result
50
50
 
51
51
 
52
 
class _CompiledStaticTuple(tests.Feature):
53
 
 
54
 
    def _probe(self):
55
 
        try:
56
 
            import bzrlib._static_tuple_c
57
 
        except ImportError:
58
 
            return False
59
 
        return True
60
 
 
61
 
    def feature_name(self):
62
 
        return 'bzrlib._static_tuple_c'
63
 
 
64
 
CompiledStaticTuple = _CompiledStaticTuple()
 
52
compiled_static_tuple_feature = tests.ModuleAvailableFeature(
 
53
                                    'bzrlib._static_tuple_c')
65
54
 
66
55
 
67
56
class _Meliae(tests.Feature):
641
630
        # Make sure the right implementation is available from
642
631
        # bzrlib.static_tuple.StaticTuple.
643
632
        if self.module is _static_tuple_py:
644
 
            if CompiledStaticTuple.available():
 
633
            if compiled_static_tuple_feature.available():
645
634
                # We will be using the C version
646
635
                return
647
636
        self.assertIs(static_tuple.StaticTuple,