Title: patch.object should raise another error when first argument is a str
Type: enhancement Stage: patch review
Components: Tests Versions: Python 3.9
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Elena.Oat, cjw296, lisroach, mariocj89, michael.foord, terry.reedy, xtreak
Priority: normal Keywords: patch

Created on 2019-11-03 02:30 by Elena.Oat, last changed 2019-11-08 19:57 by terry.reedy.

Pull Requests
URL Status Linked Edit
PR 17034 open Elena.Oat, 2019-11-03 19:42
Messages (2)
msg355886 - (view) Author: Elena Oat (Elena.Oat) * Date: 2019-11-03 02:30
When using patch.object with first argument as a string, e.g. 
´´patch.object('SomeClass', 'somemethod')´´ this raises ´´AttributeError: Something does not have the attribute 'do_something'´´. 
This should instead warn user that the correct type for the first argument is a class.
msg356258 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2019-11-08 19:57
This enhancement request (no backports) is about the unittest.mock patch.object.
Date User Action Args
2019-11-08 19:57:53terry.reedysetversions: - Python 3.5, Python 3.6, Python 3.7, Python 3.8
nosy: + terry.reedy

messages: + msg356258

type: enhancement
2019-11-03 19:42:26Elena.Oatsetkeywords: + patch
stage: patch review
pull_requests: + pull_request16549
2019-11-03 02:58:59xtreaksetnosy: + cjw296, michael.foord, lisroach, mariocj89, xtreak
2019-11-03 02:30:39Elena.Oatcreate