mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #22777: Test pickling with all protocols.
This commit is contained in:
commit
65ee4674e2
31 changed files with 704 additions and 623 deletions
|
@ -367,13 +367,14 @@ class MemoryTestMixin:
|
|||
# the module-level.
|
||||
import __main__
|
||||
PickleTestMemIO.__module__ = '__main__'
|
||||
PickleTestMemIO.__qualname__ = PickleTestMemIO.__name__
|
||||
__main__.PickleTestMemIO = PickleTestMemIO
|
||||
submemio = PickleTestMemIO(buf, 80)
|
||||
submemio.seek(2)
|
||||
|
||||
# We only support pickle protocol 2 and onward since we use extended
|
||||
# __reduce__ API of PEP 307 to provide pickling support.
|
||||
for proto in range(2, pickle.HIGHEST_PROTOCOL):
|
||||
for proto in range(2, pickle.HIGHEST_PROTOCOL + 1):
|
||||
for obj in (memio, submemio):
|
||||
obj2 = pickle.loads(pickle.dumps(obj, protocol=proto))
|
||||
self.assertEqual(obj.getvalue(), obj2.getvalue())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue