~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_btree_index.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-11 02:48:31 UTC
  • mfrom: (5847.1.6 2.4-uncommit-faster)
  • Revision ID: pqm@pqm.ubuntu.com-20110511024831-tm38ubce8znnq351
(jameinel) Make set_parent_trees() ~5% faster by improving the sort key
 function. (John A Meinel)

Show diffs side-by-side

added added

removed removed

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