diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2019-01-21 08:57:46 (GMT) |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2019-01-21 08:57:46 (GMT) |
commit | 222d303ade8aadf0adcae5190fac603bdcafe3f0 (patch) | |
tree | bd1a8b9366321becda7c6cfd1e46f51803de9f2d /Lib/unittest/mock.py | |
parent | e8239b8e8199b76ef647ff3bf080ce2eb7733e04 (diff) | |
download | cpython-222d303ade8aadf0adcae5190fac603bdcafe3f0.zip cpython-222d303ade8aadf0adcae5190fac603bdcafe3f0.tar.gz cpython-222d303ade8aadf0adcae5190fac603bdcafe3f0.tar.bz2 |
bpo-20239: Allow repeated deletion of unittest.mock.Mock attributes (#11057)
* Allow repeated deletion of unittest.mock.Mock attributes
* fixup! Allow repeated deletion of unittest.mock.Mock attributes
* fixup! fixup! Allow repeated deletion of unittest.mock.Mock attributes
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r-- | Lib/unittest/mock.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 3a22a48..ef5c55d 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -729,11 +729,10 @@ class NonCallableMock(Base): # not set on the instance itself return - if name in self.__dict__: - object.__delattr__(self, name) - obj = self._mock_children.get(name, _missing) - if obj is _deleted: + if name in self.__dict__: + super().__delattr__(name) + elif obj is _deleted: raise AttributeError(name) if obj is not _missing: del self._mock_children[name] |