
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2019-09-10 14:42 bylisroach, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 15947 | merged | lisroach,2019-09-11 13:42 | |
| PR 16299 | merged | lisroach,2019-09-20 16:49 | |
| Messages (3) | |||
|---|---|---|---|
| msg351682 -(view) | Author: Lisa Roach (lisroach)*![]() | 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)*![]() | 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)*![]() | 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 | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:20 | admin | set | github: 82274 |
| 2019-09-30 04:22:17 | lisroach | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2019-09-21 06:00:07 | matrixise | set | nosy: +matrixise messages: +msg352928 |
| 2019-09-20 16:49:02 | lisroach | set | pull_requests: +pull_request15885 |
| 2019-09-20 04:04:21 | lisroach | set | messages: +msg352829 |
| 2019-09-11 13:42:00 | lisroach | set | keywords: +patch stage: needs patch -> patch review pull_requests: +pull_request15582 |
| 2019-09-10 14:42:41 | lisroach | create | |