@@ -145,7 +145,7 @@ def check_coverage(
145145 self ,
146146 text : str ,
147147 * ,
148- lines : Sequence [TLineNo ] | Sequence [ list [ TLineNo ]] | None = None ,
148+ lines : Sequence [TLineNo ] | None = None ,
149149 missing : str = "" ,
150150 report : str = "" ,
151151 excludes : Iterable [str ] | None = None ,
@@ -157,10 +157,9 @@ def check_coverage(
157157 """Check the coverage measurement of `text`.
158158
159159 The source `text` is run and measured. `lines` are the line numbers
160- that are executable, or a list of possible line numbers, any of which
161- could match. `missing` are the lines not executed, `excludes` are
162- regexes to match against for excluding lines, and `report` is the text
163- of the measurement report.
160+ that are executable, `missing` are the lines not executed, `excludes`
161+ are regexes to match against for excluding lines, and `report` is the
162+ text of the measurement report.
164163
165164 For branch measurement, `branchz` is a string that can be decoded into
166165 arcs in the code (see `arcz_to_arcs` for the encoding scheme).
@@ -200,42 +199,9 @@ def check_coverage(
200199 analysis = cov ._analyze (mod )
201200 statements = sorted (analysis .statements )
202201 if lines :
203- if isinstance (lines [0 ], int ):
204- # lines is just a list of numbers, it must match the statements
205- # found in the code.
206- assert statements == lines , f"lines: { statements !r} != { lines !r} "
207- else :
208- # lines is a list of possible line number lists, one of them
209- # must match.
210- for i , line_list in enumerate (lines ): # pylint: disable=unused-variable
211- if statements == line_list :
212- # PYVERSIONS: we might be able to trim down multiple
213- # lines passed into this function.
214- # Uncomment this code, run the whole test suite, then
215- # sort /tmp/check_coverage_multi_line.out to group the
216- # tests together and see if any of the `lines` elements
217- # haven't been used.
218- # One of the calls in test_successful_coverage passes
219- # three `lines` elements, only one of which is right.
220- # We need to keep that test until we can delete the
221- # multi-lines option entirely.
222- #
223- # import inspect, platform
224- # frinfo = inspect.getframeinfo(inspect.currentframe().f_back)
225- # version = "{} {}.{}".format(
226- # platform.python_implementation(),
227- # *sys.version_info[:2],
228- # )
229- # with open("/tmp/check_coverage_multi_line.out", "a") as f:
230- # print(
231- # f"{frinfo.filename}@{frinfo.lineno}: "
232- # + f"lines {i + 1}/{len(lines)}: {version}",
233- # file=f,
234- # )
235- break
236- else :
237- assert False , f"None of the lines choices matched { statements !r} "
238-
202+ # lines is a list of numbers, it must match the statements
203+ # found in the code.
204+ assert statements == lines , f"lines: { statements !r} != { lines !r} "
239205 missing_formatted = analysis .missing_formatted ()
240206 msg = f"missing: { missing_formatted !r} != { missing !r} "
241207 assert missing_formatted == missing , msg
0 commit comments