File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -116,3 +116,16 @@ Here the while loop will never complete because the break will always be taken
116
116
at some point. Coverage.py can't work that out on its own, but the "no branch"
117
117
pragma indicates that the branch is known to be partial, and the line is not
118
118
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.
You can’t perform that action at this time.
0 commit comments