~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Lib/test/pickletester.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-03-11 13:30:19 UTC
  • mto: (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100311133019-sblbooa3uqrkoe70
Tags: upstream-2.6.5~rc2
ImportĀ upstreamĀ versionĀ 2.6.5~rc2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1020
1020
        s = StringIO.StringIO("X''.")
1021
1021
        self.assertRaises(EOFError, self.module.load, s)
1022
1022
 
 
1023
    def test_restricted(self):
 
1024
        # issue7128: cPickle failed in restricted mode
 
1025
        builtins = {self.module.__name__: self.module,
 
1026
                    '__import__': __import__}
 
1027
        d = {}
 
1028
        teststr = "def f(): {0}.dumps(0)".format(self.module.__name__)
 
1029
        exec teststr in {'__builtins__': builtins}, d
 
1030
        d['f']()
 
1031
 
 
1032
    def test_bad_input(self):
 
1033
        # Test issue4298
 
1034
        s = '\x58\0\0\0\x54'
 
1035
        self.assertRaises(EOFError, self.module.loads, s)
 
1036
        # Test issue7455
 
1037
        s = '0'
 
1038
        # XXX Why doesn't pickle raise UnpicklingError?
 
1039
        self.assertRaises((IndexError, cPickle.UnpicklingError),
 
1040
                          self.module.loads, s)
 
1041
 
1023
1042
class AbstractPersistentPicklerTests(unittest.TestCase):
1024
1043
 
1025
1044
    # This class defines persistent_id() and persistent_load()