148
148
k = self.module.StaticTuple('foo')
150
150
self.assertEqual(('foo',), t)
151
self.assertIsInstance(t, tuple)
152
self.assertFalse(isinstance(t, self.module.StaticTuple))
151
153
k = self.module.StaticTuple('foo', 'bar')
153
155
self.assertEqual(('foo', 'bar'), t)
156
k2 = self.module.StaticTuple(1, k)
158
self.assertIsInstance(t, tuple)
159
# For pickling to work, we need to keep the sub-items as StaticTuple so
160
# that it knows that they also need to be converted.
161
self.assertIsInstance(t[1], self.module.StaticTuple)
162
self.assertEqual((1, ('foo', 'bar')), t)
164
def test_as_tuples(self):
165
k1 = self.module.StaticTuple('foo', 'bar')
166
t = static_tuple.as_tuples(k1)
167
self.assertIsInstance(t, tuple)
168
self.assertEqual(('foo', 'bar'), t)
169
k2 = self.module.StaticTuple(1, k1)
170
t = static_tuple.as_tuples(k2)
171
self.assertIsInstance(t, tuple)
172
self.assertIsInstance(t[1], tuple)
173
self.assertEqual((1, ('foo', 'bar')), t)
175
t = static_tuple.as_tuples(mixed)
176
self.assertIsInstance(t, tuple)
177
self.assertIsInstance(t[1], tuple)
178
self.assertEqual((1, ('foo', 'bar')), t)
155
180
def test_len(self):
156
181
k = self.module.StaticTuple()