~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bencode.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:
23
23
    suite = loader.suiteClass()
24
24
    import bzrlib.util._bencode_py as py_module
25
25
    scenarios = [('python', {'bencode': py_module})]
26
 
    if CompiledBencodeFeature.available():
27
 
        import bzrlib._bencode_pyx as c_module
28
 
        scenarios.append(('C', {'bencode': c_module}))
 
26
    if compiled_bencode_feature.available():
 
27
        scenarios.append(('C', {'bencode': compiled_bencode_feature.module}))
29
28
    else:
30
29
        # the compiled module isn't available, so we add a failing test
31
30
        class FailWithoutFeature(tests.TestCase):
32
31
            def test_fail(self):
33
 
                self.requireFeature(CompiledBencodeFeature)
 
32
                self.requireFeature(compiled_bencode_feature)
34
33
        suite.addTest(loader.loadTestsFromTestCase(FailWithoutFeature))
35
34
    tests.multiply_tests(standard_tests, scenarios, suite)
36
35
    return suite
37
36
 
38
37
 
39
 
class _CompiledBencodeFeature(tests.Feature):
40
 
 
41
 
    def _probe(self):
42
 
        try:
43
 
            import bzrlib._bencode_pyx
44
 
        except ImportError:
45
 
            return False
46
 
        return True
47
 
 
48
 
    def feature_name(self):
49
 
        return 'bzrlib._bencode_pyx'
50
 
 
51
 
CompiledBencodeFeature = _CompiledBencodeFeature()
 
38
compiled_bencode_feature = tests.ModuleAvailableFeature('bzrlib._bencode_pyx')
52
39
 
53
40
 
54
41
class TestBencodeDecode(tests.TestCase):