Skip to content

Commit c9e312e

Browse files
!fixup from review
1 parent a6da838 commit c9e312e

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

changelog/8508.improvement.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Introduce multiline display for warning matching via :py:func:`pytest.warns` and
2-
enhance match comparison for :py:func:`_pytest._code.ExceptionInfo.match` as returned by :py:func:`pytest.raises`.
2+
enhance match comparison for :py:func:`pytest.ExceptionInfo.match` as returned by :py:func:`pytest.raises`.

src/_pytest/recwarn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def found_str():
279279
if not any(issubclass(r.category, self.expected_warning) for r in self):
280280
__tracebackhide__ = True
281281
fail(
282-
f"DID NOT WARN. No warnings of type {self.expected_warning} were emitted. \n"
282+
f"DID NOT WARN. No warnings of type {self.expected_warning} were emitted.\n"
283283
f"The list of emitted warnings is: {found_str()}."
284284
)
285285
elif self.match_expr is not None:

testing/test_recwarn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,23 +262,23 @@ def test_as_contextmanager(self) -> None:
262262
with pytest.warns(RuntimeWarning):
263263
warnings.warn("user", UserWarning)
264264
excinfo.match(
265-
r"DID NOT WARN. No warnings of type \(.+RuntimeWarning.+,\) were emitted. \n"
265+
r"DID NOT WARN. No warnings of type \(.+RuntimeWarning.+,\) were emitted.\n"
266266
r"The list of emitted warnings is: \[UserWarning\('user',?\)\]."
267267
)
268268

269269
with pytest.raises(pytest.fail.Exception) as excinfo:
270270
with pytest.warns(UserWarning):
271271
warnings.warn("runtime", RuntimeWarning)
272272
excinfo.match(
273-
r"DID NOT WARN. No warnings of type \(.+UserWarning.+,\) were emitted. \n"
273+
r"DID NOT WARN. No warnings of type \(.+UserWarning.+,\) were emitted.\n"
274274
r"The list of emitted warnings is: \[RuntimeWarning\('runtime',?\)]."
275275
)
276276

277277
with pytest.raises(pytest.fail.Exception) as excinfo:
278278
with pytest.warns(UserWarning):
279279
pass
280280
excinfo.match(
281-
r"DID NOT WARN. No warnings of type \(.+UserWarning.+,\) were emitted. \n"
281+
r"DID NOT WARN. No warnings of type \(.+UserWarning.+,\) were emitted.\n"
282282
r"The list of emitted warnings is: \[\]."
283283
)
284284

@@ -290,7 +290,7 @@ def test_as_contextmanager(self) -> None:
290290

291291
messages = [each.message for each in warninfo]
292292
expected_str = (
293-
f"DID NOT WARN. No warnings of type {warning_classes} were emitted. \n"
293+
f"DID NOT WARN. No warnings of type {warning_classes} were emitted.\n"
294294
f"The list of emitted warnings is: {messages}."
295295
)
296296

0 commit comments

Comments
 (0)