def pytest_generate_tests(metafunc): if "testinfra_backend" in metafunc.fixturenames: if metafunc.config.option.hosts is not None: hosts = metafunc.config.option.hosts.split(",") elif hasattr(metafunc.module, "testinfra_hosts"): hosts = metafunc.module.testinfra_hosts else: hosts = [None] params = testinfra.get_backends( hosts, connection=metafunc.config.option.connection, ssh_config=metafunc.config.option.ssh_config, sudo=metafunc.config.option.sudo, ansible_inventory=metafunc.config.option.ansible_inventory, ) ids = [e.get_pytest_id() for e in params] metafunc.parametrize("testinfra_backend", params, ids=ids, scope="module")
def pytest_generate_tests(metafunc): if "_testinfra_backend" in metafunc.fixturenames: if metafunc.config.option.hosts is not None: hosts = metafunc.config.option.hosts.split(",") elif hasattr(metafunc.module, "testinfra_hosts"): hosts = metafunc.module.testinfra_hosts else: hosts = [None] params = testinfra.get_backends( hosts, connection=metafunc.config.option.connection, ssh_config=metafunc.config.option.ssh_config, sudo=metafunc.config.option.sudo, sudo_user=metafunc.config.option.sudo_user, ansible_inventory=metafunc.config.option.ansible_inventory, ) ids = [e.get_pytest_id() for e in params] metafunc.parametrize( "_testinfra_backend", params, ids=ids, scope="module")