From 10e46549af531c5692151cad40e5180fa31bb1c8 Mon Sep 17 00:00:00 2001 From: jhermann Date: Wed, 1 Jun 2016 13:08:20 +0200 Subject: [PATCH] add 'mocker.call' convenience name (closes #48) --- pytest_mock.py | 1 + test_pytest_mock.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/pytest_mock.py b/pytest_mock.py index 34ae2a0..cadcc50 100644 --- a/pytest_mock.py +++ b/pytest_mock.py @@ -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): diff --git a/test_pytest_mock.py b/test_pytest_mock.py index d64c0eb..ae09e56 100644 --- a/test_pytest_mock.py +++ b/test_pytest_mock.py @@ -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), + ])