1
# Copyright (C) 2009, 2010 Canonical Ltd
1
# Copyright (C) 2009 Canonical Ltd
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
33
33
def load_tests(standard_tests, module, loader):
34
34
"""Parameterize tests for all versions of groupcompress."""
35
global compiled_static_tuple_feature
36
suite, compiled_static_tuple_feature = tests.permute_tests_for_extension(
37
standard_tests, loader, 'bzrlib._static_tuple_py',
38
'bzrlib._static_tuple_c')
36
('python', {'module': _static_tuple_py}),
38
suite = loader.suiteClass()
39
if CompiledStaticTuple.available():
40
from bzrlib import _static_tuple_c
41
scenarios.append(('C', {'module': _static_tuple_c}))
43
# the compiled module isn't available, so we add a failing test
44
class FailWithoutFeature(tests.TestCase):
46
self.requireFeature(CompiledStaticTuple)
47
suite.addTest(loader.loadTestsFromTestCase(FailWithoutFeature))
48
result = tests.multiply_tests(standard_tests, scenarios, suite)
52
class _CompiledStaticTuple(tests.Feature):
56
import bzrlib._static_tuple_c
61
def feature_name(self):
62
return 'bzrlib._static_tuple_c'
64
CompiledStaticTuple = _CompiledStaticTuple()
42
67
class _Meliae(tests.Feature):
77
102
def test_create_bad_args(self):
78
103
args_256 = ['a']*256
80
self.assertRaises(TypeError, self.module.StaticTuple, *args_256)
105
self.assertRaises(ValueError, self.module.StaticTuple, *args_256)
81
106
args_300 = ['a']*300
82
self.assertRaises(TypeError, self.module.StaticTuple, *args_300)
107
self.assertRaises(ValueError, self.module.StaticTuple, *args_300)
84
109
self.assertRaises(TypeError, self.module.StaticTuple, object())
616
641
# Make sure the right implementation is available from
617
642
# bzrlib.static_tuple.StaticTuple.
618
643
if self.module is _static_tuple_py:
619
if compiled_static_tuple_feature.available():
644
if CompiledStaticTuple.available():
620
645
# We will be using the C version
622
647
self.assertIs(static_tuple.StaticTuple,