当前位置: 首页>>代码示例>>Python>>正文


Python pytest.config方法代码示例

本文整理汇总了Python中pytest.config方法的典型用法代码示例。如果您正苦于以下问题:Python pytest.config方法的具体用法?Python pytest.config怎么用?Python pytest.config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pytest的用法示例。


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

示例1: pytest_configure

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def pytest_configure(config):
    # Bind a config object to `pytest` module instance
    pytest.custom_cmdopt = CustomCommandLineOption()
    pytest.custom_cmdopt.add("cpu_only", config.getoption("--cpu_only"))

    # Set the random seed so that the tests are reproducible between test runs and
    # hopefully torch and numpy versions. This seed should also allow all range tests
    # with a starting lr of 1e-5 and an ending lr of 1e-1 to run the full test without
    # diverging
    seed = 1
    random.seed(seed)
    os.environ["PYTHONHASHSEED"] = str(seed)
    np.random.seed(seed)
    torch.manual_seed(seed)
    torch.cuda.manual_seed(seed)
    torch.backends.cudnn.deterministic = True 
开发者ID:davidtvs,项目名称:pytorch-lr-finder,代码行数:18,代码来源:conftest.py

示例2: get_cli_param

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def get_cli_param(config, name_of_param, default=None):
    """
    This is helper function which store cli parameter in RUN section in
    cli_params

    Args:
        config (pytest.config): Pytest config object
        name_of_param (str): cli parameter name
        default (any): default value of parameter (default: None)

    Returns:
        any: value of cli parameter or default value

    """
    cli_param = config.getoption(name_of_param, default=default)
    ocsci_config.RUN['cli_params'][name_of_param] = cli_param
    return cli_param 
开发者ID:red-hat-storage,项目名称:ocs-ci,代码行数:19,代码来源:ocscilib.py

示例3: pytest_collection_modifyitems

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def pytest_collection_modifyitems(session, config, items):
    """
    Add Polarion ID property to test cases that are marked with one.
    """
    for item in items:
        try:
            marker = item.get_closest_marker(name="polarion_id")
            if marker:
                polarion_id = marker.args[0]
                if polarion_id:
                    item.user_properties.append(
                        ("polarion-testcase-id", polarion_id)
                    )
        except IndexError:
            log.warning(
                f"polarion_id marker found with no value for "
                f"{item.name} in {item.fspath}",
                exc_info=True
            ) 
开发者ID:red-hat-storage,项目名称:ocs-ci,代码行数:21,代码来源:ocscilib.py

示例4: check_required_loopback_interfaces_available

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def check_required_loopback_interfaces_available():
    """
    We need at least 3 loopback interfaces configured to run almost all dtests. On Linux, loopback
    interfaces are automatically created as they are used, but on Mac they need to be explicitly
    created. Check if we're running on Mac (Darwin), and if so check we have at least 3 loopback
    interfaces available, otherwise bail out so we don't run the tests in a known bad config and
    give the user some helpful advice on how to get their machine into a good known config
    """
    if platform.system() == "Darwin":
        if len(ni.ifaddresses('lo0')[AF_INET]) < 9:
            pytest.exit("At least 9 loopback interfaces are required to run dtests. "
                            "On Mac you can create the required loopback interfaces by running "
                            "'for i in {1..9}; do sudo ifconfig lo0 alias 127.0.0.$i up; done;'") 
开发者ID:apache,项目名称:cassandra-dtest,代码行数:15,代码来源:conftest.py

示例5: log_global_env_facts

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def log_global_env_facts(fixture_dtest_config, fixture_logging_setup):
    if pytest.config.pluginmanager.hasplugin('junitxml'):
        my_junit = getattr(pytest.config, '_xml', None)
        my_junit.add_global_property('USE_VNODES', fixture_dtest_config.use_vnodes) 
开发者ID:apache,项目名称:cassandra-dtest,代码行数:6,代码来源:conftest.py

示例6: fixture_maybe_skip_tests_requiring_novnodes

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def fixture_maybe_skip_tests_requiring_novnodes(request):
    """
    Fixture run before the start of every test function that checks if the test is marked with
    the no_vnodes annotation but the tests were started with a configuration that
    has vnodes enabled. This should always be a no-op as we explicitly deselect tests
    in pytest_collection_modifyitems that match this configuration -- but this is explicit :)
    """
    if request.node.get_closest_marker('no_vnodes'):
        if request.config.getoption("--use-vnodes"):
            pytest.skip("Skipping test marked with no_vnodes as tests executed with vnodes enabled via the "
                        "--use-vnodes command line argument") 
