Skip to content

Commit

Permalink
test: add one more test for the specific nedbat#996 use
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Jul 4, 2024
1 parent d9e53ca commit f317ca9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,24 @@ def test_multiline_exclusion_no_source(self) -> None:
assert parser.raw_statements == set()
assert parser.statements == set()

def test_multiline_exclusion_all_lines_must_match(self) -> None:
# https://github.com/nedbat/coveragepy/issues/996
regex = r"except ValueError:\n *print\('false'\)"
parser = self.parse_text("""\
try:
a = 2
print('false')
except ValueError:
print('false')
except ValueError:
print('something else')
except IndexError:
print('false')
""", regex)
assert parser.lines_matching(regex) == {4, 5}
assert parser.raw_statements == {1, 2, 3, 4, 5, 6, 7, 8, 9}
assert parser.statements == {1, 2, 3, 6, 7, 8, 9}

def test_multiline_exclusion_multiple_matches(self) -> None:
regex = r"print\('.*'\)\n\s+. = \d"
parser = self.parse_text("""\
Expand Down

0 comments on commit f317ca9

Please sign in to comment.