mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Use recursive call to ismock()
on unbound method instead of using temporary object.
This commit is contained in:
parent
d3949f8481
commit
4a977ba4e1
@ -173,13 +173,11 @@ def ismock(subject: Any) -> bool:
|
||||
|
||||
# check the object is bound method
|
||||
if isinstance(subject, MethodType) and _method_is_bound(subject):
|
||||
tmp_subject = subject.__func__
|
||||
else:
|
||||
tmp_subject = subject
|
||||
return ismock(subject.__func__)
|
||||
|
||||
try:
|
||||
# check the object is mocked object
|
||||
__mro__ = safe_getattr(type(tmp_subject), '__mro__', [])
|
||||
__mro__ = safe_getattr(type(subject), '__mro__', [])
|
||||
if len(__mro__) > 2 and __mro__[-2] is _MockObject:
|
||||
# A mocked object has a MRO that ends with (..., _MockObject, object).
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user