mirror of
https://github.com/python/cpython.git
synced 2025-08-01 23:53:15 +00:00
bpo-41403: Improve error message for invalid mock target (GH-30833) (GH-30834)
(cherry picked from commit f7955a82e3
)
This commit is contained in:
parent
a7a4ca4f06
commit
e3ade66ec5
3 changed files with 13 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue