Python 如何仅使用pytest测试特定值?
我想知道如何通过pytest只测试某些值。我想执行的代码如下Python 如何仅使用pytest测试特定值?,python,pytest,Python,Pytest,我想知道如何通过pytest只测试某些值。我想执行的代码如下 导入pytest a=[1,2] b=[1,2,3] @pytest.fixture(参数=a) def返回_a(请求): 返回请求.param @pytest.夹具(参数=b) def返回_b(请求): 返回请求.param def测试(返回a、返回b): 如果返回值_a==1: 断言return\u a您必须重新参数化特定测试,以覆盖return\u a夹具的默认参数化。无法在每个测试中声明某种过滤器。间接参数化示例: # use
导入pytest
a=[1,2]
b=[1,2,3]
@pytest.fixture(参数=a)
def返回_a(请求):
返回请求.param
@pytest.夹具(参数=b)
def返回_b(请求):
返回请求.param
def测试(返回a、返回b):
如果返回值_a==1:
断言return\u a您必须重新参数化特定测试,以覆盖return\u a
夹具的默认参数化。无法在每个测试中声明某种过滤器。间接参数化示例:
# use the default parametization in fixtures
def test_all(return_a, return_b):
...
# overwrite parametrization of `return_a`
@pytest.mark.parametrize("return_a", [1], indirect=True)
def test_some(return_a, return_b):
...