• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python testgen.parametrize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.testgen.parametrize函数的典型用法代码示例。如果您正苦于以下问题:Python parametrize函数的具体用法?Python parametrize怎么用?Python parametrize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parametrize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: pytest_generate_tests

def pytest_generate_tests(metafunc):
    types = [VMwareProvider, RHEVMProvider, SCVMMProvider]
    argnames, argvalues, idlist = testgen.providers_by_class(
        metafunc, types)

    argnames = ['providers_for_discover', 'start_ip', 'max_range']
    new_id_list = []

    providers_complete = []
    providers_final = []

    for x in idlist:
        providers_complete.append(get_crud(x))

    provider_combinations = sorted(
        find_neighbour_provider_combinations(providers_complete, len(types)), key=len)
    signatures_seen = set()

    for prov_comb in provider_combinations:
        sig = generate_signature(prov_comb)
        if sig in signatures_seen:
            continue
        signatures_seen.add(sig)
        start_ip, max_range = minmax_ip(prov_comb)
        providers_final.append([prov_comb, start_ip, max_range])
        new_id_list.append(sig)

    testgen.parametrize(metafunc, argnames, providers_final, ids=new_id_list, scope="module")
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:28,代码来源:test_provider_discovery.py


示例2: pytest_generate_tests

def pytest_generate_tests(metafunc):
    argnames = ['reg_method', 'reg_data', 'proxy_url', 'proxy_creds']
    argvalues = []
    idlist = []
    all_reg_data = conf.cfme_data['redhat_updates']['registration']
    if 'reg_method' in metafunc.fixturenames:
        for reg_method in REG_METHODS:
            reg_data = all_reg_data.get(reg_method, None)
            if not reg_data or not reg_data.get('test_registration', False):
                continue

            proxy_data = all_reg_data.get('http_proxy', False)
            if proxy_data and proxy_data.get('url', None):
                proxy_url = proxy_data['url']
                proxy_creds = conf.credentials['http_proxy']
                argval = [reg_method, reg_data, proxy_url, proxy_creds]
                argid = '{}-{}'.format(reg_method, 'proxy_on')
                idlist.append(argid)
                argvalues.append(argval)

            argval = [reg_method, reg_data, None, None]
            argid = '{}-{}'.format(reg_method, 'proxy_off')
            idlist.append(argid)
            argvalues.append(argval)

    parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:26,代码来源:test_register_appliance.py


示例3: pytest_generate_tests

def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, 'provisioning')
    argnames = argnames + ['cloud_init_template']

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args['provisioning']:
            # No provisioning data available
            continue

        if args['provider_type'] == "scvmm" or args['provider_type'] == 'virtualcenter':
            continue

        # required keys should be a subset of the dict keys set
        if not {'ci-template', 'ci-username', 'ci-pass', 'template'}.issubset(
                args['provisioning'].viewkeys()):
            continue

        cloud_init_template = args['provisioning']['ci-template']
        if cloud_init_template not in cfme_data.get('customization_templates', {}).keys():
            continue

        argvalues[i].append(get_template_from_config(cloud_init_template))

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
开发者ID:seandst,项目名称:cfme_tests,代码行数:31,代码来源:test_cloud_init_provisioning.py


示例4: pytest_generate_tests

def pytest_generate_tests(metafunc):
    new_idlist = []
    new_argvalues = []

    argnames, argvalues, idlist = testgen.provider_by_type(
        metafunc, PROVIDER_TYPES, required_fields=['datastores'])
    argnames += ['datastore']

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        datastores = args['provider'].data.get('datastores', {})
        if not datastores:
            continue
        for ds in datastores:
            if not ds.get('test_fleece', False):
                continue
            assert ds.get('type', None) in DATASTORE_TYPES,\
                'datastore type must be set to [{}] for smartstate analysis tests'\
                .format('|'.join(DATASTORE_TYPES))
            argvs = argvalues[i][:]
            new_argvalues.append(argvs + [datastore.Datastore(ds['name'], args['provider'].key,
                ds['type'])])
            test_id = '{}-{}'.format(args['provider'].key, ds['type'])
            new_idlist.append(test_id)
    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
开发者ID:akrzos,项目名称:cfme_tests,代码行数:25,代码来源:test_datastore_analysis.py


示例5: pytest_generate_tests

