diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-12 09:23:04 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-12 09:23:04 (GMT) |
commit | d7a441559921804a5a6141c3ec42f896f8f3b010 (patch) | |
tree | eaeaa693fe1af5871f54222f7d07d7cc49d3dd16 /Lib/test/test_dictviews.py | |
parent | a9dcdabccb1a1f7c76030c0b188ecaf7ab599e57 (diff) | |
download | cpython-d7a441559921804a5a6141c3ec42f896f8f3b010.zip cpython-d7a441559921804a5a6141c3ec42f896f8f3b010.tar.gz cpython-d7a441559921804a5a6141c3ec42f896f8f3b010.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_dictviews.py')
-rw-r--r-- | Lib/test/test_dictviews.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py index 7b02ea9..c7714cf 100644 --- a/Lib/test/test_dictviews.py +++ b/Lib/test/test_dictviews.py @@ -1,3 +1,5 @@ +import copy +import pickle import unittest from test import support @@ -198,6 +200,22 @@ class DictSetTest(unittest.TestCase): d[42] = d.values() self.assertRaises(RuntimeError, repr, d) + def test_copy(self): + d = {1: 10, "a": "ABC"} + self.assertRaises(TypeError, copy.copy, d.keys()) + self.assertRaises(TypeError, copy.copy, d.values()) + self.assertRaises(TypeError, copy.copy, d.items()) + + def test_pickle(self): + d = {1: 10, "a": "ABC"} + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + self.assertRaises((TypeError, pickle.PicklingError), + pickle.dumps, d.keys(), proto) + self.assertRaises((TypeError, pickle.PicklingError), + pickle.dumps, d.values(), proto) + self.assertRaises((TypeError, pickle.PicklingError), + pickle.dumps, d.items(), proto) + def test_main(): support.run_unittest(DictSetTest) |