diff --git a/src/_pytest/monkeypatch.py b/src/_pytest/monkeypatch.py index fcf8f6fdb..dc255357e 100644 --- a/src/_pytest/monkeypatch.py +++ b/src/_pytest/monkeypatch.py @@ -281,7 +281,7 @@ class MonkeyPatch: if not hasattr(target, name): if raising: - raise AttributeError(name) + raise AttributeError(f"{target!r} has no attribute {name!r}") else: oldval = getattr(target, name, notset) # Avoid class descriptors like staticmethod/classmethod.