PyTest Stuck When Upgrading From Python 3.8.3 to 3.10.7

225 Views Asked by At

I am developing an API in Python using FastAPI. I followed the user guide on https://fastapi.tiangolo.com/ and am very satisfied with the application.

I wanted to upgrade the Python version from 3.8.3 to 3.10.7 but I experienced a strange behavior when executing the unit tests. After the successful collection and execution, PyTest does not stop. Therefore all pipelines time out and cannot proceed with the project.

Let me show you the details:

PyTest with 3.8.3 - green

All tests are green and PyTest returns with exit code 0. Good!

After upgrading to 3.10.7 following happens:

enter image description here

It neither locally (Windows) nor on CI (Docker Container) stops. I considered event_loops that may be still running and other test plugins to execute the unit tests. I did not find a suitable solution yet.

Does anyone have an idea what the problem could originate from? Any help is much appreciated.

Cheers,

L.

1

There are 1 best solutions below

0
On

I've found the solution to my problem which was the following:

I used nest_asyncio internally which caused problems when stopping the nested event loop when executing the unit tests, because it did not work at all. I did not necessarily require asyncio to achieve the calls to an API internally. After having it explemented, the unit test stopped as expected. Surprisingly nest_asyncio is working with Python 3.8.3 but not with Python 3.10.7.

Update: GitHub Issue nest_asyncio