docs: Add references to AsyncMock in unittest.mock.patch#13681
Conversation
f11000f to
fc631e8
Compare
May 30, 2019 13:42
|
Thank you @mariocj89 for this. I had the same concern while fixing warnings caused due to this change in behavior in the testsuite : https://bugs.python.org/issue37015#msg343352 . I am okay with this being an AsyncMock because it means that there was a coroutine created and it was not awaited where raising a warning makes sense and the user can resort to using MagicMock if they are want it to be not awaited. I would prefer thoughts from @asvetlov @1st1 to discuss this behavior change from 3.7 to ensure the documentation is also updated and if needed an issue for this do discuss. I believe create_autospec has similar behavior : Line 2612 in 98ef920 |
Sorry, something went wrong.
|
I guess my reticence on this comes party from the fact that the AsyncMock stuff is something I'm still quite unsure about. If I'm honest, I was surprised to see the PR landed when it did and I'm a little concerned about unintended consequences of the stuff that has been added, along with the chance that this now means the backport is pretty much stuck until it can ditch support for all python versions that don't have the required async syntax. |
Sorry, something went wrong.
Good point, I'll add a "versionadded" tag for the patch function.
Good point, I'll add a "versionadded" to mark the change.
If you are saying that you are looking at reverting this behaviour soon, then sure, but otherwise we have out of date documentation, as beta 1 of 3.8 is getting released tomorrow. Not saying that we have to rush things, but people (from tomorrow) won't be seeing this change in the docs. Even if anything was reverted, we can revert the docs and implementation together at the same time. |
Sorry, something went wrong.
Update the docs as patch can now return an AsyncMock if the patched object is an async function.
fc631e8 to
c9cbe98
Compare
May 30, 2019 17:02
|
@mariocj89 - reverting would be quite an extreme move, and one I'm not comfortable taking, particularly with my very limited knowledge of async stuff. @asvetlo merged the original PR, IIRC, and it sounded like he's part of a team that had been using this already. I'm not sure what the best way to bottom out the remaining issues might be, including the questions I asked above. |
Sorry, something went wrong.
|
I'll review the PR just after the feature freeze. |
Sorry, something went wrong.
|
Gentle ping @asvetlov This is a change in 3.8 that will go undocumented otherwise. |
Sorry, something went wrong.
|
@lisroach: Please replace |
Sorry, something went wrong.
|
This catches me just about every time too :'( |
Sorry, something went wrong.
|
Thanks @mariocj89 for the PR, and @lisroach for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
Sorry, something went wrong.
) Update the docs as patch can now return an AsyncMock if the patched object is an async function. (cherry picked from commit f5e7f39) Co-authored-by: Mario Corchero <mcorcherojim@bloomberg.net>
Update the docs as patch can now return an AsyncMock if the patched object is an async function. (cherry picked from commit f5e7f39) Co-authored-by: Mario Corchero <mcorcherojim@bloomberg.net>
Update the docs as patch can now return an AsyncMock if the patched object is an async function.
Update the docs as patch can now return an AsyncMock if the patched object is an async function.
Just noticed this, happy to create a bug report & news entry but not sure if it is worth it.
CC: @lisroach @tirkarthi @cjw296
Relates-to: #9296