diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-02-16 18:49:16 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-02-16 18:49:16 (GMT) |
commit | e686c5c3e81526d93043cc15062dd8289b2c65ee (patch) | |
tree | 1d64a213cf4ec4a15489c30b38a9ce2643650c21 /Lib | |
parent | 1bcfbd5107c4160a77bc9a02446694ea679e570c (diff) | |
download | cpython-e686c5c3e81526d93043cc15062dd8289b2c65ee.zip cpython-e686c5c3e81526d93043cc15062dd8289b2c65ee.tar.gz cpython-e686c5c3e81526d93043cc15062dd8289b2c65ee.tar.bz2 |
look up __getnewargs__ and __getnewargs_ex__ on the object type (#16251)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_descr.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 508e02b..2a9e329 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -4701,6 +4701,20 @@ class PicklingTests(unittest.TestCase): for proto in protocols: self._check_reduce(proto, obj, listitems=list(obj)) + def test_special_method_lookup(self): + protocols = range(pickle.HIGHEST_PROTOCOL + 1) + class Picky: + def __getstate__(self): + return {} + + def __getattr__(self, attr): + if attr in ("__getnewargs__", "__getnewargs_ex__"): + raise AssertionError(attr) + return None + for protocol in protocols: + state = {} if protocol >= 2 else None + self._check_reduce(protocol, Picky(), state=state) + def _assert_is_copy(self, obj, objcopy, msg=None): """Utility method to verify if two objects are copies of each others. """ |