Bug report
Bug description:
When using autospec=True the patched async function only has calls registered after the coroutine is awaited. This behavior started happening after I upgraded from 3.12 to 3.13.6.
Code to reproduce
File tests/other_module.py
asyncdefa(value):
returnvalue*2
File tests/test_1.py
fromunittest.mockimportpatchimportpytestimportother_modulepytestmark=pytest.mark.asyncio(loop_scope="session")
defb(value):
returnother_module.a(value)
asyncdeftest_1():
withpatch.object(other_module, "a", side_effect=other_module.a, autospec=True) asa_mock:
result=b(10)
assertnota_mock.called# This should be True because 'a' was called, but it's Falseawaitresultasserta_mock.called# Now it's True
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Bug report
Bug description:
When using
autospec=Truethe patched async function only has calls registered after the coroutine is awaited. This behavior started happening after I upgraded from 3.12 to 3.13.6.Code to reproduce
File
tests/other_module.pyFile
tests/test_1.pyCPython versions tested on:
3.13
Operating systems tested on:
Linux