-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Mock is equal to ANY but MagicMock is not #72921
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
Comments
On Python 3.5.2 mock.Mock() is equal to mock.ANY, but mock.MagicMock() is not. Minimal example: In Python 3.5.2:
>>> from unittest import mock
>>> mock.Mock() == mock.ANY
True
>>> mock.ANY == mock.Mock()
True
>>> mock.MagicMock() == mock.ANY
False
>>> mock.ANY == mock.MagicMock()
True |
From a checkout in last week. Python 3.7.0a0 (default:c163a76163f7, Jan 15 2017, 22:20:24)
[GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from unittest import mock
>>> mock.ANY == mock.Mock()
True
>>> mock.ANY == mock.MagicMock()
True |
Kushal I think the OP is reporting |
Now I understood, thanks. I think I should have more coffee before commenting on bugs :) |
Proposed patch fixes comparing MagicMock with ANY. |
Serhiy's patch looks pretty good to me, thanks! Also, thanks for the report, Rafael. I definitely forgot to fix this case after fixing bpo-25195. |
New changeset 442eb26b1ca4 by Serhiy Storchaka in branch '3.5': New changeset 4a38781538f7 by Serhiy Storchaka in branch '3.6': New changeset 597515fcb343 by Serhiy Storchaka in branch 'default': |
Thanks Berker. Maybe _Call.__eq__ also should return NotImplemented in some cases, but I don't have a demonstrating example. |
Misc/NEWS
so that it is managed by towncrier #552Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: