~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__groupcompress.py

merge trunk

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
17
17
"""Tests for the python and pyrex extensions of groupcompress"""
18
18
 
19
19
from bzrlib import (
20
 
    groupcompress,
21
20
    _groupcompress_py,
22
21
    tests,
23
22
    )
24
 
 
25
 
 
26
 
def load_tests(standard_tests, module, loader):
27
 
    """Parameterize tests for all versions of groupcompress."""
28
 
    two_way_scenarios = [
29
 
        ('PP', {'make_delta': _groupcompress_py.make_delta,
30
 
                'apply_delta': _groupcompress_py.apply_delta})
31
 
        ]
 
23
from bzrlib.tests.scenarios import (
 
24
    load_tests_apply_scenarios,
 
25
    )
 
26
 
 
27
 
 
28
def module_scenarios():
32
29
    scenarios = [
33
30
        ('python', {'_gc_module': _groupcompress_py}),
34
31
        ]
36
33
        gc_module = compiled_groupcompress_feature.module
37
34
        scenarios.append(('C',
38
35
            {'_gc_module': gc_module}))
39
 
        two_way_scenarios.extend([
 
36
    return scenarios
 
37
 
 
38
 
 
39
def two_way_scenarios():
 
40
    scenarios = [
 
41
        ('PP', {'make_delta': _groupcompress_py.make_delta,
 
42
                'apply_delta': _groupcompress_py.apply_delta})
 
43
        ]
 
44
    if compiled_groupcompress_feature.available():
 
45
        gc_module = compiled_groupcompress_feature.module
 
46
        scenarios.extend([
40
47
            ('CC', {'make_delta': gc_module.make_delta,
41
48
                    'apply_delta': gc_module.apply_delta}),
42
49
            ('PC', {'make_delta': _groupcompress_py.make_delta,
44
51
            ('CP', {'make_delta': gc_module.make_delta,
45
52
                    'apply_delta': _groupcompress_py.apply_delta}),
46
53
            ])
47
 
    to_adapt, result = tests.split_suite_by_condition(
48
 
        standard_tests, tests.condition_isinstance((TestMakeAndApplyDelta,
49
 
                                                    TestBase128Int)))
50
 
    result = tests.multiply_tests(to_adapt, scenarios, result)
51
 
    to_adapt, result = tests.split_suite_by_condition(result,
52
 
        tests.condition_isinstance(TestMakeAndApplyCompatible))
53
 
    result = tests.multiply_tests(to_adapt, two_way_scenarios, result)
54
 
    return result
 
54
    return scenarios
 
55
 
 
56
 
 
57
load_tests = load_tests_apply_scenarios
55
58
 
56
59
 
57
60
compiled_groupcompress_feature = tests.ModuleAvailableFeature(
116
119
 
117
120
class TestMakeAndApplyDelta(tests.TestCase):
118
121
 
 
122
    scenarios = module_scenarios()
119
123
    _gc_module = None # Set by load_tests
120
124
 
121
125
    def setUp(self):
226
230
 
227
231
class TestMakeAndApplyCompatible(tests.TestCase):
228
232
 
 
233
    scenarios = two_way_scenarios()
 
234
 
229
235
    make_delta = None # Set by load_tests
230
236
    apply_delta = None # Set by load_tests
231
237
 
457
463
 
458
464
class TestBase128Int(tests.TestCase):
459
465
 
 
466
    scenarios = module_scenarios()
 
467
 
460
468
    _gc_module = None # Set by load_tests
461
469
 
462
470
    def assertEqualEncode(self, bytes, val):