diff options
author | Xtreak <tirkarthi@users.noreply.github.com> | 2018-12-01 15:33:54 +0530 |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2019-04-30 08:39:55 +0100 |
commit | 5a593292f8e7e27da990e9c548b1e9fcd5c81bf1 (patch) | |
tree | 91e0dc88a417d01dcbdfd3e1c7152e47fde70df6 /mock/tests/testmock.py | |
parent | 2df18d018d8ecc84d4064f477162df0d9d3f4bcb (diff) | |
download | mock-5a593292f8e7e27da990e9c548b1e9fcd5c81bf1.tar.gz |
bpo-31177: Skip deleted attributes while calling reset_mock (GH-9302)
Backports: edeca92c84a3b08902ecdfe987cde00c7e617887
Signed-off-by: Chris Withers <chris@simplistix.co.uk>
Diffstat (limited to 'mock/tests/testmock.py')
-rw-r--r-- | mock/tests/testmock.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mock/tests/testmock.py b/mock/tests/testmock.py index a61dff1..cda4124 100644 --- a/mock/tests/testmock.py +++ b/mock/tests/testmock.py @@ -1662,6 +1662,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) |