Python 如何在Pytest中为每个变量循环所有测试?
我有一本字典:Python 如何在Pytest中为每个变量循环所有测试?,python,loops,dictionary,pytest,Python,Loops,Dictionary,Pytest,我有一本字典: methodCategory = methodCategory2 (it is dynamic variable, so don't mind it) methods = {'methodCategory': ['methodname1', 'methodname2'], 'methodCategory2': ['methodname1', 'methodname2''], ... } 我还有一个pytest类:
methodCategory = methodCategory2 (it is dynamic variable, so don't mind it)
methods = {'methodCategory': ['methodname1', 'methodname2'],
'methodCategory2': ['methodname1', 'methodname2''],
...
}
我还有一个pytest类:
@pytest.mark.parameterized('methodname', methods[methodCategory])
class TestName:
def test_1(methodname):
def test_2(methodname):
def test_3(methodname):
def test_4(methodname):
我想先对每个methodname执行所有测试,然后对第二个methodname执行所有测试:
test_1[methodname1]
test_2[methodname1]
test_3[methodname1]
test_4[methodname1]
test_1[methodname2]
但它是这样的:
test_1[methodname1]
test_1[methodname2]
test_2[methodname1]
test_2[methodname2]
如何在所有测试中循环一个方法名,然后循环第二个方法名?您的问题可能已经有了答案:我不明白,pytest\u generate\u测试看起来非常复杂。我需要帮助。你的问题可能已经有了答案:我不明白,pytest_generate_测试看起来非常复杂。我需要帮助。