Author webisteme
Recipients webisteme
Date 2020-07-26.19:15:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
When calling `mock.patch` incorrectly, as in the following example, an uncaught error is thrown:

>>> from unittest import mock
>>> class Foo:
...     pass
>>> mock.patch(Foo())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/", line 1624, in patch
    getter, attribute = _get_target(target)
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/", line 1469, in _get_target
    target, attribute = target.rsplit('.', 1)
AttributeError: 'Foo' object has no attribute 'rsplit'
This can happen when confusing `mock.patch` with `mock.patch.object`. However, the uncaught error is not informative, as it does not indicate that the wrong type of object was passed to `mock.patch`.
Date User Action Args
2020-07-26 19:15:44webistemesetrecipients: + webisteme
2020-07-26 19:15:44webistemesetmessageid: <>
2020-07-26 19:15:44webistemelinkissue41403 messages
2020-07-26 19:15:43webistemecreate