Message320116
> Imagine the context manager is mock.patch used in testing and you want to run two tests in "parallel", each with a different mocked method. mock.patch isn't aware of `await` so patching will be incorrect.
That's still doable with contextvars. You just need a custom mock-like object (or library) that stores its settings/state in a context variable.
Now, the "mock" module doesn't provide this functionality out of the box, but I hope that somebody will come up with a new mock library that will work that way (or with a new mock primitive) after 3.7.0 is released.
Adding __pause__ and __resume__ was considered in PEP 521, and it was decided that the actual implementation will be too slow and complex. It's very unlikely that PEP 521 is ever accepted. |
|
Date |
User |
Action |
Args |
2018-06-20 21:25:50 | yselivanov | set | recipients:
+ yselivanov, asvetlov, Liran Nuna |
2018-06-20 21:25:50 | yselivanov | set | messageid: <1529529950.66.0.56676864532.issue33918@psf.upfronthosting.co.za> |
2018-06-20 21:25:50 | yselivanov | link | issue33918 messages |
2018-06-20 21:25:50 | yselivanov | create | |
|