cpython: c852c7d8d681 (original) (raw)

--- a/Lib/test/pickletester.py +++ b/Lib/test/pickletester.py @@ -11,8 +11,9 @@ import unittest import weakref from http.cookies import SimpleCookie +from test import support from test.support import (

+ def test_load_from_data0(self): self.assert_is_copy(self._testdata, self.loads(DATA0)) @@ -759,12 +771,7 @@ class AbstractUnpickleTests(unittest.Tes # Try too with a bogus literal. data = b'I' + str(maxint64).encode("ascii") + b'JUNK\n.'

-

def test_unpickle_from_2x(self): # Unpickle non-trivial data from Python 2.x. @@ -849,22 +856,22 @@ class AbstractUnpickleTests(unittest.Tes def test_negative_32b_binbytes(self): # On 32-bit builds, a BINBYTES of 2**31 or more is refused dumped = b'\x80\x03B\xff\xff\xff\xffxyzq\x00.'

@requires_32b def test_negative_32b_binunicode(self): # On 32-bit builds, a BINUNICODE of 2**31 or more is refused dumped = b'\x80\x03X\xff\xff\xff\xffxyzq\x00.'

def test_short_binunicode(self): dumped = b'\x80\x04\x8c\x04\xe2\x82\xac\x00.' self.assertEqual(self.loads(dumped), '\u20ac\x00') def test_misc_get(self):

@@ -879,14 +886,14 @@ class AbstractUnpickleTests(unittest.Tes @requires_32b def test_large_32b_binbytes8(self): dumped = b'\x80\x04\x8e\4\0\0\0\1\0\0\0\xe2\x82\xac\x00.'

@requires_32b def test_large_32b_binunicode8(self): dumped = b'\x80\x04\x8d\4\0\0\0\1\0\0\0\xe2\x82\xac\x00.'

def test_get(self): pickled = b'((lp100000\ng100000\nt.' @@ -915,16 +922,16 @@ class AbstractUnpickleTests(unittest.Tes def test_negative_put(self): # Issue #12847 dumped = b'Va\np-1\n.'

@requires_32b def test_negative_32b_binput(self): # Issue #12847 dumped = b'\x80\x03X\x01\x00\x00\x00ar\xff\xff\xff\xff.'

def test_badly_escaped_string(self):

def test_badly_quoted_string(self): # Issue #17710 @@ -942,7 +949,7 @@ class AbstractUnpickleTests(unittest.Tes b'S\n.', b'S.'] for p in badpickles:

def test_correctly_quoted_string(self): goodpickles = [(b"S''\n.", ''), @@ -989,86 +996,183 @@ class AbstractUnpickleTests(unittest.Tes def test_bad_stack(self): badpickles = [

def test_bad_mark(self): badpickles = [

+

class AbstractPickleTests(unittest.TestCase):

--- a/Lib/test/test_pickle.py +++ b/Lib/test/test_pickle.py @@ -33,6 +33,11 @@ class PyUnpicklerTests(AbstractUnpickleT unpickler = pickle._Unpickler bad_stack_errors = (IndexError,)

def loads(self, buf, **kwds): f = io.BytesIO(buf) @@ -64,6 +69,11 @@ class InMemoryPickleTests(AbstractPickle pickler = pickle._Pickler unpickler = pickle._Unpickler bad_stack_errors = (pickle.UnpicklingError, IndexError)

def dumps(self, arg, protocol=None): return pickle.dumps(arg, protocol) @@ -122,6 +132,9 @@ if has_c_implementation: class CUnpicklerTests(PyUnpicklerTests): unpickler = _pickle.Unpickler bad_stack_errors = (pickle.UnpicklingError,)

class CPicklerTests(PyPicklerTests): pickler = _pickle.Pickler