bpo-37383: Updates docs to reflect AsyncMock call_count after await.#15761
bpo-37383: Updates docs to reflect AsyncMock call_count after await.#15761lisroach merged 4 commits intopython:masterfrom
Conversation
Doc/library/unittest.mock.rst
Outdated
| has been awaited: | ||
|
|
||
| >>> mock = AsyncMock() | ||
| >>> mock() |
There was a problem hiding this comment.
This would cause a warning that the mock was not awaited and there is a failure in CI due to the repr output. Perhaps below would help where we skipped doctest in another similar example.
>>> mock() # doctest: +SKIP
<coroutine object AsyncMockMixin._mock_call at ...>
Doc/library/unittest.mock.rst
Outdated
| >>> mock.call_count | ||
| 0 | ||
| >>> async def main(): | ||
| >>> await mock() |
There was a problem hiding this comment.
| >>> await mock() | |
| ... await mock() |
There was a problem hiding this comment.
I think we can directly do >>> await mock() on doctest once I somehow get to https://bugs.python.org/issue37006 :)
There was a problem hiding this comment.
Is there a way to run just the doctests? Somehow I never know how to find these errors until CI raises them.
There was a problem hiding this comment.
Yes, I think the steps in travis is good to run the tests https://travis-ci.org/python/cpython/jobs/582713783#L1482 . xvfb-run is required for turtle related tests. It works on my Linux machine not sure how to install xvfb-run on Mac.
$ make -C Doc/ PYTHON=../python venv
$ xvfb-run make -C Doc/ PYTHON=../python SPHINXOPTS="-q -W -j4" doctest
tirkarthi
left a comment
There was a problem hiding this comment.
LGTM given that we also had a discussion on this behavior.
|
@lisroach: Please replace |
|
Lisa, please backport the changes to 3.8 too. Thanks. |
|
Thanks @lisroach for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
…ythonGH-15761) * bpo-351428: Updates documentation to reflect AsyncMock call_count after await. * Adds skip and fixes warning. * Removes extra >>>. * Adds ... in front of await mock(). (cherry picked from commit b9f65f0) Co-authored-by: Lisa Roach <lisaroach14@gmail.com>
|
GH-15810 is a backport of this pull request to the 3.8 branch. |
…H-15761) * bpo-351428: Updates documentation to reflect AsyncMock call_count after await. * Adds skip and fixes warning. * Removes extra >>>. * Adds ... in front of await mock(). (cherry picked from commit b9f65f0) Co-authored-by: Lisa Roach <lisaroach14@gmail.com>
…ython#15761) * bpo-351428: Updates documentation to reflect AsyncMock call_count after await. * Adds skip and fixes warning. * Removes extra >>>. * Adds ... in front of await mock().
Updates documentation to make it more clear that call_count is not updated unless the AsyncMock has been awaited.
https://bugs.python.org/issue37383