mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #22995: Default implementation of __reduce__ and __reduce_ex__ now
rejects builtin types with not defined __new__. Added tests for non-pickleable types.
This commit is contained in:
commit
12ab296f82
7 changed files with 99 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
|||
import collections
|
||||
import copy
|
||||
import pickle
|
||||
import unittest
|
||||
|
||||
class DictSetTest(unittest.TestCase):
|
||||
|
@ -198,6 +200,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)
|
||||
|
||||
def test_abc_registry(self):
|
||||
d = dict(a=1)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue