Python 我可以基于夹具参数ID使用pytest.mark.skipif吗?

Python 我可以基于夹具参数ID使用pytest.mark.skipif吗?,python,pytest,fixture,Python,Pytest,Fixture,我的conftest.py文件中有一个fixture,它有三个参数: @pytest.fixture(scope="session", params=[(33, 303), (303, 3003), (3003, 300003)], ids=["small", "medium", "large"]) def complete(request): np.random.seed(1234567890) return np.random.rand(*re

我的
conftest.py
文件中有一个fixture,它有三个参数:

@pytest.fixture(scope="session",
        params=[(33, 303), (303, 3003), (3003, 300003)],
        ids=["small", "medium", "large"])
def complete(request):
    np.random.seed(1234567890)
    return np.random.rand(*request.param)
现在,关于一个特定的长时间运行的测试函数,我想跳过“大型”的情况


这有可能吗?

不清楚你在找什么

到目前为止,skip marker评估无法访问测试元数据
您可能需要在测试函数中调用
pytest.skip
确保这是可能的。如下图所示 我正在使用参数化夹具的4个参数中跳过某个参数(使用
skipif

在测试执行过程中,确实会发生跳过,调用测试类中的所有测试将只对fixture的前三个参数执行,并且根据要满足的特定条件,将跳过我们标记为跳过的参数的fixture执行或处理。

@pytest.fixture(
    scope='class',
    params=[
        conf.ACCOUNT_OWNER_ROLE,
        conf.ACCOUNT_READ_ONLY_ROLE,
        conf.ACCOUNT_ADMIN_ROLE,
        pytest.param(conf.PROJECT_USER_ROLE, marks=pytest.mark.skipif(
                environ.get('ENV_FOR_DYNACONF') == 'production',
                reason="This feature isn't yet released to production")
                         ),
    ],
    ids=[
        'Invitee has Account-owner role',
        'Invitee has Account-read-only role',
        'Invitee has Account-Admin role',
        'Invitee has Project-user role',
    ],
)
def my_rbac_root_fixture(
    request,
    spark_client_project_fix,
    spark_client_account_fix,
    spark_client_account_fix_invitee,
):

如果您需要更多关于这个午夜的细节,请告诉我,这不是我想要的。您正在跳过一个基于环境变量的参数。我想跳过一个特定的参数/测试组合,基于在测试中使用skipif装饰器,或者基于参数id在测试体中使用pytest.skip。这确实是一种方法。我根据矩阵的维度在特定的测试用例中调用
pytest.skip
。谢谢
@pytest.fixture(
    scope='class',
    params=[
        conf.ACCOUNT_OWNER_ROLE,
        conf.ACCOUNT_READ_ONLY_ROLE,
        conf.ACCOUNT_ADMIN_ROLE,
        pytest.param(conf.PROJECT_USER_ROLE, marks=pytest.mark.skipif(
                environ.get('ENV_FOR_DYNACONF') == 'production',
                reason="This feature isn't yet released to production")
                         ),
    ],
    ids=[
        'Invitee has Account-owner role',
        'Invitee has Account-read-only role',
        'Invitee has Account-Admin role',
        'Invitee has Project-user role',
    ],
)
def my_rbac_root_fixture(
    request,
    spark_client_project_fix,
    spark_client_account_fix,
    spark_client_account_fix_invitee,
):