[issue35753] Importing call from unittest.mock directly causes ValueError
David Antonini
report at bugs.python.org
Wed Jan 16 15:17:26 EST 2019
New submission from David Antonini <davidantonini at hotmail.com>:
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.
----------
components: Tests
messages: 333786
nosy: toonarmycaptain
priority: normal
severity: normal
status: open
title: Importing call from unittest.mock directly causes ValueError
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35753>
_______________________________________
More information about the Python-bugs-list
mailing list