diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py
index 7a16cc5e6..b73c8bbb3 100644
--- a/src/_pytest/_code/code.py
+++ b/src/_pytest/_code/code.py
@@ -710,7 +710,7 @@ class ExceptionInfo(Generic[E]):
*getattr(self.value, "__notes__", []),
]
)
- msg = f"Regex pattern did not match.\n Regex: {regexp!r}\n str(exception): {value!r}"
+ msg = f"Regex pattern did not match.\n Regex: {regexp!r}\n Input: {value!r}"
if regexp == value:
msg += "\n Did you mean to `re.escape()` the regex?"
assert re.search(regexp, value), msg
diff --git a/src/_pytest/python_api.py b/src/_pytest/python_api.py
index a045da220..af7a90147 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 or `PEP-678 ` `__notes__`
+ of the exception 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`.
diff --git a/testing/code/test_excinfo.py b/testing/code/test_excinfo.py
index 92ebfbc48..90f81123e 100644
--- a/testing/code/test_excinfo.py
+++ b/testing/code/test_excinfo.py
@@ -434,7 +434,7 @@ def test_match_raises_error(pytester: Pytester) -> None:
match = [
r"E .* AssertionError: Regex pattern did not match.",
r"E .* Regex: '\[123\]\+'",
- r"E .* str\(exception\): 'division by zero'",
+ r"E .* Input: 'division by zero'",
]
result.stdout.re_match_lines(match)
result.stdout.no_fnmatch_line("*__tracebackhide__ = True*")
diff --git a/testing/python/raises.py b/testing/python/raises.py
index 1ef4b0227..3dcec31eb 100644
--- a/testing/python/raises.py
+++ b/testing/python/raises.py
@@ -196,7 +196,7 @@ class TestRaises:
expr = (
"Regex pattern did not match.\n"
f" Regex: {msg!r}\n"
- " str(exception): \"invalid literal for int() with base 10: 'asdf'\""
+ " Input: \"invalid literal for int() with base 10: 'asdf'\""
)
with pytest.raises(AssertionError, match="(?m)" + re.escape(expr)):
with pytest.raises(ValueError, match=msg):
@@ -221,10 +221,7 @@ class TestRaises:
with pytest.raises(AssertionError, match="'foo"):
raise AssertionError("'bar")
(msg,) = excinfo.value.args
- assert (
- msg
- == '''Regex pattern did not match.\n Regex: "'foo"\n str(exception): "'bar"'''
- )
+ assert msg == '''Regex pattern did not match.\n Regex: "'foo"\n Input: "'bar"'''
def test_match_failure_exact_string_message(self):
message = "Oh here is a message with (42) numbers in parameters"
@@ -235,7 +232,7 @@ class TestRaises:
assert msg == (
"Regex pattern did not match.\n"
" Regex: 'Oh here is a message with (42) numbers in parameters'\n"
- " str(exception): 'Oh here is a message with (42) numbers in parameters'\n"
+ " Input: 'Oh here is a message with (42) numbers in parameters'\n"
" Did you mean to `re.escape()` the regex?"
)