Karthikeyan Singaravelan <tir.kar...@gmail.com> added the comment:

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'

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue26140>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to