Skip to content

Commit 898e94a

Browse files
committed
fix: another possible assert changed back to a conditional.
1 parent 42961d6 commit 898e94a

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

CHANGES.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ upgrading your version of coverage.py.
2323
Unreleased
2424
----------
2525

26-
Nothing yet.
26+
- fix: ugh, the other assert from 7.6.5 can also be encountered in the wild,
27+
so it's been restored to a conditional. Sorry for the churn.
2728

2829

2930
.. start-releases

coverage/parser.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ def _line_numbers(self) -> Iterable[TLineNo]:
444444
if line_incr >= 0x80:
445445
line_incr -= 0x100
446446
line_num += line_incr
447-
assert line_num != last_line_num, f"Oops: {self.code.co_name}@{line_num}"
448-
yield line_num
447+
if line_num != last_line_num:
448+
yield line_num
449449

450450
def _find_statements(self) -> Iterable[TLineNo]:
451451
"""Find the statements in `self.code`.

tests/test_parser.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,22 @@ def test_fuzzed_double_parse(self) -> None:
198198
self.parse_text("]")
199199

200200
def test_bug_1891(self) -> None:
201-
# This code exercises a code path I thought was impossible.
201+
# These examples exercise code paths I thought were impossible.
202202
parser = self.parse_text("""\
203203
res = siblings(
204204
'configure',
205205
**ca,
206206
)
207207
""")
208-
assert parser.exit_counts() == { 1:1 }
208+
assert parser.exit_counts() == {1: 1}
209+
parser = self.parse_text("""\
210+
def g2():
211+
try:
212+
return 2
213+
finally:
214+
return 3
215+
""")
216+
assert parser.exit_counts() == {1: 1, 2: 1, 3: 1, 5: 1}
209217

210218

211219
class ExclusionParserTest(PythonParserTestBase):

0 commit comments

Comments
 (0)