Understands covergage for Python w/ Pytest

Hello Community,

I am an OSS package owner and I’m trying to use codecov to understand my unit-tests (Python w/ Pytest) gaps. I’ve had codecov configured for a while, but didn’t pay enough attention to it until recently when I’m trying to improve my automated regression.

I noticed that even though I have a unit-test for an asyncio simple function (example below). I would still get missed for the function body, even though I’m certain the unit test covers the flow.

I’m using GitHub & Travis, and Python 3.9 w/ latest pytest. I compared master and various branches and the results are similar.

Here is how it looks like. As you can see the function is hit and appears in Green, though the content appears in Red. I don’t quite understand how to interpret these results. I went thru the documentation and couldn’t figure this either:

Thanks in advance!

@amor71 I feel like I see this quite often. Function definitions are hit, but the actual functions are never run. This is a guesstimation, but I think the functions are loaded/parsed/“compiled” in case you do call Accounts.create(...) at some point.

I’ll get something more concrete, but the important thing is that your code inside the function is never actually called.

The internet says the classes and functions are getting imported. That makes sense to me. So coverage is noting that they are being loaded up but not actually being run.