diff options
author | Lisa Roach <lisaroach14@gmail.com> | 2019-09-29 21:56:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-29 21:56:47 -0700 |
commit | 3667e1ee6c90e6d3b6a745cd590ece87118f81ad (patch) | |
tree | d9802110a2f6ebbd181b904b05956a56d88c8c44 /Lib/unittest/mock.py | |
parent | 5bcc6d89bcb622a6786fff632fabdcaf67dbb4e2 (diff) | |
download | cpython-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.py | 5 |
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 |