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-33516: Add support for __round__ to MagicMock #6880

Merged
merged 1 commit into from
May 22, 2018

Conversation

amyreese
Copy link
Contributor

@amyreese amyreese commented May 15, 2018

Adds support for __round__ to MagicMock.

https://bugs.python.org/issue33516

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

Would it be possible to add a short unit test to Lib/unittest/test/testmock/testmagicmethods.py please?

It may be add nice to add tests for trunc and floor as well.

@vstinner
Copy link
Member

For Travis CI, your PR has be bitten by https://bugs.python.org/issue33531 :-(

@amyreese amyreese force-pushed the round branch 3 times, most recently from f9cd107 to 92c03e2 Compare May 17, 2018 15:32
@amyreese
Copy link
Contributor Author

Added unit tests for round/trunc/floor/ceil, and fixed docs build.

self.assertTrue(round(mock))
self.assertTrue(math.trunc(mock))
self.assertTrue(math.floor(mock))
self.assertTrue(math.ceil(mock))
Copy link
Member

Choose a reason for hiding this comment

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

The result of round(), trunc(), etc. are a number, not a boolean. You should use assertEqual(..., value) instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to assert equal to mock.__dunder__() calls.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM, except of the minor issue in the NEWS entry.

@@ -0,0 +1,2 @@
Add ``__round__`` to the list of magic methods supported by
Copy link
Member

Choose a reason for hiding this comment

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

Oh, you didn't mention the module. Please add "unittest.mock: " prefix to this NEWS entry.

@amyreese
Copy link
Contributor Author

Updated/reworded news entry to link to unittest.mock.MagicMock.

@vstinner vstinner merged commit 6c4fab0 into python:master May 22, 2018
@vstinner
Copy link
Member

Thanks @jreese, the change now LGTM. The final version is better than the first version ;-)

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

Successfully merging this pull request may close these issues.

4 participants