mirror of
https://github.com/python/cpython.git
synced 2025-08-29 05:05:03 +00:00
bpo-36593: Fix isinstance check for Mock objects with spec executed under tracing (GH-12790)
In Python having a trace function in effect while mock is imported causes isinstance to be wrong for MagicMocks. This is due to the usage of super() in some class methods, as this sets the __class__ attribute. To avoid this, as a workaround, alias the usage of super .
This commit is contained in:
parent
fde9b33dfe
commit
830b43d03c
3 changed files with 41 additions and 1 deletions
|
@ -739,7 +739,7 @@ class NonCallableMock(Base):
|
|||
|
||||
obj = self._mock_children.get(name, _missing)
|
||||
if name in self.__dict__:
|
||||
super().__delattr__(name)
|
||||
_safe_super(NonCallableMock, self).__delattr__(name)
|
||||
elif obj is _deleted:
|
||||
raise AttributeError(name)
|
||||
if obj is not _missing:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue