當前位置: 首頁>>代碼示例>>Python>>正文


Python mark.parametrize方法代碼示例

本文整理匯總了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') 
開發者ID:jirutka,項目名稱:ssh-ldap-pubkey,代碼行數:22,代碼來源:config_test.py

示例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') 
開發者ID:jirutka,項目名稱:ssh-ldap-pubkey,代碼行數:20,代碼來源:config_test.py

示例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) 
開發者ID:pboechat,項目名稱:pyobb,代碼行數:22,代碼來源:test_obb.py

示例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) 
開發者ID:jirutka,項目名稱:ssh-ldap-pubkey,代碼行數:11,代碼來源:functions_test.py

示例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) 
開發者ID:jirutka,項目名稱:ssh-ldap-pubkey,代碼行數:14,代碼來源:config_test.py

示例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 
開發者ID:mila-iqia,項目名稱:myia,代碼行數:16,代碼來源:test_cconv.py

示例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']) 
開發者ID:huskar-org,項目名稱:huskar,代碼行數:4,代碼來源:test_instance.py


注:本文中的pytest.mark.parametrize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。