summaryrefslogtreecommitdiff
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-04-08 09:52:59 +0300
committerGitHub <noreply@github.com>2017-04-08 09:52:59 +0300
commit205e00c5cfd495a4dc6dae8e8fa0fb828fb3dca9 (patch)
treef23611c3139118d743b18410c07669a2f41b9d93 /Lib/test/test_descr.py
parentdd9a0a14c89d57e43898d4b866b8c161e4ff8506 (diff)
downloadcpython-git-205e00c5cfd495a4dc6dae8e8fa0fb828fb3dca9.tar.gz
bpo-29914: Fix default implementations of __reduce__ and __reduce_ex__(). (#843)
object.__reduce__() no longer takes arguments, object.__reduce_ex__() now requires one argument.
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 92553e3573..ced25f3fc4 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -5236,7 +5236,20 @@ class PicklingTests(unittest.TestCase):
import copyreg
expected = (copyreg.__newobj__, (A,), (None, {'spam': 42}), None, None)
- self.assertEqual(A().__reduce__(2), expected) # Shouldn't crash
+ self.assertEqual(A().__reduce_ex__(2), expected) # Shouldn't crash
+
+ def test_object_reduce(self):
+ # Issue #29914
+ # __reduce__() takes no arguments
+ object().__reduce__()
+ with self.assertRaises(TypeError):
+ object().__reduce__(0)
+ # __reduce_ex__() takes one integer argument
+ object().__reduce_ex__(0)
+ with self.assertRaises(TypeError):
+ object().__reduce_ex__()
+ with self.assertRaises(TypeError):
+ object().__reduce_ex__(None)
class SharedKeyTests(unittest.TestCase):