-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-33516: Add support for __round__ to MagicMock #6880
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
Conversation
There was a problem hiding this 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.
For Travis CI, your PR has be bitten by https://bugs.python.org/issue33531 :-( |
f9cd107
to
92c03e2
Compare
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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
Updated/reworded news entry to link to unittest.mock.MagicMock. |
Thanks @jreese, the change now LGTM. The final version is better than the first version ;-) |
Adds support for
__round__
to MagicMock.https://bugs.python.org/issue33516