Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue28735

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Mock is equal to ANY but MagicMock is not
Type:behaviorStage:resolved
Components:Library (Lib)Versions:Python 3.7, Python 3.6, Python 3.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: berker.peksag, kushal.das, michael.foord, python-dev, rafael.fonseca, serhiy.storchaka, xiang.zhang
Priority:normalKeywords:patch

Created on2016-11-18 16:07 byrafael.fonseca, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
magicmock_eq.patchserhiy.storchaka,2017-01-20 17:37review
Pull Requests
URLStatusLinkedEdit
PR 552closeddstufft,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.ANYTrue>>> mock.ANY == mock.Mock()True>>> mock.MagicMock() == mock.ANYFalse>>> mock.ANY == mock.MagicMock()True
msg285908 -(view)Author: Kushal Das (kushal.das)*(Python committer)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 linuxType "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)*(Python committer)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)*(Python committer)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)*(Python committer)Date: 2017-01-20 17:37
Proposed patch fixes comparing MagicMock with ANY.
msg285925 -(view)Author: Berker Peksag (berker.peksag)*(Python committer)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 fixingissue 25195.
msg285966 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2017-01-21 21:17
New changeset442eb26b1ca4 by Serhiy Storchaka in branch '3.5':Issue#28735: Fixed the comparison of mock.MagickMock with mock.ANY.https://hg.python.org/cpython/rev/442eb26b1ca4New changeset4a38781538f7 by Serhiy Storchaka in branch '3.6':Issue#28735: Fixed the comparison of mock.MagickMock with mock.ANY.https://hg.python.org/cpython/rev/4a38781538f7New changeset597515fcb343 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)*(Python committer)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
DateUserActionArgs
2022-04-11 14:58:39adminsetgithub: 72921
2017-03-31 16:36:21dstufftsetpull_requests: +pull_request952
2017-01-21 21:21:01serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: +msg285967

stage: commit review -> resolved
2017-01-21 21:17:52python-devsetnosy: +python-dev
messages: +msg285966
2017-01-20 23:13:59berker.peksagsetmessages: +msg285925
stage: patch review -> commit review
2017-01-20 17:37:55serhiy.storchakasetfiles: +magicmock_eq.patch
keywords: +patch
messages: +msg285918

stage: patch review
2017-01-20 14:51:39kushal.dassetmessages: +msg285910
2017-01-20 14:49:07xiang.zhangsetnosy: +serhiy.storchaka,berker.peksag,xiang.zhang
messages: +msg285909
2017-01-20 14:25:16kushal.dassetnosy: +kushal.das
messages: +msg285908
2016-11-18 21:02:43SilentGhostsetnosy: +michael.foord

versions: + Python 3.6, Python 3.7
2016-11-18 16:07:14rafael.fonsecacreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp