微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Python pytest.mark 模块-parametrize() 实例源码

Python pytest.mark 模块,parametrize() 实例源码

我们从Python开源项目中,提取了以下2代码示例,用于说明如何使用pytest.mark.parametrize()

项目:gobble    作者:openspending    | 项目源码 | 文件源码
def test_handle_raises_error_if_status_is_400(api_call):
    responses.add(api_call.method, api_call.url, body=HTTPError())
    with raises(HTTPError):
        handle(api_call())


# @responses.activate
# @mark.parametrize('api_call',api_calls)
# def test_call_endpoint_with_query_parameters(api_call):
#     responses.add(
#         api_call.method,
#         api_call.url + '?spam=eggs&foo=bar',
#         match_querystring=False
#     )
#     params = dict(foo='bar',spam='eggs')
#     assert api_call(params=params).status_code == 200
项目:gobble    作者:openspending    | 项目源码 | 文件源码
def test_remove_secrets_does_its_job(unsecure_json, secure_json):
    freeze(unsecure_json)
    assert unsecure_json == secure_json


# @responses.activate
# @mark.parametrize('function',api_functions)
# def test_endpoint_saves_request_snapshot_to_file(function):
#     function()
#     assert isfile(function.snapshot._filepath)
#     assert function.snapshot._filepath.endswith('json')
# # noinspection PyShadowingNames,PyUnusedLocal

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