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.

Author mariocj89
Recipients cjw296, mariocj89, michael.foord, xtreak
Date 2018-11-13.11:27:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1542108475.44.0.788709270274.issue35226@psf.upfronthosting.co.za>
In-reply-to
Content
If this is to be done we should not change those tests, I am sure there is code validating calls relying on its "tupleness". Example:

```

>>> import unittest.mock
>>> m = unittest.mock.Mock()
>>> m(1)
>>> m(2, a=1) 
>>> m.assert_has_calls([
...   ((1,), {}),
...   ((2,), {'a':1}),
... ])

```

This is documented here: https://github.com/python/cpython/blob/0d12672b30b8c6c992bef7564581117ae83e11ad/Lib/unittest/mock.py#L1993

On the addition in general,
I cannot really comment on the "call(x=1).foo == call(x=2).foo" or how that is supposed to work, I've used those "nesting calls" minimally. I would try to get a hold of Michael Ford.

As a note, I think nesting calls in unittest.mock.call is supposed to be used only via the https://docs.python.org/3/library/unittest.mock.html#unittest.mock.call.call_list method and for calls only.

See:

```
>>> call(x=1).foo(z=1).call_list() == call(x=1).foo(z=1).call_list()
True
>>> call(x=2).foo(z=1).call_list() == call(x=1).foo(z=1).call_list()
False
```

which "works as expected".

Having support for:

```call(x=1).foo == call(x=2).foo``` is kind of trying to validate an attribute has been accessed, which is a different thing from what mock.calls seems to be doing at the moment. It could be added I guess, but I don't see how do can you use that in `mock.assert_has_calls` for example. What is the "real life" issue that you faced with this issue? Because creating and comparing calls yourself is not something that is usually done, I guess you compared it to a mock call.
History
Date User Action Args
2018-11-13 11:27:55mariocj89setrecipients: + mariocj89, cjw296, michael.foord, xtreak
2018-11-13 11:27:55mariocj89setmessageid: <1542108475.44.0.788709270274.issue35226@psf.upfronthosting.co.za>
2018-11-13 11:27:55mariocj89linkissue35226 messages
2018-11-13 11:27:55mariocj89create