/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-23 18:40:24 UTC
  • mfrom: (4759.2.20 statictuple-pickling)
  • Revision ID: pqm@pqm.ubuntu.com-20091023184024-igfxawbh4tkag0ui
(Matt Nordhoff) Add Pickle support to the StaticTuple class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for the StaticTuple type."""
18
18
 
 
19
import cPickle
19
20
import gc
20
21
import sys
21
22
 
577
578
        self.assertRaises(TypeError,
578
579
                          self.module.StaticTuple.from_sequence, foo='a')
579
580
 
 
581
    def test_pickle(self):
 
582
        st = self.module.StaticTuple('foo', 'bar')
 
583
        pickled = cPickle.dumps(st)
 
584
        unpickled = cPickle.loads(pickled)
 
585
        self.assertEqual(unpickled, st)
 
586
 
 
587
    def test_pickle_empty(self):
 
588
        st = self.module.StaticTuple()
 
589
        pickled = cPickle.dumps(st)
 
590
        unpickled = cPickle.loads(pickled)
 
591
        self.assertIs(st, unpickled)
 
592
 
 
593
    def test_pickle_nested(self):
 
594
        st = self.module.StaticTuple('foo', self.module.StaticTuple('bar'))
 
595
        pickled = cPickle.dumps(st)
 
596
        unpickled = cPickle.loads(pickled)
 
597
        self.assertEqual(unpickled, st)
 
598
 
580
599
    def test_static_tuple_thunk(self):
581
600
        # Make sure the right implementation is available from
582
601
        # bzrlib.static_tuple.StaticTuple.