79
79
_shalom = u'\u05e9\u05dc\u05d5\u05dd'
82
encoding_scenarios = [
82
class EncodingTestAdapter(object):
83
"""A tool to generate a suite, testing multiple encodings for a single test.
85
This is similar to bzrlib.transport.TransportTestProviderAdapter.
86
It is done by copying the test once for each encoding, and injecting
87
the encoding name, and the list of valid strings for that encoding.
88
Each copy is also given a new id() to make it easy to identify.
83
92
# Permutation 1 of utf-8
87
'message': _yellow_horse,
88
'filename': _shrimp_sandwich,
89
'directory': _nihonjin,
93
('utf-8', 1, {'committer':_erik
94
, 'message':_yellow_horse
95
, 'filename':_shrimp_sandwich
96
, 'directory':_nihonjin}),
93
97
# Permutation 2 of utf-8
96
'committer': _alexander,
97
'message': u'Testing ' + _mu,
106
'message': u'Testing ' + _mu,
107
'filename': _juju_alt,
108
'directory': _shrimp_sandwich,
110
'encoding': 'iso-8859-1',
114
'committer': _someone,
115
'message': _yellow_horse,
117
'directory': _something,
119
'encoding': 'iso-8859-2',
123
'committer': _alexander,
124
'message': u'Testing ' + _mu,
125
'filename': _russian_test,
126
'directory': _russian_test + 'dir',
128
'encoding': 'cp1251',
130
# The iso-8859-1 tests run on a default windows cp437 installation
131
# and it takes a long time to run an extra permutation of the tests
132
# But just in case we want to add this back in:
133
# ('cp437', {'committer':_erik
134
# , 'message':u'Testing ' + _mu
135
# , 'filename':'file_' + _omega
136
# , 'directory':_epsilon + '_dir',
137
# 'encoding': 'cp437'}),
98
('utf-8', 2, {'committer':_alexander
99
, 'message':u'Testing ' + _mu
101
, 'directory':_juju}),
102
('iso-8859-1', 0, {'committer':_erik
103
, 'message':u'Testing ' + _mu
104
, 'filename':_juju_alt
105
, 'directory':_shrimp_sandwich}),
106
('iso-8859-2', 0, {'committer':_someone
107
, 'message':_yellow_horse
109
, 'directory':_something}),
110
('cp1251', 0, {'committer':_alexander
111
, 'message':u'Testing ' + _mu
112
, 'filename':_russian_test
113
, 'directory':_russian_test + 'dir'}),
114
('cp437', 0, {'committer':_erik
115
, 'message':u'Testing ' + _mu
116
, 'filename':'file_' + _omega
117
, 'directory':_epsilon + '_dir'}),
120
def adapt(self, test):
122
for encoding, count, info in self._encodings:
123
new_test = deepcopy(test)
124
new_test.encoding = encoding
126
def make_new_test_id():
128
new_id = "%s(%s,%s)" % (new_test.id(), encoding, count)
130
new_id = "%s(%s)" % (new_test.id(), encoding)
131
return lambda: new_id
132
new_test.id = make_new_test_id()
133
result.addTest(new_test)