比方说,我有一个参数化夹具这样的:如何在Pytest中使用夹具的覆盖参数?
@pytest.fixture(params=[1, 2, 800]):
def resource(request):
return Resource(capacity=request.param)
当我使用夹具作为测试功能参数,Pytest运行与所有三个版本的测试:
def test_resource(resource): # Runs for capacities 1, 2, and 800.
assert resource.is_okay()
然而,一些测试中,我想改变该灯具被内置的参数:
def test_worker(resource, worker): # Please run this for capacities 1 and 5.
worker.use(resource)
assert worker.is_okay()
我怎么可以指定只接受SPECI的某些版本fied夹具?
'indirect = True'位似乎是pytest中记录不完整的宝石之一!谢谢,这正是我需要的! –