Message333786
Ok so that's a pretty odd bug. I already had from unittest.mock import patch, mock_open so I simply modified that to from instead of doing mock.call in my test. Changing this to from unittest import mock and then mock.call fixed the error.
from unittest.mock import patch, mock_open, call
mocked_print.assert_has_calls([
call("first print"),
call("second print"),
])
I get:
C:\Program Files (x86)\Python37-64\lib\doctest.py:932: in find
self._find(tests, obj, name, module, source_lines, globs, {})
C:\Program Files (x86)\Python37-64\lib\doctest.py:991: in _find
if ((inspect.isroutine(inspect.unwrap(val))
C:\Program Files (x86)\Python37-64\lib\inspect.py:515: in unwrap
raise ValueError('wrapper loop when unwrapping {!r}'.format(f))
E ValueError: wrapper loop when unwrapping call
collected 1 item / 1 errors
But when I don't import call directly my test runs as expected:
from unittest.mock import patch, mock_open
import unittest.mock
mocked_print.assert_has_calls([
mock.call(),
mock.call(),
])
I have the same issue when using:
assert mocked_print.call_args_list == [call("first print"), call("second print")] <- ValueError
assert mocked_print.call_args_list == [mock.call("first print"), mock.call("second print")] <- Works as expected. |
|
Date |
User |
Action |
Args |
2019-01-16 20:17:27 | toonarmycaptain | set | recipients:
+ toonarmycaptain |
2019-01-16 20:17:24 | toonarmycaptain | set | messageid: <1547669844.88.0.953853980523.issue35753@roundup.psfhosted.org> |
2019-01-16 20:17:24 | toonarmycaptain | link | issue35753 messages |
2019-01-16 20:17:24 | toonarmycaptain | create | |
|