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

docs: Fix references to recursive seal of Mocks #9028

Merged
merged 2 commits into from Oct 19, 2018

Conversation

mariocj89
Copy link
Contributor

The documentation references the concept of "submocks" when just referring to child mocks, simplify the docstring and update the example as it assigns the mock without a name, which makes it a valid child mock and the seal recurses into it.

This was misinterpreted at the time of the initial PR as in my tests I've always named all the mocks 😞 .

Happy to open an issue if you think it is worth it.

parent. If a mock is assigned to an attribute of an existing mock,
it is not considered a submock.

The operation seals the mock passed in and all its children recursively.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add here an explanation of what "child mocks" are? The documentation does not clarify exactly what a child mock is and this can be confusing.


The operation seals the mock passed in, all the mocks generated
by accessing an attribute of the mock argument and all assigned
mocks without a name or a `spec` recursively.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be RST or md? If it's RST I think it needs to be

``spec``

instead of:

`spec`

I also find the sentence confusing and don't really understand what it means.

Copy link
Member

@pganssle pganssle Sep 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can re-word like this:

The operation recursively seals the mock passed in, meaning that the mock itself, any mocks generated by accessing one of its attributes, and all assigned mocks without a name or spec will be sealed.

@pganssle
Copy link
Member

Although as I noted I find one sentence a bit confusing, there is nothing grammatically wrong with these documentation changes (in case you want a native English speaker's Seal of Approval).

@mariocj89
Copy link
Contributor Author

I do always want indeed a Native English speaker's SoA.

Please have another look :)

@mariocj89
Copy link
Contributor Author

@pablogsal I've updated the PR in case you want to re-review. As it was awaiting for merge and want to make sure you are OK with the changes.


The operation recursively seals the mock passed in, meaning that
the mock itself, any mocks generated by accessing one of its attributes,
and all assigned mocks without a name or spec.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "that" makes this sentence not make sense. I think you need to add "will be sealed" at the end of this.

As the sealing of the mock hierarchy is based on whether the mock has
the previous one as a parent or not, remove references to the undefined
"submock" concept and explain `seal` just in term of child mocks.
The documentation shows an example where using a new mock prevents
`seal` from applying recursively but for that to work the `Mock`
instance needs to have a name or a spec.

The docs in `library/unittest.mock` have been updated to remove
confusing terms about submock and be explicit about the behavior
expected.
@miss-islington
Copy link
Contributor

Thanks @mariocj89 for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 19, 2018
…H-9028)

The docs in `library/unittest.mock` have been updated to remove
confusing terms about submock and be explicit about the behavior
expected.
(cherry picked from commit 96200eb)

Co-authored-by: Mario Corchero <mariocj89@gmail.com>
@bedevere-bot
Copy link

GH-9974 is a backport of this pull request to the 3.7 branch.

@vstinner
Copy link
Member

@mariocj89: I simplified the commit message. I'm not sure that it's really useful to elaborate more inside the commit message, the change speaks by itself :-) I also adjusted the commit title. Sorry that the commit stayed open for so long. Thanks again for this nice unittest.mock feature ;-)

miss-islington added a commit that referenced this pull request Oct 19, 2018
The docs in `library/unittest.mock` have been updated to remove
confusing terms about submock and be explicit about the behavior
expected.
(cherry picked from commit 96200eb)

Co-authored-by: Mario Corchero <mariocj89@gmail.com>
@mariocj89 mariocj89 deleted the fix_mock_seal_docs branch October 20, 2018 14:44
@mariocj89
Copy link
Contributor Author

Thank you! And absolutely no reason for apologies, things take time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants