~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__known_graph.py

  • Committer: Andrew Bennetts
  • Date: 2010-12-14 23:14:44 UTC
  • mfrom: (5569 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5570.
  • Revision ID: andrew.bennetts@canonical.com-20101214231444-uubf7zjbg8q92ocs
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    )
27
27
from bzrlib.tests import test_graph
28
28
from bzrlib.revision import NULL_REVISION
29
 
 
30
 
 
31
 
def load_tests(standard_tests, module, loader):
32
 
    """Parameterize tests for all versions of groupcompress."""
 
29
from bzrlib.tests.scenarios import load_tests_apply_scenarios
 
30
 
 
31
 
 
32
def caching_scenarios():
33
33
    scenarios = [
34
34
        ('python', {'module': _known_graph_py, 'do_cache': True}),
35
35
    ]
36
 
    caching_scenarios = [
37
 
        ('python-nocache', {'module': _known_graph_py, 'do_cache': False}),
38
 
    ]
39
 
    suite = loader.suiteClass()
40
36
    if compiled_known_graph_feature.available():
41
37
        scenarios.append(('C', {'module': compiled_known_graph_feature.module,
42
38
                                'do_cache': True}))
43
 
        caching_scenarios.append(
 
39
    return scenarios
 
40
 
 
41
 
 
42
def non_caching_scenarios():
 
43
    scenarios = [
 
44
        ('python-nocache', {'module': _known_graph_py, 'do_cache': False}),
 
45
    ]
 
46
    if compiled_known_graph_feature.available():
 
47
        scenarios.append(
44
48
            ('C-nocache', {'module': compiled_known_graph_feature.module,
45
49
                           'do_cache': False}))
46
 
    else:
47
 
        # the compiled module isn't available, so we add a failing test
48
 
        class FailWithoutFeature(tests.TestCase):
49
 
            def test_fail(self):
50
 
                self.requireFeature(compiled_known_graph_feature)
51
 
        suite.addTest(loader.loadTestsFromTestCase(FailWithoutFeature))
52
 
    # TestKnownGraphHeads needs to be permutated with and without caching.
53
 
    # All other TestKnownGraph tests only need to be tested across module
54
 
    heads_suite, other_suite = tests.split_suite_by_condition(
55
 
        standard_tests, tests.condition_isinstance(TestKnownGraphHeads))
56
 
    suite = tests.multiply_tests(other_suite, scenarios, suite)
57
 
    suite = tests.multiply_tests(heads_suite, scenarios + caching_scenarios,
58
 
                                 suite)
59
 
    return suite
 
50
    return scenarios
 
51
 
 
52
 
 
53
load_tests = load_tests_apply_scenarios
60
54
 
61
55
 
62
56
compiled_known_graph_feature = tests.ModuleAvailableFeature(
63
 
                                    'bzrlib._known_graph_pyx')
 
57
    'bzrlib._known_graph_pyx')
64
58
 
65
59
 
66
60
#  a
75
69
 
76
70
class TestCaseWithKnownGraph(tests.TestCase):
77
71
 
 
72
    scenarios = caching_scenarios()
78
73
    module = None # Set by load_tests
79
74
 
80
75
    def make_known_graph(self, ancestry):
214
209
 
215
210
class TestKnownGraphHeads(TestCaseWithKnownGraph):
216
211
 
 
212
    scenarios = caching_scenarios() + non_caching_scenarios()
217
213
    do_cache = None # Set by load_tests
218
214
 
219
215
    def test_heads_null(self):