开发者ID:apache,项目名称:cassandra-dtest,代码行数:13,代码来源:conftest.py

示例7: _upgrade_testing_enabled

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def _upgrade_testing_enabled(config):
    return config.getoption("--execute-upgrade-tests") or config.getoption("--execute-upgrade-tests-only") 
开发者ID:apache,项目名称:cassandra-dtest,代码行数:4,代码来源:conftest.py

示例8: is_master

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def is_master(config):
    """
    Validate slaveinput attribute.

    True if the code running the given pytest.config object
    is running in a xdist master node or not running xdist at all.
    """
    return not hasattr(config, 'slaveinput') 
开发者ID:reportportal,项目名称:agent-python-pytest,代码行数:10,代码来源:plugin.py

示例9: pytest_configure_node

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def pytest_configure_node(node):
    """
    Configure node of tests.

    :param node: _pytest.nodes.Node
    :return: pickle of RPService
    """
    if node.config._reportportal_configured is False:
        # Stop now if the plugin is not properly configured
        return
    node.slaveinput['py_test_service'] = pickle.dumps(node.config.
                                                      py_test_service) 
开发者ID:reportportal,项目名称:agent-python-pytest,代码行数:14,代码来源:plugin.py

示例10: pytest_sessionstart

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def pytest_sessionstart(session):
    """
    Start test session.

    :param session: Session
    :return: None
    """
    if session.config._reportportal_configured is False:
        # Stop now if the plugin is not properly configured
        return

    if is_master(session.config):
        session.config.py_test_service.init_service(
            project=session.config.getini('rp_project'),
            endpoint=session.config.getini('rp_endpoint'),
            uuid=getenv('RP_UUID') or session.config.getini('rp_uuid'),
            log_batch_size=int(session.config.getini('rp_log_batch_size')),
            ignore_errors=bool(session.config.getini('rp_ignore_errors')),
            ignored_attributes=session.config.getini('rp_ignore_attributes'),
            verify_ssl=session.config.getini('rp_verify_ssl'),
            retries=int(session.config.getini('retries')),
        )

        attributes = [{'value': tag} for tag in
                      session.config.getini('rp_launch_attributes')]
        session.config.py_test_service.start_launch(
            session.config.option.rp_launch,
            attributes=attributes,
            description=session.config.option.rp_launch_description
        )
        if session.config.pluginmanager.hasplugin('xdist'):
            wait_launch(session.config.py_test_service.rp) 
开发者ID:reportportal,项目名称:agent-python-pytest,代码行数:34,代码来源:plugin.py

示例11: pytest_collection_finish

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def pytest_collection_finish(session):
    """
    Collect tests if session is configured.

    :param session: pytest.Session
    :return: None
    """
    if session.config._reportportal_configured is False:
        # Stop now if the plugin is not properly configured
        return

    session.config.py_test_service.collect_tests(session) 
开发者ID:reportportal,项目名称:agent-python-pytest,代码行数:14,代码来源:plugin.py

示例12: pytest_sessionfinish

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def pytest_sessionfinish(session):
    """
    Finish session if has attr  'slaveinput'.

    :param session: pytest.Session
    :return: None
    """
    if session.config._reportportal_configured is False:
        # Stop now if the plugin is not properly configured
        return

    if is_master(session.config):
        session.config.py_test_service.finish_launch() 
开发者ID:reportportal,项目名称:agent-python-pytest,代码行数:15,代码来源:plugin.py

示例13: _get_option

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def _get_option(config, key):
    return config.getoption(key) or config.inicfg.get(key) 
开发者ID:SAP,项目名称:PyHDB,代码行数:4,代码来源:conftest.py

示例14: hana_system

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def hana_system():
    host = _get_option(pytest.config, 'hana_host')
    port = _get_option(pytest.config, 'hana_port') or 30015
    user = _get_option(pytest.config, 'hana_user')
    password = _get_option(pytest.config, 'hana_password')
    return HANASystem(host, port, user, password) 
开发者ID:SAP,项目名称:PyHDB,代码行数:8,代码来源:conftest.py

示例15: pytest_configure

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import config [as 别名]
def pytest_configure(config):
    config.addinivalue_line(
        "markers",
        "hanatest: mark test to run only with SAP HANA system"
    ) 
开发者ID:SAP,项目名称:PyHDB,代码行数:7,代码来源:conftest.py


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