Skip to content
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

mock.call_args compares as equal and not equal #69185

Closed
akaptur mannequin opened this issue Sep 4, 2015 · 4 comments
Closed

mock.call_args compares as equal and not equal #69185

akaptur mannequin opened this issue Sep 4, 2015 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@akaptur
Copy link
Mannequin

akaptur mannequin commented Sep 4, 2015

BPO 24997
Nosy @rbtcollins, @voidspace, @berkerpeksag, @tirkarthi

Note: 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:

assignee = None
closed_at = <Date 2018-09-22.20:49:16.043>
created_at = <Date 2015-09-04.05:08:39.547>
labels = ['type-bug', 'library']
title = 'mock.call_args compares as equal and not equal'
updated_at = <Date 2018-09-22.20:49:16.013>
user = 'https://bugs.python.org/akaptur'

bugs.python.org fields:

activity = <Date 2018-09-22.20:49:16.013>
actor = 'berker.peksag'
assignee = 'none'
closed = True
closed_date = <Date 2018-09-22.20:49:16.043>
closer = 'berker.peksag'
components = ['Library (Lib)']
creation = <Date 2015-09-04.05:08:39.547>
creator = 'akaptur'
dependencies = []
files = []
hgrepos = []
issue_num = 24997
keywords = []
message_count = 4.0
messages = ['249715', '325986', '326082', '326114']
nosy_count = 5.0
nosy_names = ['rbcollins', 'michael.foord', 'berker.peksag', 'akaptur', 'xtreak']
pr_nums = []
priority = 'normal'
resolution = 'out of date'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue24997'
versions = ['Python 3.5', 'Python 3.6']

@akaptur
Copy link
Mannequin Author

akaptur mannequin commented Sep 4, 2015

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.

@akaptur akaptur mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 4, 2015
@tirkarthi
Copy link
Member

Seems this is not reproducible at least on Python 3.6.4 and Master branch.

# bpo-24997.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

@tirkarthi
Copy link
Member

Seems to have been implemented with ce91387 . 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

@berkerpeksag
Copy link
Member

Correct, this has been fixed in bpo-25195. Closing as 'out of date'. Thanks for triaging!

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants