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: unittest.mock.call object has inherited count method
Type: behavior Stage: resolved
Components: Versions: Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: kushal.das, michael.foord, python-dev
Priority: normal Keywords: patch

Created on 2014-04-16 20:49 by michael.foord, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue21270.patch kushal.das, 2014-09-09 13:51 Patch to override touple methods. review
issue21270_v2.patch kushal.das, 2014-09-16 13:00 Patch to override touple methods version 2. review
Messages (7)
msg216587 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2014-04-16 20:49
The unittest.mock.call object inherits methods from tuple that prevent you using them as normal call attributes. They should be overridden.
msg222546 - (view) Author: Kushal Das (kushal.das) * (Python committer) Date: 2014-07-08 06:12
To start with I am overriding count and index method. Do you think this is enough?
msg222562 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2014-07-08 14:24
Those are the only ones I think. Thanks.
msg226634 - (view) Author: Kushal Das (kushal.das) * (Python committer) Date: 2014-09-09 13:51
Forgot to attach the patch. Includes NEWS entry. Overriden methods count() and index().
msg226803 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2014-09-11 21:32
Thanks for this Kushal. It's not quite right though, count and index need to do the same as other attributes looked up with __getattr__. In fact delegating to __getattr__ is probably the easiest way of achieving that. (With the current patch the calls will be incorrect for call.foo.index() or similar I believe.)
msg226950 - (view) Author: Kushal Das (kushal.das) * (Python committer) Date: 2014-09-16 13:00
Uploading the second version of the patch.
msg226951 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-09-16 13:04
New changeset 5660c1bdc2b6 by Kushal Das in branch 'default':
Closes #21270 : We now override tuple methods in mock.call objects.
https://hg.python.org/cpython/rev/5660c1bdc2b6
History
Date User Action Args
2022-04-11 14:58:02adminsetgithub: 65469
2014-09-16 13:04:18python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg226951

resolution: fixed
stage: needs patch -> resolved
2014-09-16 13:00:18kushal.dassetfiles: + issue21270_v2.patch

messages: + msg226950
2014-09-11 21:32:43michael.foordsetmessages: + msg226803
2014-09-09 13:51:15kushal.dassetfiles: + issue21270.patch
keywords: + patch
messages: + msg226634
2014-07-08 14:24:49michael.foordsetmessages: + msg222562
2014-07-08 06:12:55kushal.dassetmessages: + msg222546
2014-04-16 20:49:19michael.foordcreate