Closed
Description
assert_called_once_with
and the other assert_
functions show in the traceback, which is very unhelpful. __tracebackhide__
would help, but this is is a system lib :).
Test
def test_stub(mocker):
stub = mocker.stub()
stub.assert_called_once_with('foo', 'baz')
Output:
================================================================================== FAILURES ==================================================================================
_________________________________________________________________________________ test_stub __________________________________________________________________________________
mocker = <pytest_mock.MockFixture object at 0x7f52cb320cc0>
def test_stub(mocker):
stub = mocker.stub()
> stub.assert_called_once_with('foo', 'baz')
mocker = <pytest_mock.MockFixture object at 0x7f52cb320cc0>
stub = <MagicMock spec='function' id='139993573101520'>
tests/ston/test_utils.py:21:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_mock_self = <MagicMock spec='function' id='139993573101520'>, args = ('foo', 'baz'), kwargs = {}, self = <MagicMock spec='function' id='139993573101520'>
msg = "Expected 'mock' to be called once. Called 0 times."
def assert_called_once_with(_mock_self, *args, **kwargs):
"""assert that the mock was called exactly once and with the specified
arguments."""
self = _mock_self
if not self.call_count == 1:
msg = ("Expected '%s' to be called once. Called %s times." %
(self._mock_name or 'mock', self.call_count))
> raise AssertionError(msg)
E AssertionError: Expected 'mock' to be called once. Called 0 times.
_mock_self = <MagicMock spec='function' id='139993573101520'>
args = ('foo', 'baz')
kwargs = {}
msg = "Expected 'mock' to be called once. Called 0 times."
self = <MagicMock spec='function' id='139993573101520'>
/usr/lib/python3.4/unittest/mock.py:781: AssertionError
Expected Output:
================================================================================== FAILURES ==================================================================================
_________________________________________________________________________________ test_stub __________________________________________________________________________________
mocker = <pytest_mock.MockFixture object at 0x7f07b55ed128>
def test_stub(mocker):
stub = mocker.stub()
> stub.assert_called_once_with('foo', 'baz')
E AssertionError: Expected 'mock' to be called once. Called 0 times.
mocker = <pytest_mock.MockFixture object at 0x7f07b55ed128>
stub = <MagicMock spec='function' id='139671084389320'>
tests/ston/test_utils.py:21: AssertionError
Metadata
Metadata
Assignees
Labels
No labels