Python code coverage is analyzed using coverage.py reports

Python code coverage is analyzed using coverage.py reports … here is a solution to the problem.

Python code coverage is analyzed using coverage.py reports

Here are my coverage statistics:

Coverage: 76%
310 Statement 253 Run 94 Branch 57 Missing 13 Exclude 27 Parts

Can anyone help calculate the formula for this percentage?

Solution

Because of the way branches are counted, you can’t get an accurate total from these displayed numbers. But roughly speaking, the total is:

total = (executions)/(possible executions)

The number of executions is the number of statements plus the number of

branches minus the number of excluded statements.

possible executions = statements + branches - excluded

The number of executions is the number of statements run plus the number of branches taken. We don’t show the number of branches taken, so you’ll have to estimate:

executions = (run statements) + (total branches - partial branches)

This gives us:

total = (253+94-27)/(310+94-13) = 81.8%

Related Problems and Solutions