def pytest_generate_tests(metafunc):
    types = ["virtualcenter", "rhevm", "scvmm"]
    argnames, argvalues, idlist = testgen.provider_by_type(metafunc, types)

    argnames = ["providers_for_discover", "start_ip", "max_range"]
    new_id_list = []

    providers_complete = []
    providers_final = []

    for x in idlist:
        providers_complete.append(get_crud(x))

    provider_combinations = sorted(find_neighbour_provider_combinations(providers_complete, len(types)), key=len)
    signatures_seen = set()

    for prov_comb in provider_combinations:
        sig = generate_signature(prov_comb)
        if sig in signatures_seen:
            continue
        signatures_seen.add(sig)
        start_ip, max_range = minmax_ip(prov_comb)
        providers_final.append([prov_comb, start_ip, max_range])
        new_id_list.append(sig)

    testgen.parametrize(metafunc, argnames, providers_final, ids=new_id_list, scope="module")
开发者ID:anewmanRH,项目名称:cfme_tests,代码行数:26,代码来源:test_provider_discovery.py


示例6: pytest_generate_tests

def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    if not idlist:
        return
    new_idlist = []
    new_argvalues = []
    if 'random_pwr_ctl_vm' in metafunc.fixturenames:
        if random_vm_test:
            # Reusing random vm for test
            argnames, new_argvalues, new_idlist = random_vm_test
        else:
            # Picking random VM for tests
            single_index = random.choice(range(len(idlist)))
            new_idlist = ['random_provider']
            new_argvalues = argvalues[single_index]
            argnames.append('random_pwr_ctl_vm')
            new_argvalues.append('')
            new_argvalues = [new_argvalues]
            random_vm_test.append(argnames)
            random_vm_test.append(new_argvalues)
            random_vm_test.append(new_idlist)
    else:
        new_idlist = idlist
        new_argvalues = argvalues
    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="class")
开发者ID:MattLombana,项目名称:cfme_tests,代码行数:26,代码来源:test_vm_power_control.py


示例7: pytest_generate_tests

def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc,
        required_fields=[["provisioning", "template"], ["provisioning", "host"], ["provisioning", "datastore"]],
    )
    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
开发者ID:ManageIQ,项目名称:integration_tests,代码行数:7,代码来源:test_vm_clone.py


示例8: pytest_generate_tests

def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.providers_by_class(metafunc, [InfraProvider])
    argnames = argnames + ['host_type', 'host_name']
    new_argvalues = []
    new_idlist = []

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        prov_hosts = args['provider'].data['hosts']

        if not prov_hosts:
            continue
        for test_host in prov_hosts:
            if not test_host.get('test_fleece', False):
                continue
            assert test_host.get('type', None) in HOST_TYPES,\
                'host type must be set to [{}] for smartstate analysis tests'\
                .format('|'.join(HOST_TYPES))

            argvalues[i] = argvalues[i] + [test_host['type'], test_host['name']]
            test_id = '{}-{}-{}'.format(args['provider'].key, test_host['type'], test_host['name'])
            new_argvalues.append(argvalues[i])
            new_idlist.append(test_id)
    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
开发者ID:rananda,项目名称:cfme_tests,代码行数:25,代码来源:test_host_analysis.py


示例9: pytest_generate_tests

def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc, 'provisioning', template_location=["provisioning", "template"])

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args['provisioning']:
            # No provisioning data available
            continue

        if args['provider'].type == "scvmm":
            continue

        # required keys should be a subset of the dict keys set
        if not {'template', 'host', 'datastore'}.issubset(args['provisioning'].viewkeys()):
            # Need all three for template provisioning
            continue

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
开发者ID:richardfontana,项目名称:cfme_tests,代码行数:25,代码来源:test_provisioning.py


示例10: pytest_generate_tests

def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, required_fields=[
        'iso_datastore',
        ['provisioning', 'host'],
        ['provisioning', 'datastore'],
        ['provisioning', 'iso_template'],
        ['provisioning', 'iso_file'],
        ['provisioning', 'iso_kickstart'],
        ['provisioning', 'iso_root_password'],
        ['provisioning', 'iso_image_type'],
        ['provisioning', 'vlan'],
    ])
    argnames = argnames + ['iso_cust_template', 'iso_datastore']

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        iso_cust_template = args['provider'].data['provisioning']['iso_kickstart']
        if iso_cust_template not in cfme_data.get('customization_templates', {}).keys():
            continue

        argvalues[i].append(get_template_from_config(iso_cust_template))
        argvalues[i].append(ISODatastore(args['provider'].name))
        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
开发者ID:akrzos,项目名称:cfme_tests,代码行数:30,代码来源:test_iso_service_catalogs.py


示例11: pytest_generate_tests

