diff options
author | Michael Foord <michael@voidspace.org.uk> | 2012-06-09 16:31:59 (GMT) |
---|---|---|
committer | Michael Foord <michael@voidspace.org.uk> | 2012-06-09 16:31:59 (GMT) |
commit | 75963643b178f9d72d3b6bb02d136d67c9cc6d3e (patch) | |
tree | bfb5554802f021c2686f505120312f87bf09574d /Lib/unittest/mock.py | |
parent | afc0c77b421baf8ac2376e563dd9be25e1e1eb63 (diff) | |
download | cpython-75963643b178f9d72d3b6bb02d136d67c9cc6d3e.zip cpython-75963643b178f9d72d3b6bb02d136d67c9cc6d3e.tar.gz cpython-75963643b178f9d72d3b6bb02d136d67c9cc6d3e.tar.bz2 |
Fix exception when calling reset_mock on a mock created with autospec
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r-- | Lib/unittest/mock.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 36be0fd..4ae3d16 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -510,6 +510,8 @@ class NonCallableMock(Base): self.method_calls = _CallList() for child in self._mock_children.values(): + if isinstance(child, _SpecState): + continue child.reset_mock() ret = self._mock_return_value @@ -664,6 +666,7 @@ class NonCallableMock(Base): # but not method calls _check_and_set_parent(self, value, None, name) setattr(type(self), name, value) + self._mock_children[name] = value elif name == '__class__': self._spec_class = value return |