~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_btree_index.py

(gz) Change minimum required testtools version for selftest to 0.9.5 for
 unicode fixes (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2011 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 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
31
31
    )
32
32
from bzrlib.tests import (
33
33
    TestCaseWithTransport,
34
 
    scenarios,
 
34
    condition_isinstance,
 
35
    multiply_tests,
 
36
    split_suite_by_condition,
35
37
    )
36
38
 
37
39
 
38
 
load_tests = scenarios.load_tests_apply_scenarios
39
 
 
40
 
 
41
 
def btreeparser_scenarios():
 
40
def load_tests(standard_tests, module, loader):
 
41
    # parameterise the TestBTreeNodes tests
 
42
    node_tests, others = split_suite_by_condition(standard_tests,
 
43
        condition_isinstance(TestBTreeNodes))
42
44
    import bzrlib._btree_serializer_py as py_module
43
45
    scenarios = [('python', {'parse_btree': py_module})]
44
46
    if compiled_btreeparser_feature.available():
45
 
        scenarios.append(('C', 
46
 
            {'parse_btree': compiled_btreeparser_feature.module}))
47
 
    return scenarios
 
47
        scenarios.append(('C', {'parse_btree':
 
48
                                compiled_btreeparser_feature.module}))
 
49
    return multiply_tests(node_tests, scenarios, others)
48
50
 
49
51
 
50
52
compiled_btreeparser_feature = tests.ModuleAvailableFeature(
51
 
    'bzrlib._btree_serializer_pyx')
 
53
                                'bzrlib._btree_serializer_pyx')
52
54
 
53
55
 
54
56
class BTreeTestCase(TestCaseWithTransport):
796
798
    def test_eq_ne(self):
797
799
        # two indices are equal when constructed with the same parameters:
798
800
        t1 = transport.get_transport('trace+' + self.get_url(''))
799
 
        t2 = self.get_transport()
 
801
        t2 = transport.get_transport(self.get_url(''))
800
802
        self.assertTrue(
801
803
            btree_index.BTreeGraphIndex(t1, 'index', None) ==
802
804
            btree_index.BTreeGraphIndex(t1, 'index', None))
1151
1153
        for node in nodes:
1152
1154
            builder.add_node(*node)
1153
1155
        stream = builder.finish()
1154
 
        trans = self.get_transport()
 
1156
        trans = transport.get_transport(self.get_url())
1155
1157
        size = trans.put_file('index', stream)
1156
1158
        index = btree_index.BTreeGraphIndex(trans, 'index', size)
1157
1159
        self.assertEqual(500, index.key_count())
1183
1185
 
1184
1186
class TestBTreeNodes(BTreeTestCase):
1185
1187
 
1186
 
    scenarios = btreeparser_scenarios()
1187
 
 
1188
1188
    def setUp(self):
1189
1189
        BTreeTestCase.setUp(self)
1190
1190
        self.overrideAttr(btree_index, '_btree_serializer', self.parse_btree)