This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xtreak
Recipients asvetlov, lisroach, michael.foord, miyakogi, xtreak, yselivanov
Date 2019-09-13.13:38:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1568381929.61.0.153245422318.issue26140@roundup.psfhosted.org>
In-reply-to
Content
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'
History
Date User Action Args
2019-09-13 13:38:49xtreaksetrecipients: + xtreak, michael.foord, asvetlov, yselivanov, miyakogi, lisroach
2019-09-13 13:38:49xtreaksetmessageid: <1568381929.61.0.153245422318.issue26140@roundup.psfhosted.org>
2019-09-13 13:38:49xtreaklinkissue26140 messages
2019-09-13 13:38:49xtreakcreate