/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__static_tuple.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-27 16:54:11 UTC
  • mfrom: (4771.2.2 2.1-st-from-iterable)
  • Revision ID: pqm@pqm.ubuntu.com-20091027165411-s996a4rrdm66jq99
(Matt Nordhoff,
        jam) Allow StaticTuple.from_sequence() to support iterables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
571
571
    def test_from_sequence_not_sequence(self):
572
572
        self.assertRaises(TypeError,
573
573
                          self.module.StaticTuple.from_sequence, object())
 
574
        self.assertRaises(TypeError,
 
575
                          self.module.StaticTuple.from_sequence, 10)
574
576
 
575
577
    def test_from_sequence_incorrect_args(self):
576
578
        self.assertRaises(TypeError,
578
580
        self.assertRaises(TypeError,
579
581
                          self.module.StaticTuple.from_sequence, foo='a')
580
582
 
 
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)
 
587
 
 
588
    def test_from_sequence_generator(self):
 
589
        def generate_tuple():
 
590
            yield 'foo'
 
591
            yield 'bar'
 
592
        st = self.module.StaticTuple.from_sequence(generate_tuple())
 
593
        self.assertIsInstance(st, self.module.StaticTuple)
 
594
        self.assertEqual(('foo', 'bar'), st)
 
595
 
581
596
    def test_pickle(self):
582
597
        st = self.module.StaticTuple('foo', 'bar')
583
598
        pickled = cPickle.dumps(st)