diff --git a/_pytest/python_api.py b/_pytest/python_api.py index e6f002849..5bbf3ac7a 100644 --- a/_pytest/python_api.py +++ b/_pytest/python_api.py @@ -571,7 +571,6 @@ def raises(expected_exception, *args, **kwargs): message = kwargs.pop("message") if "match" in kwargs: match_expr = kwargs.pop("match") - message += " matching '{0}'".format(match_expr) return RaisesContext(expected_exception, message, match_expr) elif isinstance(args[0], str): code, = args diff --git a/changelog/3222.trivial b/changelog/3222.trivial new file mode 100644 index 000000000..fbbbd5510 --- /dev/null +++ b/changelog/3222.trivial @@ -0,0 +1 @@ +The "matching '...'" part got removed from ``pytest.raises()`` error messages as it falsely implies that an exception was raised but it didn't match. \ No newline at end of file