diff options
author | blhsing <blhsing@gmail.com> | 2024-06-11 05:42:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-11 05:42:49 (GMT) |
commit | 9e9ee50421c857b443e2060274f17fb884d54473 (patch) | |
tree | f6b285c1dc402467a0175bf91721a1d6a8fce1f5 /Lib/unittest | |
parent | 422c4fc855afd18bcc6415902ea1d85a50cb7ce1 (diff) | |
download | cpython-9e9ee50421c857b443e2060274f17fb884d54473.zip cpython-9e9ee50421c857b443e2060274f17fb884d54473.tar.gz cpython-9e9ee50421c857b443e2060274f17fb884d54473.tar.bz2 |
gh-65454: avoid triggering call to a PropertyMock in NonCallableMock.__setattr__ (#120019)
Diffstat (limited to 'Lib/unittest')
-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 edabb45..08975e0 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -830,6 +830,9 @@ class NonCallableMock(Base): mock_name = f'{self._extract_mock_name()}.{name}' raise AttributeError(f'Cannot set {mock_name}') + if isinstance(value, PropertyMock): + self.__dict__[name] = value + return return object.__setattr__(self, name, value) |