summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_coroutines.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-11-12 09:31:51 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-11-12 09:31:51 (GMT)
commit609a2e17ada69ba47e8011e9d5a0eba649a0ef65 (patch)
treeedf177dd3226efd5051163d1267b83ecd692094c /Lib/test/test_coroutines.py
parent45bde5d2ee58ac4887b034569c2ee930b3cfb8af (diff)
parentd7a441559921804a5a6141c3ec42f896f8f3b010 (diff)
downloadcpython-609a2e17ada69ba47e8011e9d5a0eba649a0ef65.zip
cpython-609a2e17ada69ba47e8011e9d5a0eba649a0ef65.tar.gz
cpython-609a2e17ada69ba47e8011e9d5a0eba649a0ef65.tar.bz2
Issue #22995: Default implementation of __reduce__ and __reduce_ex__ now
rejects builtin types with not defined __new__. Added tests for non-pickleable types.
Diffstat (limited to 'Lib/test/test_coroutines.py')
-rw-r--r--Lib/test/test_coroutines.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py
index b15e244..07c1cdf 100644
--- a/Lib/test/test_coroutines.py
+++ b/Lib/test/test_coroutines.py
@@ -1,5 +1,7 @@
import contextlib
+import copy
import inspect
+import pickle
import sys
import types
import unittest
@@ -1318,6 +1320,34 @@ class CoroutineTest(unittest.TestCase):
run_async(foo())
self.assertEqual(CNT, 0)
+ def test_copy(self):
+ async def func(): pass
+ coro = func()
+ with self.assertRaises(TypeError):
+ copy.copy(coro)
+
+ aw = coro.__await__()
+ try:
+ with self.assertRaises(TypeError):
+ copy.copy(aw)
+ finally:
+ aw.close()
+
+ def test_pickle(self):
+ async def func(): pass
+ coro = func()
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ with self.assertRaises((TypeError, pickle.PicklingError)):
+ pickle.dumps(coro, proto)
+
+ aw = coro.__await__()
+ try:
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ with self.assertRaises((TypeError, pickle.PicklingError)):
+ pickle.dumps(aw, proto)
+ finally:
+ aw.close()
+
class CoroAsyncIOCompatTest(unittest.TestCase):