This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: AsyncMock add `.awaited` like `.called`
Type: enhancement Stage: patch review
Components: Versions: Python 3.9, Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: lisroach, xtreak
Priority: normal Keywords: patch

Created on 2019-09-13 15:49 by lisroach, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 16443 merged lisroach, 2019-09-27 23:32
PR 16481 merged miss-islington, 2019-09-30 04:03
Messages (6)
msg352345 - (view) Author: Lisa Roach (lisroach) * (Python committer) Date: 2019-09-13 15:49
Currently Mock has a `.called` attribute, we could add an equivalent `.awaited` that returns True or False if the object has been awaited on.
msg352352 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-09-13 15:56
awaited is now initialized with an Event object. Do you had any use case in mind while designing it? I think it's a good choice to have True/False instead of being used to give an Event object that is not used.
msg352828 - (view) Author: Lisa Roach (lisroach) * (Python committer) Date: 2019-09-20 04:03
Yeah I think the current `awaited` ought to at least be a private variable, since people will assume it works like a boolean to match `.called`. Then we could add a new, proper, `awaited` that would function like:

>>> mock = AsyncMock()
>>> cr_mock = mock()
>>> mock.called
>>> mock.awaited
>>> await cr_mock
>>> mock.awaited
msg353427 - (view) Author: Lisa Roach (lisroach) * (Python committer) Date: 2019-09-27 23:26
Looking at this more, I think I want to just remove the current `awaited` object. The PR in asyntest makes it seem pretty cool:

But I have issue with the naming (await_event is probably better for us), and I'm not sure how to document it well and ensure it's well tested.

With the 3.8 release coming up fast I'd rather remove it for now and then add it back in after some more thought has been given to the feature, instead of getting stuck with a not fully thought out attribute we have to worry about deprecating.
msg353529 - (view) Author: Lisa Roach (lisroach) * (Python committer) Date: 2019-09-30 04:01
New changeset 25e115ec00b5f75e3589c9f21013c47c21e1753f by Lisa Roach in branch 'master':
bpo-38161: Removes _AwaitEvent from AsyncMock. (GH-16443)
msg353532 - (view) Author: Lisa Roach (lisroach) * (Python committer) Date: 2019-09-30 04:23
New changeset 36e7e4aabb662e86e9dace1a6447492f45868654 by Lisa Roach (Miss Islington (bot)) in branch '3.8':
bpo-38161: Removes _AwaitEvent from AsyncMock. (GH-16443) (GH-16481)
Date User Action Args
2022-04-11 14:59:20adminsetgithub: 82342
2019-09-30 04:23:36lisroachsetmessages: + msg353532
2019-09-30 04:03:41miss-islingtonsetpull_requests: + pull_request16065
2019-09-30 04:01:33lisroachsetmessages: + msg353529
2019-09-27 23:32:27lisroachsetkeywords: + patch
stage: patch review
pull_requests: + pull_request16023
2019-09-27 23:26:22lisroachsetmessages: + msg353427
2019-09-20 04:03:21lisroachsetmessages: + msg352828
2019-09-13 15:56:49xtreaksetversions: + Python 3.8, Python 3.9
nosy: + xtreak

messages: + msg352352

type: enhancement
2019-09-13 15:49:28lisroachcreate