Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue38093

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Update MagicMock __aenter__ and __aexit__ to return AsyncMock's
Type:behaviorStage:resolved
Components:Versions:Python 3.9, Python 3.8
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: lisroachNosy List: ezio.melotti, lisroach, matrixise, michael.foord, xtreak
Priority:normalKeywords:patch

Created on2019-09-10 14:42 bylisroach, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 15947mergedlisroach,2019-09-11 13:42
PR 16299mergedlisroach,2019-09-20 16:49
Messages (3)
msg351682 -(view)Author: Lisa Roach (lisroach)*(Python committer)Date: 2019-09-10 14:42
After a discussion with Michael, xtreak, and Ezio we've decided to try to make the process of mocking an async context manager slightly easier.Currently if you want to mock a context manager that is used like this:async with cm():  # note that cm is called here  blahYou need to mock cm as a MagicMock and set __aenter__ and __aexit__ return values directly because they do not exist on MagicMocks.Our first step to making this easier is setting the calculated return value of MagicMock __aenter__ and __aexit__ to be AsyncMock, which will make it so you do not need to set them specifically.A future improvement may be to create a ContextManagerMock directly that can take an async kwarg that would return a context manager with AsyncMocks for __aenter__ and __aexit__ automatically.
msg352829 -(view)Author: Lisa Roach (lisroach)*(Python committer)Date: 2019-09-20 04:04
New changeset8b03f943c37e07fb2394acdcfacd066647f9b1fd by Lisa Roach in branch 'master':bpo-38093: Correctly returns AsyncMock for async subclasses. (GH-15947)https://github.com/python/cpython/commit/8b03f943c37e07fb2394acdcfacd066647f9b1fd
msg352928 -(view)Author: Stéphane Wirtel (matrixise)*(Python committer)Date: 2019-09-21 06:00
New changeset865bb685a67798eb98dcf5f3a852e08c77792998 by Stéphane Wirtel (Lisa Roach) in branch '3.8':[3.8]bpo-38093: Correctly returns AsyncMock for async subclasses. (GH-15947) (GH-16299)https://github.com/python/cpython/commit/865bb685a67798eb98dcf5f3a852e08c77792998
History
DateUserActionArgs
2022-04-11 14:59:20adminsetgithub: 82274
2019-09-30 04:22:17lisroachsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-09-21 06:00:07matrixisesetnosy: +matrixise
messages: +msg352928
2019-09-20 16:49:02lisroachsetpull_requests: +pull_request15885
2019-09-20 04:04:21lisroachsetmessages: +msg352829
2019-09-11 13:42:00lisroachsetkeywords: +patch
stage: needs patch -> patch review
pull_requests: +pull_request15582
2019-09-10 14:42:41lisroachcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp