diff options
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() |