diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-12 11:23:04 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-12 11:23:04 +0200 |
commit | d7a441559921804a5a6141c3ec42f896f8f3b010 (patch) | |
tree | eaeaa693fe1af5871f54222f7d07d7cc49d3dd16 /Lib/test/test_generators.py | |
parent | a9dcdabccb1a1f7c76030c0b188ecaf7ab599e57 (diff) | |
download | cpython-git-d7a441559921804a5a6141c3ec42f896f8f3b010.tar.gz |
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.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index 5c455cdd81..604e12d92e 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 weakref @@ -70,6 +72,24 @@ class FinalizationTest(unittest.TestCase): self.assertEqual(cm.exception.value, 2) +class GeneratorTest(unittest.TestCase): + + 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 # is correctly saved/restored in PyEval_EvalFrameEx(). |