Yury Selivanov <yseliva...@gmail.com> added the comment:

> 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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33918>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to