mocker.stub() is a coroutine function
AstraLuma opened this issue · 1 comments
AstraLuma commented
def test_icf_sync(mocker):
func = mocker.stub('func')
assert not inspect.iscoroutinefunction(func)
def test_icf_async(mocker):
func = mocker.async_stub('func')
assert inspect.iscoroutinefunction(func)
Expected: mocker.stub()
returns something that doesn't resemble a coroutine.
Observed: mocker.stub()
is detected as a coroutine.
nicoddemus commented
Hi @AstraLuma,
mocker.stub
is just a thin wrapper which calls unittest.mock.MagicMock
:
pytest-mock/src/pytest_mock/plugin.py
Lines 182 to 185 in d5243b0
Can you replace your mocker.stub
call by unittest.mock.MagicMock
and see if you have the same behavior? If you do then the behavior is expected, and you can raise the question upstream to see if this is intended by unittest.mock
or it should behave differently.