diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2022-01-23 18:42:41 +0000 |
---|---|---|
committer | Irit Katriel <iritkatriel@yahoo.com> | 2022-01-23 18:45:10 +0000 |
commit | 3596331d54fe1dd231700b269f76609d86e07c86 (patch) | |
tree | 47b718d1839f201353eb4b3714f82a193cdc087f /Lib/unittest/mock.py | |
parent | a7a4ca4f06c8c31d7f403113702ad2e80bfc326b (diff) | |
download | cpython-git-backport-f7955a8-3.10.tar.gz |
bpo-41403: Improve error message for invalid mock target (GH-30833)backport-f7955a8-3.10
(cherry picked from commit f7955a82e36d4c32ebdd7b7707cdf0e6ffa7a418)
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 6226bd4bc0..7152f86ed9 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -1602,9 +1602,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}") getter = lambda: _importer(target) return getter, attribute |