diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-12 09:31:51 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-11-12 09:31:51 (GMT) |
commit | 609a2e17ada69ba47e8011e9d5a0eba649a0ef65 (patch) | |
tree | edf177dd3226efd5051163d1267b83ecd692094c /Lib/test/test_dictviews.py | |
parent | 45bde5d2ee58ac4887b034569c2ee930b3cfb8af (diff) | |
parent | d7a441559921804a5a6141c3ec42f896f8f3b010 (diff) | |
download | cpython-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_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 8d33801..787ef20 100644 --- a/Lib/test/test_dictviews.py +++ b/Lib/test/test_dictviews.py @@ -1,3 +1,5 @@ +import copy +import pickle import unittest class DictSetTest(unittest.TestCase): @@ -197,6 +199,22 @@ class DictSetTest(unittest.TestCase): d[42] = d.values() self.assertRaises(RecursionError, 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) + if __name__ == "__main__": unittest.main() |