Skip to content

Commit

Permalink
docs: explain partial coverage reports on generator expressions (#1789)
Browse files Browse the repository at this point in the history
Ref #1617
  • Loading branch information
marcgibbons committed May 20, 2024
1 parent 0700018 commit 60a5d65
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions doc/branch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,16 @@ Here the while loop will never complete because the break will always be taken
at some point. Coverage.py can't work that out on its own, but the "no branch"
pragma indicates that the branch is known to be partial, and the line is not
flagged.

Generator expressions
=====================

Generator expressions may also report partial branch coverage. Consider the
following example::

value = next(i in range(1))

While we might expect this line of code to be reported as covered, the
generator did not iterate until ``StopIteration`` is raised, the indication
that the loop is complete. This is another case
where adding ``# pragma: no branch`` may be desirable.

0 comments on commit 60a5d65

Please sign in to comment.