Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-37955: mock.patch incorrect reference to Mock #15521

Merged

Conversation

@phsilva
Copy link
Contributor

phsilva commented Aug 26, 2019

mock.patch mentions that keyword arguments are passed
to Mock when it passes to MagicMock by default.

This PR fixes that.

https://bugs.python.org/issue37955

@the-knights-who-say-ni

This comment has been minimized.

Copy link

the-knights-who-say-ni commented Aug 26, 2019

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Our records indicate we have not received your CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

@tirkarthi

This comment has been minimized.

Copy link
Member

tirkarthi commented Aug 26, 2019

Changing the hyperlink to Mock sounds good to me. But also note like #13681 from 3.8 the default value could be MagicMock or AsyncMock depends on the target. cc: @mariocj89 @cjw296

mock.patch mentions that keyword arguments are passed
to Mock when it passes to MagicMock by default.

This PR fixes that.
@phsilva phsilva force-pushed the phsilva:bpo-37955-incorrect-reference-in-mock-patch-doc branch from 6c0f647 to 6578726 Aug 26, 2019
@phsilva

This comment has been minimized.

Copy link
Contributor Author

phsilva commented Aug 26, 2019

Changing the hyperlink to Mock sounds good to me. But also note like #13681 from 3.8 the default value could be MagicMock or AsyncMock depends on the target. cc: @mariocj89 @cjw296

The issue on #13681 seems important, the return value on those functions is mostly undocumented right now (since 3.8 changes).

Maybe we should stop mentioning what the actual return type is and say it is whatever is on new_callable and at new_callable we can mention that it depends based on async or not.

This patch adds information about possible use of a AsyncMock
when passing arbitrary arguments to mock.patch.
@phsilva

This comment has been minimized.

Copy link
Contributor Author

phsilva commented Nov 30, 2019

Latest patch adjust the text to account the suggestions. Appreciate any reviews.

Doc/library/unittest.mock.rst Outdated Show resolved Hide resolved
@@ -1651,7 +1651,8 @@ def patch(
"as"; very useful if `patch` is creating a mock object for you.
`patch` takes arbitrary keyword arguments. These will be passed to
the `Mock` (or `new_callable`) on construction.
to construct a `AsyncMock` if the patched object is an async function,
to `MagicMock` otherwise or to `new_callable` if specified.

This comment has been minimized.

Copy link
@cjw296

cjw296 Dec 1, 2019

Contributor

Is there any way we could not have this text duplicated between mock.py and mock.rst?

This comment has been minimized.

Copy link
@phsilva

phsilva Dec 2, 2019

Author Contributor

I am new to Python docs, but as far as I looked around there is a lot of duplication between .rst and .py in many modules, will need to ask around about if there is another way.

This comment has been minimized.

Copy link
@cjw296

cjw296 Dec 9, 2019

Contributor

It makes this a more substantial PR, but Sphinx autodoc should be able to pull in the .py's docstrings. Not sure if autodoc is enabled for the CPython docs, that would be some more digging on your part :-)

This comment has been minimized.

Copy link
@phsilva

phsilva Dec 10, 2019

Author Contributor

Will take a look into it, but it looks like all modules actually repeats docs in Doc and in Lib, will ask around why.

This comment has been minimized.

Copy link
@cjw296

cjw296 Jan 15, 2020

Contributor

How did the asking around go?

@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Dec 1, 2019

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@phsilva

This comment has been minimized.

Copy link
Contributor Author

phsilva commented Dec 2, 2019

I have made the requested changes; please review again.

@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Dec 2, 2019

Thanks for making the requested changes!

@cjw296: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from cjw296 Dec 2, 2019
Doc/library/unittest.mock.rst Outdated Show resolved Hide resolved
@phsilva

This comment has been minimized.

Copy link
Contributor Author

phsilva commented Dec 10, 2019

I have made the requested changes; please review again.

@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Dec 10, 2019

Thanks for making the requested changes!

@cjw296: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from cjw296 Dec 10, 2019
@phsilva phsilva requested a review from lisroach Dec 12, 2019
@phsilva

This comment has been minimized.

Copy link
Contributor Author

phsilva commented Jan 15, 2020

Hi, would be great if can get some review here... Thanks a lot! @lisroach @cjw296

@csabella csabella requested review from cjw296, lisroach and tirkarthi and removed request for cjw296 and lisroach Jan 21, 2020
@cjw296

This comment has been minimized.

Copy link
Contributor

cjw296 commented Jan 24, 2020

@csabella: waiting for a response to #15521 (comment)

@cjw296
cjw296 approved these changes Jan 25, 2020
Copy link
Contributor

cjw296 left a comment

Actually, let's leave the bigger change for another time.

@cjw296 cjw296 added the skip news label Jan 25, 2020
@cjw296 cjw296 merged commit 40c0809 into python:master Jan 25, 2020
4 checks passed
4 checks passed
Azure Pipelines PR #20191210.8 succeeded
Details
bedevere/issue-number Issue number 37955 found
Details
bedevere/news "skip news" label found
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@csabella

This comment has been minimized.

Copy link
Contributor

csabella commented Jan 25, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.