mock.sentinel.res0

Here are the examples of the python api mock.sentinel.res0 taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

Example 1

Project: mockextras Source File: test_stub.py
def test_stub_arg_matching():
    mock_fn = Mock()
    mock_fn.side_effect = stub((call(), sentinel.res0),
                               (call(sentinel.arg1), sentinel.res1),
                               (call(datetime(1978, 2, 2, 12, 34, 56)), sentinel.res2),
                               (call(Any()), sentinel.res3),
                               (call(x=sentinel.argx, y=sentinel.argy), sentinel.res4),
                               (call(x=sentinel.argx, y=datetime(1978, 2, 2, 12, 34, 56)), sentinel.res5),
                               (call(x=sentinel.argx, y=Any()), sentinel.res6))

    assert mock_fn() == sentinel.res0
    assert mock_fn(sentinel.arg1) == sentinel.res1
    assert mock_fn(Any()) == sentinel.res1
    assert mock_fn(Any(datetime)) == sentinel.res2
    assert mock_fn(datetime(1978, 2, 2, 12, 34, 56)) == sentinel.res2
    assert mock_fn(datetime(1978, 2, 2, 12, 45, 00)) == sentinel.res3
    assert mock_fn(sentinel.meh) == sentinel.res3
    assert mock_fn(x=sentinel.argx, y=sentinel.argy) == sentinel.res4
    assert mock_fn(x=sentinel.argx, y=datetime(1978, 2, 2, 12, 34, 56)) == sentinel.res5
    assert mock_fn(x=sentinel.argx, y=Any()) == sentinel.res4
    assert mock_fn(x=sentinel.argx, y=Any(datetime)) == sentinel.res5
    assert mock_fn(x=sentinel.argx, y=sentinel.meh) == sentinel.res6