Skip to content

Commit

Permalink
add 'mocker.call' convenience name (closes #48)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhermann committed Jun 1, 2016
1 parent 7f8be65 commit 10e4654
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions pytest_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class MockFixture(object):
Mock = mock_module.Mock
MagicMock = mock_module.MagicMock
PropertyMock = mock_module.PropertyMock
call = mock_module.call
ANY = mock_module.ANY

def __init__(self):
Expand Down
13 changes: 13 additions & 0 deletions test_pytest_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,16 @@ def request(cls, method, args):
m = mocker.patch.object(Request, 'request')
Request.request(method='get', args={'type': 'application/json'})
m.assert_called_once_with(method='get', args={'type': 'application/json'})


def deep_thought(*someargs):
"""Just a mocking target."""


def test_assert_has_calls_with_mocker_call(mocker):
mocked = mocker.patch(__name__ + '.deep_thought', return_value=42)
mocked(mocked("question", "about the universe & stuff"))
mocked.assert_has_calls([
mocker.call("question", "about the universe & stuff"),
mocker.call(42),
])

0 comments on commit 10e4654

Please sign in to comment.