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: Mock functions with autospec STILL don't support assert_called_once, assert_called, assert_not_called
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Justin Dray, dybi, matrixise, xtreak
Priority: normal Keywords:

Created on 2018-05-25 07:39 by dybi, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg317659 - (view) Author: Piotr Dybowski (dybi) Date: 2018-05-25 07:39
This is the same issue as: https://bugs.python.org/issue28380.
It seems that fix has never been merged,
msg326342 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-09-25 11:39
Thanks for the report. Can you please add a sample script that reproduces the error and the version of Python you are using? The fix was not merged to Python 3.5 as per msg278214 and I am little confused that this issue has Python 3.6 as affected version.
msg327341 - (view) Author: Justin Dray (Justin Dray) Date: 2018-10-08 11:24
I can still reproduce this with python 3.6.5:

https://gist.github.com/justin8/c6a565d3b64222a9ba3a2568d1d830ee

no .assert_called() on autospec'd functions, but it works with normal mock.MagicMock()

ipython autocomplete shows assert_any_call, assert_called_once, assert_called_with and assert_has_calls as valid functions however?
msg327342 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2018-10-08 11:33
There is a problem with your code, you use `mock` library but this one does not exist in the standard library. 

You should use `unittest.mock` 

Because this issue is not related with the unittest.mock library, I am going to close this issue.
History
Date User Action Args
2022-04-11 14:59:00adminsetgithub: 77824
2018-10-08 11:33:06matrixisesetstatus: open -> closed

nosy: + matrixise
messages: + msg327342

stage: resolved
2018-10-08 11:24:10Justin Draysetnosy: + Justin Dray
messages: + msg327341
2018-09-25 11:39:27xtreaksetnosy: + xtreak
messages: + msg326342
2018-05-25 07:39:19dybicreate