diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2022-01-23 18:42:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-23 18:42:41 (GMT) |
commit | f7955a82e36d4c32ebdd7b7707cdf0e6ffa7a418 (patch) | |
tree | be80eeca8d122c5b8a256c1c9675b05c9623e214 /Lib/unittest/mock.py | |
parent | ca78130d7eb5265759697639e42487ec6d0a4caf (diff) | |
download | cpython-f7955a82e36d4c32ebdd7b7707cdf0e6ffa7a418.zip cpython-f7955a82e36d4c32ebdd7b7707cdf0e6ffa7a418.tar.gz cpython-f7955a82e36d4c32ebdd7b7707cdf0e6ffa7a418.tar.bz2 |
bpo-41403: Improve error message for invalid mock target (GH-30833)
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r-- | Lib/unittest/mock.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 9f99a5a..9137501 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -1589,9 +1589,9 @@ class _patch(object): def _get_target(target): try: target, attribute = target.rsplit('.', 1) - except (TypeError, ValueError): - raise TypeError("Need a valid target to patch. You supplied: %r" % - (target,)) + except (TypeError, ValueError, AttributeError): + raise TypeError( + f"Need a valid target to patch. You supplied: {target!r}") return partial(pkgutil.resolve_name, target), attribute |