summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/mock.py
diff options
context:
space:
mode:
authorLisa Roach <lisaroach14@gmail.com>2019-09-30 05:22:44 (GMT)
committerGitHub <noreply@github.com>2019-09-30 05:22:44 (GMT)
commit21f24ead90c22d0e2c2ebf14a64b37d99de54b33 (patch)
treec65cd3d5174adbbffa1772cc7b822e66289eb597 /Lib/unittest/mock.py
parent36e7e4aabb662e86e9dace1a6447492f45868654 (diff)
downloadcpython-21f24ead90c22d0e2c2ebf14a64b37d99de54b33.zip
cpython-21f24ead90c22d0e2c2ebf14a64b37d99de54b33.tar.gz
cpython-21f24ead90c22d0e2c2ebf14a64b37d99de54b33.tar.bz2
[3.8] bpo-38163: Child mocks detect their type as sync or async (GH-16471) (GH-16484)
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 5d32f88..488ab1c 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -997,8 +997,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