570
571
def test_from_sequence_not_sequence(self):
571
572
self.assertRaises(TypeError,
572
573
self.module.StaticTuple.from_sequence, object())
574
self.assertRaises(TypeError,
575
self.module.StaticTuple.from_sequence, 10)
574
577
def test_from_sequence_incorrect_args(self):
575
578
self.assertRaises(TypeError,
577
580
self.assertRaises(TypeError,
578
581
self.module.StaticTuple.from_sequence, foo='a')
583
def test_from_sequence_iterable(self):
584
st = self.module.StaticTuple.from_sequence(iter(['foo', 'bar']))
585
self.assertIsInstance(st, self.module.StaticTuple)
586
self.assertEqual(('foo', 'bar'), st)
588
def test_from_sequence_generator(self):
589
def generate_tuple():
592
st = self.module.StaticTuple.from_sequence(generate_tuple())
593
self.assertIsInstance(st, self.module.StaticTuple)
594
self.assertEqual(('foo', 'bar'), st)
596
def test_pickle(self):
597
st = self.module.StaticTuple('foo', 'bar')
598
pickled = cPickle.dumps(st)
599
unpickled = cPickle.loads(pickled)
600
self.assertEqual(unpickled, st)
602
def test_pickle_empty(self):
603
st = self.module.StaticTuple()
604
pickled = cPickle.dumps(st)
605
unpickled = cPickle.loads(pickled)
606
self.assertIs(st, unpickled)
608
def test_pickle_nested(self):
609
st = self.module.StaticTuple('foo', self.module.StaticTuple('bar'))
610
pickled = cPickle.dumps(st)
611
unpickled = cPickle.loads(pickled)
612
self.assertEqual(unpickled, st)
580
614
def test_static_tuple_thunk(self):
581
615
# Make sure the right implementation is available from
582
616
# bzrlib.static_tuple.StaticTuple.