import pytest import yaml class TestDemo: @pytest.mark.parametrize("env", yaml.safe_load(open("./date.yaml"))) def test_demo(self,env): if "test" in env: print("这是一个测试环境") print(env) elif "dev" in env: print("这是一个开发环境") def test_yaml(self): print(yaml.safe_load(open("./date.yaml")))