yaml_str = """
default: test
test/dev.com:
dev: 10.10.10.1
test: 10.10.10.2
"""
print(load(yaml_str))
env = {
"test/dev.com": {
"dev": "10.10.10.100",
"test": "10.10.10.200",
},
"default": "test",
}
print(dump(env))
结合 pytest 进行参数化,数据驱动
demo:
"""
array:
- 3
- 2
- 1
"""
@pytest.mark.parametrize("num", load(open("demo.yaml", "r"))["array"]) # 结合 pytest 参数化方式,从文件中读取数据
def test_yaml_by_pytest(num):
assert num > 1
数据驱动方法
原文:https://www.cnblogs.com/chenri/p/12695239.html