bpo-38163: Child mocks detect their type as sync or async (GH-16471)

This commit is contained in:
Lisa Roach 2019-09-29 21:56:47 -07:00 committed by GitHub
parent 5bcc6d89bc
commit 3667e1ee6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 76 additions and 28 deletions

View file

@ -992,8 +992,9 @@ class NonCallableMock(Base):
# Any asynchronous magic becomes an AsyncMock
klass = AsyncMock
elif issubclass(_type, AsyncMockMixin):
if _new_name in _all_sync_magics:
# Any synchronous magic becomes a MagicMock
if (_new_name in _all_sync_magics or
self._mock_methods and _new_name in self._mock_methods):
# Any synchronous method on AsyncMock becomes a MagicMock
klass = MagicMock
else:
klass = AsyncMock