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 toonarmycaptain
Recipients toonarmycaptain
Date 2019-01-16.20:19:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547669948.02.0.595479199536.issue35753@roundup.psfhosted.org>
In-reply-to
Content
I'm having a problem with mock.call when I import it directly from unittest.mock.

When I do:

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.
History
Date User Action Args
2019-01-16 20:19:10toonarmycaptainsetrecipients: + toonarmycaptain
2019-01-16 20:19:08toonarmycaptainsetmessageid: <1547669948.02.0.595479199536.issue35753@roundup.psfhosted.org>
2019-01-16 20:19:08toonarmycaptainlinkissue35753 messages
2019-01-16 20:19:07toonarmycaptaincreate