本文整理汇总了Python中pytest.mark.parametrize方法的典型用法代码示例。如果您正苦于以下问题:Python mark.parametrize方法的具体用法?Python mark.parametrize怎么用?Python mark.parametrize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pytest.mark
的用法示例。
在下文中一共展示了mark.parametrize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: describe_parse_tls_reqcert_opt
# 需要导入模块: from pytest import mark [as 别名]
# 或者: from pytest.mark import parametrize [as 别名]
def describe_parse_tls_reqcert_opt():
@mark.parametrize('value, expected', [
('never', ldap.OPT_X_TLS_NEVER),
('allow', ldap.OPT_X_TLS_ALLOW),
('try', ldap.OPT_X_TLS_TRY),
('demand', ldap.OPT_X_TLS_DEMAND),
('hard', ldap.OPT_X_TLS_HARD),
])
def returns_ldap_OPT_X_TLS_constant_for_valid_value(value, expected):
assert parse_tls_reqcert_opt(value) == expected
assert parse_tls_reqcert_opt(value.upper()) == expected
@mark.parametrize('value', [None, ''])
def returns_None_when_given_falsy(value):
assert parse_tls_reqcert_opt(value) is None
def raises_KeyError_for_invalud_value():
with raises(KeyError):
parse_tls_reqcert_opt('whatever')
示例2: describe_parse_scope_opt
# 需要导入模块: from pytest import mark [as 别名]
# 或者: from pytest.mark import parametrize [as 别名]
def describe_parse_scope_opt():
@mark.parametrize('value, expected', [
('base', ldap.SCOPE_BASE),
('one', ldap.SCOPE_ONELEVEL),
('sub', ldap.SCOPE_SUBTREE)
])
def returns_ldap_SCOPE_constant_for_valid_value(value, expected):
assert parse_scope_opt(value) == expected
assert parse_scope_opt(value.upper()) == expected
@mark.parametrize('value', [None, ''])
def returns_None_when_given_falsy(value):
assert parse_scope_opt(value) is None
def raises_KeyError_for_invalud_value():
with raises(KeyError):
parse_scope_opt('whatever')
示例3: test_obb_size
# 需要导入模块: from pytest import mark [as 别名]
# 或者: from pytest.mark import parametrize [as 别名]
def test_obb_size(sphere, idx, extents):
obb = OBB.build_from_points(sphere['vertices'])
# render_to_png('test_obb_size_%d.png' % idx, lambda: create_gl_list(sphere), obb, (1, 0, 0, 0,
# 0, 1, 0, 0,
# 0, 0, 1, 0,
# 0, 0, -5, 1))
assert tpl_cmp(obb.extents, extents)
# @mark.parametrize('cube,u,v,w,idx', [(cube(1, (0, 0, 0), (0, 0, 0)), (0, 0, 1), (0, -1, 0), (-1, 0, 0), 0),
# (cube(1, (0, 0, 0), (45, 45, 0)), (0, 0, 1), (0, 1, 0), (-1, 0, 0), 1),
# (cube(1, (0, 0, 0), (-45, -45, 0)), (0, 1, 0), (0, 0, 1), (-1, 0, 0), 2)])
# def test_obb_axis(cube, u, v, w, idx):
# obb = OBB.build_from_triangles(cube['vertices'], cube['indices'])
# # render_to_png('test_obb_axis_%d.png' % idx, lambda: create_gl_list(cube), obb, (1, 0, 0, 0,
# # 0, 1, 0, 0,
# # 0, 0, 1, 0,
# # 0, 0, -5, 1))
# assert tpl_cmp(obb.rotation[0], u)
# assert tpl_cmp(obb.rotation[1], v)
# assert tpl_cmp(obb.rotation[2], w)
示例4: describe_is_valid_openssh_pubkey
# 需要导入模块: from pytest import mark [as 别名]
# 或者: from pytest.mark import parametrize [as 别名]
def describe_is_valid_openssh_pubkey():
@mark.parametrize('key', read_fixtures('valid_ssh_keys'))
def returns_true_when_given_valid_pubkey(key):
assert is_valid_openssh_pubkey(key)
@mark.parametrize('key', read_fixtures('invalid_ssh_keys'))
def returns_false_when_given_invalid_pubkey(key):
assert not is_valid_openssh_pubkey(key)
示例5: describe_parse_bool
# 需要导入模块: from pytest import mark [as 别名]
# 或者: from pytest.mark import parametrize [as 别名]
def describe_parse_bool():
@mark.parametrize('value', ['on', 'true', 'yes', 'ON', 'TrUe'])
def returns_True_when_given_truthy_value(value):
assert parse_bool(value)
@mark.parametrize('value', ['off', 'false', 'no', 'NO', 'fooo'])
def returns_False_when_given_non_truthy_value(value):
assert not parse_bool(value)
def returns_False_when_given_None():
assert not parse_bool(None)
示例6: cconv
# 需要导入模块: from pytest import mark [as 别名]
# 或者: from pytest.mark import parametrize [as 别名]
def cconv(*arglists, use_llift=False):
def decorate(fn):
def run_test(args):
result_py = fn(*args)
res = cconv_pipeline.make()(input=fn, use_llift=use_llift)
check_no_free_variables(res["graph"])
result_final = res["output"](*args)
assert result_py == result_final
m = mark.parametrize("args", arglists)(run_test)
m.__orig__ = fn
return m
return decorate
示例7: pytest_generate_tests
# 需要导入模块: from pytest import mark [as 别名]
# 或者: from pytest.mark import parametrize [as 别名]
def pytest_generate_tests(metafunc):
metafunc.parametrize('data_type', ['config', 'switch'])