def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc, 'provider_key')
    for i, argvalue_tuple in enumerate(argvalues):
        provider_data = cfme_data['management_systems'][
            argvalue_tuple[argnames.index('provider_key')]]
        if provider_data.get('type', False) != 'virtualcenter':
            continue

    if 'random_snpsht_mgt_vm' in metafunc.fixturenames:
        if random_vm_test:
            argnames, new_argvalues, new_idlist = random_vm_test
        else:
            single_index = random.choice(range(len(idlist)))
            new_idlist = [idlist[single_index]]
            new_argvalues = argvalues[single_index]
            argnames.append('random_snpsht_mgt_vm')
            new_argvalues.append('')
            new_argvalues = [new_argvalues]
            random_vm_test.append(argnames)
            random_vm_test.append(new_argvalues)
            random_vm_test.append(new_idlist)
    else:
        new_idlist = idlist
        new_argvalues = argvalues
    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
开发者ID:slouderm,项目名称:cfme_tests,代码行数:26,代码来源:test_snapshot.py


示例12: pytest_generate_tests

def pytest_generate_tests(metafunc):
    # Filter out providers without templates defined
    argnames, argvalues, idlist = testgen.cloud_providers(metafunc, 'provisioning')

    new_argvalues = []
    new_idlist = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        if not args['provisioning']:
            # Don't know what type of instance to provision, move on
            continue

        # required keys should be a subset of the dict keys set
        if not {'image'}.issubset(args['provisioning'].viewkeys()):
            # Need image for image -> instance provisioning
            continue

        if metafunc.function in {
                test_provision_from_template_with_attached_disks, test_provision_with_boot_volume,
                test_provision_with_additional_volume} \
                and args['provider_type'] != 'openstack':
            continue

        new_idlist.append(idlist[i])
        new_argvalues.append([args[argname] for argname in argnames])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:27,代码来源:test_provisioning.py


示例13: pytest_generate_tests

def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.providers_by_class(metafunc, [VMwareProvider])
    argnames = argnames + ["_host_provider"]

    new_idlist = []
    new_argvalues = []

    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        # TODO
        # All this should be replaced with a proper ProviderFilter passed to testgen.providers()
        if args['provider'].type != "virtualcenter":
            continue
        hosts = args['provider'].data.get("hosts", [])
        if not hosts:
            continue

        version = args['provider'].data.get("version", None)
        if version is None:
            # No version, no test
            continue
        if Version(version) < "5.0":
            # Ignore lesser than 5
            continue

        host = hosts[0]
        creds = credentials[host["credentials"]]
        ip_address = resolve_hostname(host["name"])
        cred = VMwareProvider.Credential(
            principal=creds["username"],
            secret=creds["password"],
            verify_secret=creds["password"]
        )
        # Mock provider data
        provider_data = {}
        provider_data.update(args['provider'].data)
        provider_data["name"] = host["name"]
        provider_data["hostname"] = host["name"]
        provider_data["ipaddress"] = ip_address
        provider_data["credentials"] = host["credentials"]
        provider_data.pop("host_provisioning", None)
        provider_data["hosts"] = [host]
        provider_data["discovery_range"] = {}
        provider_data["discovery_range"]["start"] = ip_address
        provider_data["discovery_range"]["end"] = ip_address
        host_provider = VMwareProvider(
            name=host["name"],
            hostname=host["name"],
            ip_address=ip_address,
            credentials={'default': cred},
            provider_data=provider_data,
        )
        argvalues[i].append(host_provider)
        idlist[i] = "{}/{}".format(args['provider'].key, host["name"])
        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
开发者ID:rananda,项目名称:cfme_tests,代码行数:58,代码来源:test_esx_direct_host.py


示例14: pytest_generate_tests

def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.infra_providers(metafunc,
        required_fields=[
            ['provisioning', 'template'],
            ['provisioning', 'host'],
            ['provisioning', 'datastore']
        ])
    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
开发者ID:sakthivelramakrishnan,项目名称:cfme_tests,代码行数:9,代码来源:test_provisioning_dialog.py


示例15: pytest_generate_tests

def pytest_generate_tests(metafunc):
    # Filter out providers without provisioning data or hosts defined
    argnames, argvalues, idlist = testgen.provider_by_type(metafunc, ['rhevm'],
        required_fields=[
            ['provisioning', 'ci-template'],
            ['provisioning', 'ci-username'],
            ['provisioning', 'ci-pass'],
            ['provisioning', 'image']
    ])
    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope="module")
开发者ID:FilipB,项目名称:cfme_tests,代码行数:10,代码来源:test_cloud_init_provisioning.py


