summaryrefslogtreecommitdiff
path: root/Lib/test/test_dictviews.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-11-12 11:23:04 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2015-11-12 11:23:04 +0200
commitb7f87a12287127884384ba7314f171698d666db2 (patch)
tree7e29bce7dc80df4412eee426c9e9fe61afa422e1 /Lib/test/test_dictviews.py
parentb337240e945ed9bd6608be307abb662ab3e27749 (diff)
downloadcpython-b7f87a12287127884384ba7314f171698d666db2.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_dictviews.py')
-rw-r--r--Lib/test/test_dictviews.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py
index 7b02ea9eba..c7714cf790 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)