summaryrefslogtreecommitdiff
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorLisa Roach <lisaroach14@gmail.com>2019-09-29 21:56:47 -0700
committerGitHub <noreply@github.com>2019-09-29 21:56:47 -0700
commit3667e1ee6c90e6d3b6a745cd590ece87118f81ad (patch)
treed9802110a2f6ebbd181b904b05956a56d88c8c44 /Lib/unittest/mock.py
parent5bcc6d89bcb622a6786fff632fabdcaf67dbb4e2 (diff)
downloadcpython-git-3667e1ee6c90e6d3b6a745cd590ece87118f81ad.tar.gz
bpo-38163: Child mocks detect their type as sync or async (GH-16471)
Diffstat (limited to 'Lib/unittest/mock.py')
-rw-r--r--Lib/unittest/mock.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index e797d2f5b5..a48132c5b1 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -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