Skip to content

Commit

Permalink
test: add a test for #1836, by Marco Ricci
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Sep 4, 2024
1 parent 43bb8f2 commit 1b25284
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,36 @@ def test_bug_1828(self) -> None:
'3 ccc"]',
]

@pytest.mark.parametrize(
"leader", ["", "f", "r", "fr", "rf"],
ids=["string", "f-string", "raw_string", "f-raw_string", "raw_f-string"]
)
def test_bug_1836(self, leader) -> None:
# https://github.com/nedbat/coveragepy/issues/1836
self.make_file("py312_fstrings.py", f"""\
prog_name = 'bug.py'
err_msg = {leader}'''\\
{{prog_name}}: ERROR: This is the first line of the error.
{{prog_name}}: ERROR: This is the second line of the error.
\\
{{prog_name}}: ERROR: This is the third line of the error.
'''
""")

cov = coverage.Coverage()
py312_fstrings = self.start_import_stop(cov, "py312_fstrings")
cov.html_report(py312_fstrings)

assert self.get_html_report_text_lines("py312_fstrings.py") == [
"1" + "prog_name = 'bug.py'",
"2" + f"err_msg = {leader}'''\\",
"3" + "{prog_name}: ERROR: This is the first line of the error.",
"4" + "{prog_name}: ERROR: This is the second line of the error.",
"5" + "\\",
"6" + "{prog_name}: ERROR: This is the third line of the error.",
"7" + "'''",
]

def test_unicode(self) -> None:
surrogate = "\U000e0100"

Expand Down

0 comments on commit 1b25284

Please sign in to comment.