Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Open
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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*2File 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 TrueCPython versions tested on:
3.13
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Todo