~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: 2011-03-15 07:54:39 UTC
  • mfrom: (0.38.5 trunk)
  • mto: This revision was merged to the branch mainline in revision 5726.
  • Revision ID: andrew.bennetts@canonical.com-20110315075439-nzm293joz143cx0k
Merge bzr-changelog-merge plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009, 2010, 2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
20
20
 
21
21
from bzrlib import (
22
22
    errors,
23
 
    graph as _mod_graph,
24
23
    _known_graph_py,
25
24
    tests,
26
25
    )
27
26
from bzrlib.tests import test_graph
28
27
from bzrlib.revision import NULL_REVISION
29
 
 
30
 
 
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
 
 
30
 
 
31
def caching_scenarios():
33
32
    scenarios = [
34
33
        ('python', {'module': _known_graph_py, 'do_cache': True}),
35
34
    ]
36
 
    caching_scenarios = [
37
 
        ('python-nocache', {'module': _known_graph_py, 'do_cache': False}),
38
 
    ]
39
 
    suite = loader.suiteClass()
40
35
    if compiled_known_graph_feature.available():
41
36
        scenarios.append(('C', {'module': compiled_known_graph_feature.module,
42
37
                                'do_cache': True}))
43
 
        caching_scenarios.append(
 
38
    return scenarios
 
39
 
 
40
 
 
41
def non_caching_scenarios():
 
42
    scenarios = [
 
43
        ('python-nocache', {'module': _known_graph_py, 'do_cache': False}),
 
44
    ]
 
45
    if compiled_known_graph_feature.available():
 
46
        scenarios.append(
44
47
            ('C-nocache', {'module': compiled_known_graph_feature.module,
45
48
                           '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
 
49
    return scenarios
 
50
 
 
51
 
 
52
load_tests = load_tests_apply_scenarios
60
53
 
61
54
 
62
55
compiled_known_graph_feature = tests.ModuleAvailableFeature(
63
 
                                    'bzrlib._known_graph_pyx')
 
56
    'bzrlib._known_graph_pyx')
64
57
 
65
58
 
66
59
#  a
75
68
 
76
69
class TestCaseWithKnownGraph(tests.TestCase):
77
70
 
 
71
    scenarios = caching_scenarios()
78
72
    module = None # Set by load_tests
79
73
 
80
74
    def make_known_graph(self, ancestry):
214
208
 
215
209
class TestKnownGraphHeads(TestCaseWithKnownGraph):
216
210
 
 
211
    scenarios = caching_scenarios() + non_caching_scenarios()
217
212
    do_cache = None # Set by load_tests
218
213
 
219
214
    def test_heads_null(self):