You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from unittest.mock import create_autospec
class X:
@property
def myprop(self):
raise Exception("some bug")
create_autospec(X())
Now you could tell for me to fix X. The problem though is that in my project the problem is much more complex. X is some other class that is being autospeced and the getter touches some mock objects it does not like.
Your environment
CPython versions tested on: 3.10
Operating system and architecture: Windows
Fix
--- a\unittest\mock.py
+++ b\unittest\mock.py
for attr in dir(spec):
- if iscoroutinefunction(getattr(spec, attr, None)):
- _spec_asyncs.append(attr)
+ try::
+ value = getattr(spec, attr, None)
+ except:
+ pass
+ else:
+ if iscoroutinefunction(value):
+ _spec_asyncs.append(attr)
Bug report
This crashes. It should not.
Now you could tell for me to fix
X. The problem though is that in my project the problem is much more complex. X is some other class that is being autospeced and the getter touches some mock objects it does not like.Your environment
Fix