[issue38763] mock with side effect : assert_called_once returns None while call_count returns 1

2019-11-12 Thread Chris Withers


Change by Chris Withers :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38763] mock with side effect : assert_called_once returns None while call_count returns 1

2019-11-12 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

I think we can close this as not a bug. I don't think we need to add boolean 
return value of True if the assert statements are True since it's never meant 
to be used. I would wait for others opinion on this.

--
nosy: +cjw296, lisroach, mariocj89, michael.foord

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38763] mock with side effect : assert_called_once returns None while call_count returns 1

2019-11-10 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

assert_called_once is supposed to raise an AssertionError if the mock is not 
called and to return None like other assert_* helpers. The return value is not 
supposed to be used and it's more of an assertion action where if it's None 
then it's implied to be True.

>>> from unittest.mock import Mock
>>> def side_effect(*args, **kwargs): print("side_effect called")
...
>>> m = Mock(side_effect=side_effect)
>>> m.call_count
0
>>> m.assert_called_once()
Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/kasingar/stuff/python/cpython/Lib/unittest/mock.py", line 881, 
in assert_called_once
raise AssertionError(msg)
AssertionError: Expected 'mock' to have been called once. Called 0 times.
>>> m()
side_effect called
>>> m.call_count
1
>>> m.assert_called_once()
>>> m.assert_called()
>>> m.assert_has_calls([call()])

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38763] mock with side effect : assert_called_once returns None while call_count returns 1

2019-11-10 Thread Troulet-lambert Odile


New submission from Troulet-lambert Odile :

Using a mock with side_effect, I would expect that assert_called_once returns 
True if the mock has been called.
Yet it returns None while call_count== 1 returns True.

If this is not a bug, I would welcome some explanation in the documentation.

--
components: Tests
files: bugmock.tar
messages: 356341
nosy: piscvau
priority: normal
severity: normal
status: open
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file48706/bugmock.tar

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com