我的conftest.py
文件中有一个夹具,它有三个参数:
@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)
现在在一个特定的长时间运行的测试函数上,我想跳过"大"案例。
@pytest.mark.skipif(...)
def test_snafu(complete):
assert ...
这在某种程度上可能吗?
不清楚你要找什么
截至目前,跳过标记评估无法访问测试元数据您可能希望在测试函数中调用pytest.skip
当然有可能。如下所示我正在跳过我参数化夹具的 4 个参数中的某个参数(使用 skipif
)。
在测试执行中,跳过确实发生了,调用测试类中的所有测试将只对夹具的前三个参数执行,并且对于我们标记为 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,
):
如果您需要有关此@Midnighter的更多详细信息,请告诉我