summaryrefslogtreecommitdiff
path: root/mock/tests
diff options
context:
space:
mode:
authorXtreak <tirkarthi@users.noreply.github.com>2018-12-01 15:33:54 +0530
committerChris Withers <chris@withers.org>2019-04-30 08:39:55 +0100
commit5a593292f8e7e27da990e9c548b1e9fcd5c81bf1 (patch)
tree91e0dc88a417d01dcbdfd3e1c7152e47fde70df6 /mock/tests
parent2df18d018d8ecc84d4064f477162df0d9d3f4bcb (diff)
downloadmock-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')
-rw-r--r--mock/tests/testmock.py10
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)