-
Hi everyone. I am having an issue with pytest coverage report for my FastAPI project. Did anybody here have this issue? I have seen only one mention of it in stackoverflow, but not resolved. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
Maybe related to nedbat/coveragepy#1082 ? |
Beta Was this translation helpful? Give feedback.
-
@Kludex Yes, looks like it. It was exactly my case: I have a FastAPI together with SQLAlchemy async calls. After reading the thread and other related threads carefully I noticed that coverage report in my project stopped after async calls to SQLAlchemy engine. As I understood the reason for it is that FastAPI uses threads, and SQLAlchemy uses greenlet to provide async behavior and coverage has problems tracking both in the same project. I tried to play around with the coveragerc settings and came out using "concurrency=greenlet" config. So far, the report looks much better and shows hits on the code lines after SQLAlchemy async calls. I will check it further on. Thank you for the link. I would definitely not have dug it out by myself! |
Beta Was this translation helpful? Give feedback.
-
I'm also testing against a FastAPI project with a mix of async routes, async SQLAlchemy and synchronous FastAPI dependencies. Instructing coverage to use Adding a voodoo |
Beta Was this translation helpful? Give feedback.
-
A fix for this has been merged to the coverage repository. Once the new coverage version is out you will be able to specify multiple |
Beta Was this translation helpful? Give feedback.
-
After reading the above and making sure I had a recent version of coverage ( [coverage:run]
concurrency =
greenlet
thread |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Maybe related to nedbat/coveragepy#1082 ?