Skip to content

Conversation

nicoddemus
Copy link
Member

Follow up to #79

def test(mocker):
    m = mocker.Mock()
    m('fo')
    m.assert_called_once_with('', bar=4)

Output:

____________________________________ test _____________________________________

mocker = <pytest_mock.MockFixture object at 0x0381E2D0>

    def test(mocker):
        m = mocker.Mock()
        m('fo')
>       m.assert_called_once_with('', bar=4)
E       AssertionError: Expected call: mock('', bar=4)
E       Actual call: mock('fo')
E
E       pytest introspection follows:
E
E       Args:
E       assert ('fo',) == ('',)
E         At index 0 diff: 'fo' != ''
E         Use -v to get the full diff
E       Kwargs:
E       assert {} == {'bar': 4}
E         Right contains more items:
E         {'bar': 4}
E         Use -v to get the full diff

test_foo.py:6: AssertionError
========================== 1 failed in 0.03 seconds ===========================

cc @txomon @quodlibetor

This supports Python 2 and Python 3, and dramatically reduces the number of
lines that show up in tracebacks in Python 3.
@quodlibetor
Copy link
Contributor

That looks beautiful.

@nicoddemus nicoddemus merged commit 9d221d5 into pytest-dev:master Mar 30, 2017
@nicoddemus nicoddemus deleted the preserve-mock-msg branch March 30, 2017 22:30
@nicoddemus
Copy link
Member Author

pytest-mock 1.6.0 is out! 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants