Skip to content

Commit 60a5d65

Browse files
authored
docs: explain partial coverage reports on generator expressions (#1789)
Ref #1617
1 parent 0700018 commit 60a5d65

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doc/branch.rst

+13
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,16 @@ Here the while loop will never complete because the break will always be taken
116116
at some point. Coverage.py can't work that out on its own, but the "no branch"
117117
pragma indicates that the branch is known to be partial, and the line is not
118118
flagged.
119+
120+
Generator expressions
121+
=====================
122+
123+
Generator expressions may also report partial branch coverage. Consider the
124+
following example::
125+
126+
value = next(i in range(1))
127+
128+
While we might expect this line of code to be reported as covered, the
129+
generator did not iterate until ``StopIteration`` is raised, the indication
130+
that the loop is complete. This is another case
131+
where adding ``# pragma: no branch`` may be desirable.

0 commit comments

Comments
 (0)