Skip to content

Commit a77bba7

Browse files
committed
test: add a test for #1836, by Marco Ricci
1 parent 515d99c commit a77bba7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/test_html.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,36 @@ def test_bug_1828(self) -> None:
12031203
'3 ccc"]',
12041204
]
12051205

1206+
@pytest.mark.parametrize(
1207+
"leader", ["", "f", "r", "fr", "rf"],
1208+
ids=["string", "f-string", "raw_string", "f-raw_string", "raw_f-string"]
1209+
)
1210+
def test_bug_1836(self, leader: str) -> None:
1211+
# https://github.com/nedbat/coveragepy/issues/1836
1212+
self.make_file("py312_fstrings.py", f"""\
1213+
prog_name = 'bug.py'
1214+
err_msg = {leader}'''\\
1215+
{{prog_name}}: ERROR: This is the first line of the error.
1216+
{{prog_name}}: ERROR: This is the second line of the error.
1217+
\\
1218+
{{prog_name}}: ERROR: This is the third line of the error.
1219+
'''
1220+
""")
1221+
1222+
cov = coverage.Coverage()
1223+
py312_fstrings = self.start_import_stop(cov, "py312_fstrings")
1224+
cov.html_report(py312_fstrings)
1225+
1226+
assert self.get_html_report_text_lines("py312_fstrings.py") == [
1227+
"1" + "prog_name = 'bug.py'",
1228+
"2" + f"err_msg = {leader}'''\\",
1229+
"3" + "{prog_name}: ERROR: This is the first line of the error.",
1230+
"4" + "{prog_name}: ERROR: This is the second line of the error.",
1231+
"5" + "\\",
1232+
"6" + "{prog_name}: ERROR: This is the third line of the error.",
1233+
"7" + "'''",
1234+
]
1235+
12061236
def test_unicode(self) -> None:
12071237
surrogate = "\U000e0100"
12081238

0 commit comments

Comments
 (0)