This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author hmvp
Recipients hmvp
Date 2017-08-10.14:22:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1502374939.75.0.688742031254.issue31177@psf.upfronthosting.co.za>
In-reply-to
Content
When using a mock and deleting a attribute reset_mock cannot be used anymore since it tries to call reset_mock on the _deleted sentinel value.

Reproduction path:
```
from unittest.mock import MagicMock
mock = MagicMock()
mock.a = 'test'
del mock.a
mock.reset_mock()
```

Gives:
```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/unittest/mock.py", line 544, in reset_mock
    child.reset_mock(visited)
AttributeError: '_SentinelObject' object has no attribute 'reset_mock'
```

Expected result:
mock is reset without throwing an exception and the 'a' attribute is no longer in a deleted state

Only checked 3.5 and current master if bug is present
History
Date User Action Args
2017-08-10 14:22:19hmvpsetrecipients: + hmvp
2017-08-10 14:22:19hmvpsetmessageid: <1502374939.75.0.688742031254.issue31177@psf.upfronthosting.co.za>
2017-08-10 14:22:19hmvplinkissue31177 messages
2017-08-10 14:22:19hmvpcreate