21
21
from bzrlib import (
27
26
from bzrlib.tests import test_graph
28
27
from bzrlib.revision import NULL_REVISION
31
def load_tests(standard_tests, module, loader):
32
"""Parameterize tests for all versions of groupcompress."""
28
from bzrlib.tests.scenarios import load_tests_apply_scenarios
29
from bzrlib.tests import (
34
def caching_scenarios():
34
36
('python', {'module': _known_graph_py, 'do_cache': True}),
38
if compiled_known_graph_feature.available():
39
scenarios.append(('C', {'module': compiled_known_graph_feature.module,
44
def non_caching_scenarios():
37
46
('python-nocache', {'module': _known_graph_py, 'do_cache': False}),
39
suite = loader.suiteClass()
40
if CompiledKnownGraphFeature.available():
41
from bzrlib import _known_graph_pyx
42
scenarios.append(('C', {'module': _known_graph_pyx, 'do_cache': True}))
43
caching_scenarios.append(('C-nocache',
44
{'module': _known_graph_pyx, 'do_cache': False}))
46
# the compiled module isn't available, so we add a failing test
47
class FailWithoutFeature(tests.TestCase):
49
self.requireFeature(CompiledKnownGraphFeature)
50
suite.addTest(loader.loadTestsFromTestCase(FailWithoutFeature))
51
# TestKnownGraphHeads needs to be permutated with and without caching.
52
# All other TestKnownGraph tests only need to be tested across module
53
heads_suite, other_suite = tests.split_suite_by_condition(
54
standard_tests, tests.condition_isinstance(TestKnownGraphHeads))
55
suite = tests.multiply_tests(other_suite, scenarios, suite)
56
suite = tests.multiply_tests(heads_suite, scenarios + caching_scenarios,
61
class _CompiledKnownGraphFeature(tests.Feature):
65
import bzrlib._known_graph_pyx
70
def feature_name(self):
71
return 'bzrlib._known_graph_pyx'
73
CompiledKnownGraphFeature = _CompiledKnownGraphFeature()
48
if compiled_known_graph_feature.available():
50
('C-nocache', {'module': compiled_known_graph_feature.module,
55
load_tests = load_tests_apply_scenarios
58
compiled_known_graph_feature = features.ModuleAvailableFeature(
59
'bzrlib._known_graph_pyx')