diff options
| author | Xtreak <tirkarthi@users.noreply.github.com> | 2018-12-01 15:33:54 +0530 |
|---|---|---|
| committer | Victor Stinner <vstinner@redhat.com> | 2018-12-01 11:03:54 +0100 |
| commit | edeca92c84a3b08902ecdfe987cde00c7e617887 (patch) | |
| tree | 965902be00aa84c99d0e7d7a0128c0625c7721d9 /Lib/unittest/test/testmock/testmock.py | |
| parent | 989052047eea7f35da0d7ca268791b2442ee1553 (diff) | |
| download | cpython-git-edeca92c84a3b08902ecdfe987cde00c7e617887.tar.gz | |
bpo-31177: Skip deleted attributes while calling reset_mock (GH-9302)
Diffstat (limited to 'Lib/unittest/test/testmock/testmock.py')
| -rw-r--r-- | Lib/unittest/test/testmock/testmock.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py index 8cd284a652..ac6eea3720 100644 --- a/Lib/unittest/test/testmock/testmock.py +++ b/Lib/unittest/test/testmock/testmock.py @@ -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) |
