[issue26467] Add async magic method support to unittest.mock.Mock
Javier Domingo
report at bugs.python.org
Mon Dec 19 19:22:47 EST 2016
Javier Domingo added the comment:
I found this while trying to test an async context manager. This is a critical feature to enable migrations to async code, as the impossibility to test something properly is not acceptable in many environments.
Implementing it in a way that __call__ returns an object capable of being coroutine or normal function would avoid having to implement Async specific Mocks, wouldn't it? I am not too confident, but would it be doable to have an implementation that depends on whether _is_coroutine is accessed or not?
I don't like it, but I really don't like the fact that we need to patch different all the methods depending on whether they are coroutine or not.
Obviously, having the __acall__ method would really help solving this issue.
----------
nosy: +txomon
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26467>
_______________________________________
More information about the Python-bugs-list
mailing list