mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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:
parent
a9dcdabccb
commit
d7a4415599
6 changed files with 78 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue