From 0b4a557087b7d90f4db44a893470545656730d2a Mon Sep 17 00:00:00 2001 From: bowugit Date: Fri, 21 Jul 2023 00:29:29 +0800 Subject: [PATCH] Extend pytest.raises to support Exception having __repr__ method and initialized with kwargs (#11073) Co-authored-by: Bruno Oliveira --- AUTHORS | 1 + src/_pytest/python_api.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index f2b59b7c4..4c42de21f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -57,6 +57,7 @@ Ben Gartner Ben Webb Benjamin Peterson Bernard Pratz +Bo Wu Bob Ippolito Brian Dorsey Brian Larsen diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py index a045da220..27826863e 100644 --- a/src/_pytest/python_api.py +++ b/src/_pytest/python_api.py @@ -812,7 +812,8 @@ def raises( # noqa: F811 :kwparam str | typing.Pattern[str] | None match: If specified, a string containing a regular expression, or a regular expression object, that is tested against the string - representation of the exception using :func:`re.search`. + representation of the exception and its `PEP-678 ` `__notes__` + using :func:`re.search`. To match a literal string that may contain :ref:`special characters `, the pattern can first be escaped with :func:`re.escape`.