def ddt(path): with open(path, 'r', encoding='utf-8') as f: data = yaml.safe_load(f) return pytest.mark.parametrize('data', data) @ddt("./data/req.yaml") def test_b(self,data): print(data)
其中ddt()方法可以放到conftest.py文件中