Consider the two test cases below:
@pytest.mark.asyncio
async def test_mocksocket_mocker(mocker):
mocker.patch('socket.socket', wraps=MockSocket)
pass
@pytest.mark.asyncio
async def test_mocksocket_loop_mocker(event_loop, mocker):
mocker.patch('socket.socket', wraps=MockSocket)
pass
The top one reports ERROR at teardown of test_mocksocket_mocker. The bottom one does not report any error. The only difference between them is that the bottom one requests the event_loop fixture.
The error message is quite long. It seems to be caused by MockSocket still being active when _provide_clean_event_loop() is called, and the new event loop failing at initialization.
Also, if the test case calls unittest.mock.patch instead of mocker.patch, then there is no error.
Attached is the test file, full console output, and package versions. This is running on Windows 10.
pytest-asyncio-mock.zip
Consider the two test cases below:
The top one reports
ERROR at teardown of test_mocksocket_mocker. The bottom one does not report any error. The only difference between them is that the bottom one requests theevent_loopfixture.The error message is quite long. It seems to be caused by MockSocket still being active when
_provide_clean_event_loop()is called, and the new event loop failing at initialization.Also, if the test case calls
unittest.mock.patchinstead ofmocker.patch, then there is no error.Attached is the test file, full console output, and package versions. This is running on Windows 10.
pytest-asyncio-mock.zip