如何绕过pytest夹具装饰器?
How to bypass pytest fixture decorator?
@pytest_fixture
def some_fix():
return some_data
我想直接调用这个some_fix函数。如何绕过 pytest fixture 装饰器?
应用任何绕过装饰器的技巧与在递增数字后递减数字具有相同的价值。最干净的解决方案是定义两个函数:
def plain_function():
# call this function when you need to bypass decorator
pass
@pytest.fixture
def simlar_fixture():
return plain_function()
@pytest_fixture
def some_fix():
return some_data
我想直接调用这个some_fix函数。如何绕过 pytest fixture 装饰器?
应用任何绕过装饰器的技巧与在递增数字后递减数字具有相同的价值。最干净的解决方案是定义两个函数:
def plain_function():
# call this function when you need to bypass decorator
pass
@pytest.fixture
def simlar_fixture():
return plain_function()