summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_generators.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-11-12 09:34:39 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-11-12 09:34:39 (GMT)
commit12ab296f8212029f43e17f4745abcef89f34ea32 (patch)
tree36796bc99ee039866836d6aa68e67722f3205ac6 /Lib/test/test_generators.py
parentd5d6e331fb2e4e33058991dfa0ab7a08dd41e193 (diff)
parent609a2e17ada69ba47e8011e9d5a0eba649a0ef65 (diff)
downloadcpython-12ab296f8212029f43e17f4745abcef89f34ea32.zip
cpython-12ab296f8212029f43e17f4745abcef89f34ea32.tar.gz
cpython-12ab296f8212029f43e17f4745abcef89f34ea32.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_generators.py')
-rw-r--r--Lib/test/test_generators.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 25cc628..b92d5ce 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -1,4 +1,6 @@
+import copy
import gc
+import pickle
import sys
import unittest
import warnings
@@ -111,6 +113,21 @@ class GeneratorTest(unittest.TestCase):
self.assertEqual(gen.__qualname__,
"GeneratorTest.test_name.<locals>.<genexpr>")
+ def test_copy(self):
+ def f():
+ yield 1
+ g = f()
+ with self.assertRaises(TypeError):
+ copy.copy(g)
+
+ def test_pickle(self):
+ def f():
+ yield 1
+ g = f()
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ with self.assertRaises((TypeError, pickle.PicklingError)):
+ pickle.dumps(g, proto)
+
class ExceptionTest(unittest.TestCase):
# Tests for the issue #23353: check that the currently handled exception