429
429
self.assertIsNot(None, self.module._C_API)
431
def test_from_sequence_tuple(self):
432
st = self.module.StaticTuple.from_sequence(('foo', 'bar'))
433
self.assertIsInstance(st, self.module.StaticTuple)
434
self.assertEqual(('foo', 'bar'), st)
436
def test_from_sequence_str(self):
437
st = self.module.StaticTuple.from_sequence('foo')
438
self.assertIsInstance(st, self.module.StaticTuple)
439
self.assertEqual(('f', 'o', 'o'), st)
441
def test_from_sequence_list(self):
442
st = self.module.StaticTuple.from_sequence(['foo', 'bar'])
443
self.assertIsInstance(st, self.module.StaticTuple)
444
self.assertEqual(('foo', 'bar'), st)
446
def test_from_sequence_static_tuple(self):
447
st = self.module.StaticTuple('foo', 'bar')
448
st2 = self.module.StaticTuple.from_sequence(st)
449
# If the source is a StaticTuple already, we return the exact object
450
self.assertIs(st, st2)
452
def test_from_sequence_not_sequence(self):
453
self.assertRaises(TypeError,
454
self.module.StaticTuple.from_sequence, object())
456
def test_from_sequence_incorrect_args(self):
457
self.assertRaises(TypeError,
458
self.module.StaticTuple.from_sequence, object(), 'a')
459
self.assertRaises(TypeError,
460
self.module.StaticTuple.from_sequence, foo='a')
431
462
def test_static_tuple_thunk(self):
432
463
# Make sure the right implementation is available from
433
464
# bzrlib.static_tuple.StaticTuple.
435
466
if CompiledStaticTuple.available():
436
467
# We will be using the C version
438
self.assertIs(static_tuple.StaticTuple,
469
self.assertIs(static_tuple.StaticTuple,
439
470
self.module.StaticTuple)