示例16: pytest_generate_tests

def pytest_generate_tests(metafunc):
    # cfme.rest.services requires several provisioning tags
    argnames, argvalues, idlist = testgen.infra_providers(
        metafunc,
        required_fields=[['provisioning', 'template'],
                         ['provisioning', 'host'],
                         ['provisioning', 'datastore'],
                         ['provisioning', 'iso_file'],
                         ['provisioning', 'vlan'],
                         ['provisioning', 'catalog_item_type']])
    testgen.parametrize(metafunc, argnames, argvalues, ids=idlist, scope='module')
开发者ID:ManageIQ,项目名称:integration_tests,代码行数:11,代码来源:test_rest_services.py


示例17: pytest_generate_tests

def pytest_generate_tests(metafunc):
    yield
    if 'rbac_role' in metafunc.fixturenames:
        if enable_rbac:
            try:
                meta_data = metafunc.function.meta
                roles = meta_data.kwargs['from_docs']['rbac']['roles'].keys()
            except:
                raise Exception("Test {} should have metadata describing RBAC roles")

        else:
            roles = ['default']
        testgen.parametrize(metafunc, 'rbac_role', roles)
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:13,代码来源:rbac.py


示例18: pytest_generate_tests

def pytest_generate_tests(metafunc):
    # Filter out providers not meant for Chargeback Testing
    argnames, argvalues, idlist = testgen.provider_by_type(metafunc, ['virtualcenter', 'rhevm'],
        required_fields=[(['cap_and_util', 'test_chargeback'], True)]
    )

    new_argvalues = []
    new_idlist = []
    for i, argvalue_tuple in enumerate(argvalues):

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
开发者ID:ManageIQ,项目名称:integration_tests,代码行数:14,代码来源:test_validate_chargeback_report.py


示例19: pytest_generate_tests

def pytest_generate_tests(metafunc):
    argnames, argvalues, idlist = testgen.infra_providers(metafunc)
    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))

        if args["provider"].type in {"scvmm"}:
            continue

        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
开发者ID:FilipB,项目名称:cfme_tests,代码行数:14,代码来源:test_alerts.py


示例20: pytest_generate_tests

def pytest_generate_tests(metafunc):
    # Filter out providers without host provisioning data defined
    argnames, argvalues, idlist = testgen.providers_by_class(
        metafunc, [InfraProvider], required_fields=[
            ['host_provisioning', 'pxe_server'],
            ['host_provisioning', 'pxe_image'],
            ['host_provisioning', 'pxe_image_type'],
            ['host_provisioning', 'pxe_kickstart'],
            ['host_provisioning', 'datacenter'],
            ['host_provisioning', 'cluster'],
            ['host_provisioning', 'datastores'],
            ['host_provisioning', 'hostname'],
            ['host_provisioning', 'root_password'],
            ['host_provisioning', 'ip_addr'],
            ['host_provisioning', 'subnet_mask'],
            ['host_provisioning', 'gateway'],
            ['host_provisioning', 'dns'],
        ])
    pargnames, pargvalues, pidlist = testgen.pxe_servers(metafunc)
    argnames = argnames + ['pxe_server', 'pxe_cust_template']
    pxe_server_names = [pval[0] for pval in pargvalues]

    new_idlist = []
    new_argvalues = []
    for i, argvalue_tuple in enumerate(argvalues):
        args = dict(zip(argnames, argvalue_tuple))
        try:
            prov_data = args['provider'].data['host_provisioning']
        except KeyError:
            # No host provisioning data available
            continue

        stream = prov_data.get('runs_on_stream', '')
        if not version.current_version().is_in_series(str(stream)):
            continue

        pxe_server_name = prov_data.get('pxe_server', '')
        if pxe_server_name not in pxe_server_names:
            continue

        pxe_cust_template = prov_data.get('pxe_kickstart', '')
        if pxe_cust_template not in cfme_data.get('customization_templates', {}).keys():
            continue

        argvalues[i].append(get_pxe_server_from_config(pxe_server_name))
        argvalues[i].append(get_template_from_config(pxe_cust_template))
        new_idlist.append(idlist[i])
        new_argvalues.append(argvalues[i])

    testgen.parametrize(metafunc, argnames, new_argvalues, ids=new_idlist, scope="module")
开发者ID:rananda,项目名称:cfme_tests,代码行数:50,代码来源:test_host_provisioning.py



注:本文中的utils.testgen.parametrize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testgen.provider_by_type函数代码示例发布时间:2022-05-26
下一篇:
Python testgen.infra_providers函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap