Message352329
I believe it's still a problem with Mock though MagicMock and AsyncMock work but I am not sure what would be the correct behavior that whether Mock should behave like a coroutine or not as per the discussion here.
./python.exe
Python 3.9.0a0 (heads/master:375a3e2bdb, Sep 13 2019, 14:18:36)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from unittest.mock import Mock, MagicMock, AsyncMock
>>> import inspect
>>> def f(): pass
...
>>> for m in MagicMock, AsyncMock : print(inspect.iscoroutinefunction(m(f)))
...
True
True
>>> for m in Mock, MagicMock, AsyncMock : print(inspect.iscoroutinefunction(m(f)))
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/inspect.py", line 194, in iscoroutinefunction
return _has_code_flag(obj, CO_COROUTINE)
File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/inspect.py", line 180, in _has_code_flag
return bool(f.__code__.co_flags & flag)
TypeError: unsupported operand type(s) for &: 'Mock' and 'int' |
|
Date |
User |
Action |
Args |
2019-09-13 13:38:49 | xtreak | set | recipients:
+ xtreak, michael.foord, asvetlov, yselivanov, miyakogi, lisroach |
2019-09-13 13:38:49 | xtreak | set | messageid: <1568381929.61.0.153245422318.issue26140@roundup.psfhosted.org> |
2019-09-13 13:38:49 | xtreak | link | issue26140 messages |
2019-09-13 13:38:49 | xtreak | create | |
|