diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-02-16 13:49:16 -0500 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-02-16 13:49:16 -0500 |
commit | 2626fab4c7e1cc3daffe2071c8894c54dac8680a (patch) | |
tree | 7f69af94ede59ee5c2d0363766ec97a42f50980a /Lib/test/test_descr.py | |
parent | c00fa6387d9a2ceb3b4c4fa94646279c8b70fb4f (diff) | |
download | cpython-git-2626fab4c7e1cc3daffe2071c8894c54dac8680a.tar.gz |
look up __getnewargs__ and __getnewargs_ex__ on the object type (#16251)
Diffstat (limited to 'Lib/test/test_descr.py')
-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 508e02bdae..2a9e329633 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. """ |