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 <>
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 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)))
>>> 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/", line 194, in iscoroutinefunction
    return _has_code_flag(obj, CO_COROUTINE)
  File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/", 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:49xtreaksetrecipients: + xtreak, michael.foord, asvetlov, yselivanov, miyakogi, lisroach
2019-09-13 13:38:49xtreaksetmessageid: <>
2019-09-13 13:38:49xtreaklinkissue26140 messages
2019-09-13 13:38:49xtreakcreate