Mario Corchero <[email protected]> added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35226>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com