diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-11-16 00:28:25 (GMT) |
---|---|---|
committer | Yury Selivanov <yury@magic.io> | 2017-11-16 00:28:25 (GMT) |
commit | f35076a002b958f991d180d6f945344cc5ab3900 (patch) | |
tree | c0e4e49172999a62fcee5836351db8317d977dc8 /Lib/test | |
parent | d15bb5fcad584e113836486d17c6abcbf2168a86 (diff) | |
download | cpython-f35076a002b958f991d180d6f945344cc5ab3900.zip cpython-f35076a002b958f991d180d6f945344cc5ab3900.tar.gz cpython-f35076a002b958f991d180d6f945344cc5ab3900.tar.bz2 |
bpo-32034: Make IncompleteReadError & LimitOverrunError pickleable GH-4409 (#4411)
(cherry picked from commit 43605e6bfa8d49612df4a38460d063d6ba781906)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_asyncio/test_streams.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py index b47433a..6d16d20 100644 --- a/Lib/test/test_asyncio/test_streams.py +++ b/Lib/test/test_asyncio/test_streams.py @@ -3,6 +3,7 @@ import gc import os import queue +import pickle import socket import sys import threading @@ -845,6 +846,23 @@ os.close(fd) stream._transport.__repr__.return_value = "<Transport>" self.assertEqual("<StreamReader t=<Transport>>", repr(stream)) + def test_IncompleteReadError_pickleable(self): + e = asyncio.IncompleteReadError(b'abc', 10) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + with self.subTest(pickle_protocol=proto): + e2 = pickle.loads(pickle.dumps(e, protocol=proto)) + self.assertEqual(str(e), str(e2)) + self.assertEqual(e.partial, e2.partial) + self.assertEqual(e.expected, e2.expected) + + def test_LimitOverrunError_pickleable(self): + e = asyncio.LimitOverrunError('message', 10) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + with self.subTest(pickle_protocol=proto): + e2 = pickle.loads(pickle.dumps(e, protocol=proto)) + self.assertEqual(str(e), str(e2)) + self.assertEqual(e.consumed, e2.consumed) + if __name__ == '__main__': unittest.main() |