mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-31177: Skip deleted attributes while calling reset_mock (GH-9302)
This commit is contained in:
parent
989052047e
commit
edeca92c84
3 changed files with 13 additions and 1 deletions
|
@ -1596,6 +1596,16 @@ class MockTest(unittest.TestCase):
|
|||
self.assertRaises(AttributeError, getattr, mock, 'f')
|
||||
|
||||
|
||||
def test_reset_mock_does_not_raise_on_attr_deletion(self):
|
||||
# bpo-31177: reset_mock should not raise AttributeError when attributes
|
||||
# were deleted in a mock instance
|
||||
mock = Mock()
|
||||
mock.child = True
|
||||
del mock.child
|
||||
mock.reset_mock()
|
||||
self.assertFalse(hasattr(mock, 'child'))
|
||||
|
||||
|
||||
def test_class_assignable(self):
|
||||
for mock in Mock(), MagicMock():
|
||||
self.assertNotIsInstance(mock, int)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue