Title: gh-61215: Add Mock.call_event to allow waiting for calls by Kentzo · Pull Request #20759 · python/cpython · GitHub
Open Graph Title: gh-61215: Add Mock.call_event to allow waiting for calls by Kentzo · Pull Request #20759 · python/cpython
X Title: gh-61215: Add Mock.call_event to allow waiting for calls by Kentzo · Pull Request #20759 · python/cpython
Description: This implementation of bpo-17013 is alternative to #16094 Changes are based on my work for asynctest. Specifically on _AwaitEvent that was left out when related code was ported to CPython. Key features: Does not require end users to do anything: change is automatically available in every Mock Utilizes existing semantics of python conditionals (both asyncio and threading) Accepting this change will allow me to port _AwaitEvent therefore giving identical semantics to both wait-for-calls and wait-for-awaits. I will provide necessary typing annotations for typeshed. Considerations: This approach changes type of the Mock.called property from bool to private bool-like _CallEvent. However, the only practical problem I could think of is if someone was checking type of Mock.called (e.g. isinstance, is). That does not sound like a plausible problem: after all the property itself is seldom used with exception of conditional expressions where _CallEvent.__bool__ and _CallEvent.__eq__ is sufficient. Added new property instead. It probably makes sense to provide convenience methods like wait_for_call, but I would like to hear the opinion of the reviewers. Implemented. CC: @vstinner @tirkarthi @mariocj89 https://bugs.python.org/issue17013 Issue: gh-61215
Open Graph Description: This implementation of bpo-17013 is alternative to #16094 Changes are based on my work for asynctest. Specifically on _AwaitEvent that was left out when related code was ported to CPython. Key feat...
X Description: This implementation of bpo-17013 is alternative to #16094 Changes are based on my work for asynctest. Specifically on _AwaitEvent that was left out when related code was ported to CPython. Key feat...
Opengraph URL: https://github.com/python/cpython/pull/20759
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:b3fcc064-a377-1a94-12f3-ba91a85f0ea8 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | B2DC:245D90:44A32A:5C45F2:6969DD96 |
| html-safe-nonce | 2299d217caab5ecb56a8fcfb2bb79ace45ee132c2467053b7d484cbb59b686fe |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkRDOjI0NUQ5MDo0NEEzMkE6NUM0NUYyOjY5NjlERDk2IiwidmlzaXRvcl9pZCI6Ijc2NTQ4NDkzNTUwNTg4OTYyNzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 171503a67c8cad71dcccf142e00b68d1ab1f6440747c37e18e29c8a295b90a28 |
| hovercard-subject-tag | pull_request:431736206 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/20759/checks |
| twitter:image | https://avatars.githubusercontent.com/u/88809?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/88809?s=400&v=4 |
| og:image:alt | This implementation of bpo-17013 is alternative to #16094 Changes are based on my work for asynctest. Specifically on _AwaitEvent that was left out when related code was ported to CPython. Key feat... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | bdde15ad1b403e23b08bbd89b53fbe6bdf688cad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width