コード例 #1
0
        'exceptions': 1
    }, TypeError),
    ({
        'exceptions': (Exception, 2)
    }, TypeError),
    ({
        'on_exception': 5
    }, TypeError),
])
def test_retry_invalid_args(case, exception):
    with pytest.raises(exception):
        _.retry(**case)


@parametrize('case,expected', [(_.times(2, _.stub_list), [[], []]),
                               (_.stub_list(), [])])
def test_stub_list(case, expected):
    assert case == expected


@parametrize('case,expected', [(_.times(2, _.stub_dict), [{}, {}]),
                               (_.stub_dict(), {})])
def test_stub_dict(case, expected):
    assert case == expected


@parametrize('case,expected', [(_.times(2, _.stub_false), [False, False]),
                               (_.stub_false(), False)])
def test_stub_false(case, expected):
    assert case == expected
コード例 #2
0
ファイル: test_utilities.py プロジェクト: dgilland/pydash
    ({'jitter': '1'}, ValueError),
    ({'jitter': (1,)}, ValueError),
    ({'jitter': ('1', '2')}, ValueError),
    ({'exceptions': (1, 2)}, TypeError),
    ({'exceptions': 1}, TypeError),
    ({'exceptions': (Exception, 2)}, TypeError),
    ({'on_exception': 5}, TypeError),
])
def test_retry_invalid_args(case, exception):
    with pytest.raises(exception):
        _.retry(**case)


@parametrize('case,expected', [
    (_.times(2, _.stub_list), [[], []]),
    (_.stub_list(), [])
])
def test_stub_list(case, expected):
    assert case == expected


@parametrize('case,expected', [
    (_.times(2, _.stub_dict), [{}, {}]),
    (_.stub_dict(), {})
])
def test_stub_dict(case, expected):
    assert case == expected


@parametrize('case,expected', [
    (_.times(2, _.stub_false), [False, False]),