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 himkt
Recipients docs@python, himkt
Date 2022-04-04.03:24:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1649042662.7.0.274264935665.issue47209@roundup.psfhosted.org>
In-reply-to
Content
Currently documentation says we can check call_args_list by providing a list of tuples of arguments.

```
>>> expected = [(), ((3, 4),), ({'key': 'fish', 'next': 'w00t!'},)]
>>> mock.call_args_list == expected
True
```

(from https://docs.python.org/3.11/library/unittest.mock.html#unittest.mock.Mock.call_args_list)

However, I think we have to wrap all arguments with `call`.
I'd happy to send a patch if it should be fixed.


### Reproduce:

```
import time
from unittest.mock import call
from unittest.mock import patch


with patch("time.sleep") as mock_obj:
    time.sleep(1)
    time.sleep(2)

    print("mock_obj.call_args_list")
    print(mock_obj.call_args_list)

    print("mock_obj.call_args_list == [(1,), (2,)]")
    print(mock_obj.call_args_list == [(1,), (2,)])
    print("mock_obj.call_args_list == [call(1,), call(2,)]")
    print(mock_obj.call_args_list == [call(1,), call(2,)])
```

```
> python demo.py                                                                                                                                                             2022-04-04 12:03:18
mock_obj.call_args_list
[call(1), call(2)]
mock_obj.call_args_list == [(1,), (2,)]
False
mock_obj.call_args_list == [call(1,), call(2,)]
True
```


### Links

- Documentation in repo: https://github.com/python/cpython/blob/4216dce04b7d3f329beaaafc82a77c4ac6cf4d57/Doc/library/unittest.mock.rst
- Documentation in page: https://docs.python.org/3.11/library/unittest.mock.html#unittest.mock.Mock.call_args_list
History
Date User Action Args
2022-04-04 03:24:22himktsetrecipients: + himkt, docs@python
2022-04-04 03:24:22himktsetmessageid: <1649042662.7.0.274264935665.issue47209@roundup.psfhosted.org>
2022-04-04 03:24:22himktlinkissue47209 messages
2022-04-04 03:24:22himktcreate