SIGN IN SIGN UP

bpo-39485: fix corner-case in method-detection of mock (GH-18252)

Replace check for whether something is a method in the mock module. The
previous version fails on PyPy, because there no method wrappers exist
(everything looks like a regular Python-defined function). Thus the
isinstance(getattr(result, '__get__', None), MethodWrapperTypes) check
returns True for any descriptor, not just methods.

This condition could also return erroneously True in CPython for
C-defined descriptors.

Instead to decide whether something is a method, just check directly
whether it's a function defined on the class. This passes all tests on
CPython and fixes the bug on PyPy.
C
Carl Friedrich Bolz-Tereick committed
a327677905956ae0b239ff430a1346dfe265709e
Parent: 3cb49b6
Committed by GitHub <noreply@github.com> on 1/29/2020, 3:43:37 PM