[New-bugs-announce] [issue31177] unittest mock's reset_mock throws an error when an attribute has been deleted
report at bugs.python.org
Thu Aug 10 10:22:19 EDT 2017
New submission from Hmvp:
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.
from unittest.mock import MagicMock
mock = MagicMock()
mock.a = 'test'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/unittest/mock.py", line 544, in reset_mock
AttributeError: '_SentinelObject' object has no attribute 'reset_mock'
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
components: Library (Lib)
title: unittest mock's reset_mock throws an error when an attribute has been deleted
versions: Python 3.5, Python 3.6, Python 3.7
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce