mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-85934: Use getattr_static when adding mock spec (#22209)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
This commit is contained in:
parent
6b1510cf11
commit
2e0931046d
3 changed files with 40 additions and 1 deletions
|
@ -526,7 +526,13 @@ class NonCallableMock(Base):
|
|||
spec_list = dir(spec)
|
||||
|
||||
for attr in spec_list:
|
||||
if iscoroutinefunction(getattr(spec, attr, None)):
|
||||
static_attr = inspect.getattr_static(spec, attr, None)
|
||||
unwrapped_attr = static_attr
|
||||
try:
|
||||
unwrapped_attr = inspect.unwrap(unwrapped_attr)
|
||||
except ValueError:
|
||||
pass
|
||||
if iscoroutinefunction(unwrapped_attr):
|
||||
_spec_asyncs.append(attr)
|
||||
|
||||
spec = spec_list
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue