This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mock.call_args compares as equal and not equal
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: akaptur, berker.peksag, michael.foord, rbcollins, xtreak
Priority: normal Keywords:

Created on 2015-09-04 05:08 by akaptur, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg249715 - (view) Author: A Kaptur (akaptur) * (Python triager) Date: 2015-09-04 05:08
mock.call_args can be both equal to and not equal to another object:

>>> m = Mock()
>>> m(1,2)
<Mock name='mock()' id='4483976016'>
>>> m.call_args
call(1, 2)
>>> m.call_args == call(1,2)
True
>>> m.call_args != call(1,2)
True

This appears to be a recent regression - it repros on trunk, but not on 3.3 or 2.7 with mock 1.3.0.
msg325986 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-09-21 12:36
Seems this is not reproducible at least on Python 3.6.4 and Master branch.

# bpo24997.py

from unittest.mock import *

m = Mock()
m(1,2)
m.call_args
print("1 ", m.call_args == call(1,2))
print("2 ", m.call_args != call(1,2))


# Master

./python.exe
Python 3.8.0a0 (heads/master:c510c6b8b6, Sep 21 2018, 11:10:24)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
./python.exe ../backups/bpo24997.py
1  True
2  False

# Python 3.6.4

python3.6 ../backups/bpo24997.py
1  True
2  False


Thanks
msg326082 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-09-22 08:01
Seems to have been implemented with ce913877e42b7fa03434c2e765ace891e0f5c4dc . https://bugs.python.org/issue25195 

$ git checkout ce913877e42b7fa03434c2e765ace891e0f5c4dc~1 Lib/unittest/mock.py
$ ./python.exe ../backups/bpo24997.py
1  True
2  True

$ git checkout ce913877e42b7fa03434c2e765ace891e0f5c4dc Lib/unittest/mock.py
$ ./python.exe ../backups/bpo24997.py
1  True
2  False

Thanks
msg326114 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-09-22 20:49
Correct, this has been fixed in issue 25195. Closing as 'out of date'. Thanks for triaging!
History
Date User Action Args
2022-04-11 14:58:20adminsetgithub: 69185
2018-09-22 20:49:16berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg326114

resolution: out of date
stage: needs patch -> resolved
2018-09-22 08:01:21xtreaksetmessages: + msg326082
2018-09-21 12:36:58xtreaksetnosy: + xtreak
messages: + msg325986
2015-09-04 20:09:05terry.reedysetnosy: + rbcollins, michael.foord
2015-09-04 05:08:39akapturcreate