Issue28735
Created on 2016-11-18 16:07 by rafael.fonseca, last changed 2017-03-31 16:36 by dstufft. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| magicmock_eq.patch | serhiy.storchaka, 2017-01-20 17:37 | review | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 552 | closed | dstufft, 2017-03-31 16:36 | |
| Messages (8) | |||
|---|---|---|---|
| msg281135 - (view) | Author: Rafael Jacinto Caricio da Fonseca (rafael.fonseca) | Date: 2016-11-18 16:07 | |
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 |
|||
| msg285908 - (view) | Author: Kushal Das (kushal.das) * | Date: 2017-01-20 14:25 | |
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 |
|||
| msg285909 - (view) | Author: Xiang Zhang (xiang.zhang) * | Date: 2017-01-20 14:49 | |
Kushal I think the OP is reporting `mock.MagicMock() == mock.ANY` is False while `mock.ANY == mock.MagicMock()` is True which is still the case in 3.7. A related issue is #25195. In that issue Serhiy has mentioned this behaviour(http://bugs.python.org/issue25195#msg259822). |
|||
| msg285910 - (view) | Author: Kushal Das (kushal.das) * | Date: 2017-01-20 14:51 | |
Now I understood, thanks. I think I should have more coffee before commenting on bugs :) |
|||
| msg285918 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2017-01-20 17:37 | |
Proposed patch fixes comparing MagicMock with ANY. |
|||
| msg285925 - (view) | Author: Berker Peksag (berker.peksag) * | Date: 2017-01-20 23:13 | |
Serhiy's patch looks pretty good to me, thanks! Also, thanks for the report, Rafael. I definitely forgot to fix this case after fixing issue 25195. |
|||
| msg285966 - (view) | Author: Roundup Robot (python-dev) | Date: 2017-01-21 21:17 | |
New changeset 442eb26b1ca4 by Serhiy Storchaka in branch '3.5': Issue #28735: Fixed the comparison of mock.MagickMock with mock.ANY. https://hg.python.org/cpython/rev/442eb26b1ca4 New changeset 4a38781538f7 by Serhiy Storchaka in branch '3.6': Issue #28735: Fixed the comparison of mock.MagickMock with mock.ANY. https://hg.python.org/cpython/rev/4a38781538f7 New changeset 597515fcb343 by Serhiy Storchaka in branch 'default': Issue #28735: Fixed the comparison of mock.MagickMock with mock.ANY. https://hg.python.org/cpython/rev/597515fcb343 |
|||
| msg285967 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * | Date: 2017-01-21 21:21 | |
Thanks Berker. Maybe _Call.__eq__ also should return NotImplemented in some cases, but I don't have a demonstrating example. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2017-03-31 16:36:21 | dstufft | set | pull_requests: + pull_request952 |
| 2017-01-21 21:21:01 | serhiy.storchaka | set | status: open -> closed resolution: fixed messages: + msg285967 stage: commit review -> resolved |
| 2017-01-21 21:17:52 | python-dev | set | nosy:
+ python-dev messages: + msg285966 |
| 2017-01-20 23:13:59 | berker.peksag | set | messages:
+ msg285925 stage: patch review -> commit review |
| 2017-01-20 17:37:55 | serhiy.storchaka | set | files:
+ magicmock_eq.patch keywords: + patch messages: + msg285918 stage: patch review |
| 2017-01-20 14:51:39 | kushal.das | set | messages: + msg285910 |
| 2017-01-20 14:49:07 | xiang.zhang | set | nosy:
+ serhiy.storchaka, berker.peksag, xiang.zhang messages: + msg285909 |
| 2017-01-20 14:25:16 | kushal.das | set | nosy:
+ kushal.das messages: + msg285908 |
| 2016-11-18 21:02:43 | SilentGhost | set | nosy:
+ michael.foord versions: + Python 3.6, Python 3.7 |
| 2016-11-18 16:07:14 | rafael.fonseca | create | |