Message351407
I just checked the behavior with asynctest. The _mock_call implementation where the call is recorded is similar except that in asynctest it's a synchronous function [0] and in AsyncMock it's an async function [1] thus needs to be awaited to register call count. Agreed it's more of a confusion over does call mean a function call or something that should be recorded only once awaited given that there is call_count and await_calls. But would be good to have this documented that call_count is recorded only after await.
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import asynctest
>>> m = asynctest.CoroutineMock()
>>> m(1)
<generator object CoroutineMock._mock_call.<locals>.proxy at 0x1023c8b88>
>>> m.mock_calls
[call(1)]
Python 3.9.0a0 (heads/master:a6563650c8, Sep 9 2019, 14:53:16)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from unittest.mock import AsyncMock
>>> m = AsyncMock()
>>> m.mock_calls
[]
[0] https://github.com/Martiusweb/asynctest/blob/d1d47ecb8220371284230d6d6fe642649ef82ab2/asynctest/mock.py#L584
[1] https://github.com/python/cpython/blob/19052a11314e7be7ba003fd6cdbb5400a5d77d96/Lib/unittest/mock.py#L2120 |
|
Date |
User |
Action |
Args |
2019-09-09 10:28:02 | xtreak | set | recipients:
+ xtreak, cjw296, michael.foord, lisroach, mariocj89 |
2019-09-09 10:28:02 | xtreak | set | messageid: <1568024882.87.0.43750930893.issue37383@roundup.psfhosted.org> |
2019-09-09 10:28:02 | xtreak | link | issue37383 messages |
2019-09-09 10:28:02 | xtreak | create | |
|