[issue25599] asyncio.iscoroutinefunction returns unexpected results when presented with unittest.mock.Mock

Theron Luhn report at bugs.python.org
Tue Nov 10 12:26:22 EST 2015


New submission from Theron Luhn:

>>> asyncio.iscoroutinefunction(unittest.mock.Mock())
<Mock name='mock._is_coroutine' id='4544068072'>

This is an unexpected response, both in type (Mock rather than boolean) and value (truthy).

inspect.iscoroutinefunction behaves as expected.

Workaround:

>>> m = unittest.mock.Mock()
>>> m._is_coroutine = False
>>> asyncio.iscoroutinefunction(m)
False

----------
components: asyncio
messages: 254457
nosy: Theron Luhn, gvanrossum, haypo, yselivanov
priority: normal
severity: normal
status: open
title: asyncio.iscoroutinefunction returns unexpected results when presented with unittest.mock.Mock
type: behavior
versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25599>
_______________________________________


More information about the Python-bugs-list mailing list