Skip to content

Add words explaining partial coverage reports on generator expressions #1789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.