Skip to content

Preserve original mock message #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 30, 2017

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