diff options
author | Michael Foord <michael@voidspace.org.uk> | 2011-11-22 23:33:18 +0000 |
---|---|---|
committer | Michael Foord <michael@voidspace.org.uk> | 2011-11-22 23:33:18 +0000 |
commit | 1a130814450bbbe06213ba66a2e193856626f48c (patch) | |
tree | acf0b36f8de65888afa93c980db8f80108856346 /mock.py | |
parent | 2644e0a5624c8389c07e50b65705a7bee23906fa (diff) | |
download | mock-1a130814450bbbe06213ba66a2e193856626f48c.tar.gz |
Minor tweak
Diffstat (limited to 'mock.py')
-rw-r--r-- | mock.py | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -440,7 +440,7 @@ def _mock_signature_property(name): def _set(self, value, name=name, _the_name=_the_name): sig = self._mock_signature if sig is None: - setattr(self, _the_name, value) + self.__dict__[_the_name] = value else: setattr(sig, name, value) @@ -784,10 +784,11 @@ class NonCallableMock(Base): def __setattr__(self, name, value): - if (self._spec_set and self._mock_methods is not None and + if name in _allowed_names: + pass + elif (self._spec_set and self._mock_methods is not None and name not in self._mock_methods and - name not in self.__dict__ and - name not in _allowed_names): + name not in self.__dict__): raise AttributeError("Mock object has no attribute '%s'" % name) elif name in _unsupported_magics: msg = 'Attempting to set unsupported magic method %r.' % name @@ -806,8 +807,6 @@ class NonCallableMock(Base): # but not method calls _check_and_set_parent(self, value, None, name) setattr(type(self), name, value) - elif name in _allowed_names: - pass elif _check_and_set_parent(self, value, name, name): self._mock_children[name] = value return object.__setattr__(self, name, value) |