416
416
if self.module is _static_tuple_py:
418
418
self.assertIsNot(None, self.module._C_API)
420
def test_from_sequence_tuple(self):
421
st = self.module.StaticTuple.from_sequence(('foo', 'bar'))
422
self.assertIsInstance(st, self.module.StaticTuple)
423
self.assertEqual(('foo', 'bar'), st)
425
def test_from_sequence_str(self):
426
st = self.module.StaticTuple.from_sequence('foo')
427
self.assertIsInstance(st, self.module.StaticTuple)
428
self.assertEqual(('f', 'o', 'o'), st)
430
def test_from_sequence_list(self):
431
st = self.module.StaticTuple.from_sequence(['foo', 'bar'])
432
self.assertIsInstance(st, self.module.StaticTuple)
433
self.assertEqual(('foo', 'bar'), st)
435
def test_from_sequence_static_tuple(self):
436
st = self.module.StaticTuple('foo', 'bar')
437
st2 = self.module.StaticTuple.from_sequence(st)
438
# If the source is a StaticTuple already, we return the exact object
439
self.assertIs(st, st2)
441
def test_from_sequence_not_sequence(self):
442
self.assertRaises(TypeError,
443
self.module.StaticTuple.from_sequence, object())
445
def test_from_sequence_incorrect_args(self):
446
self.assertRaises(TypeError,
447
self.module.StaticTuple.from_sequence, object(), 'a')
448
self.assertRaises(TypeError,
449
self.module.StaticTuple.from_sequence, foo='a')