pytest
yy050810
这个作者很懒,什么都没留下…
展开
-
yaml数据参数化
1、加载yaml文件yaml.safe_ load(open(" ./data.yaml"))2、yaml内容e.g.1:字典dict:companies: [{id: 1,name: company1,price: 200W},{id: 2,name: company2,price:500W}]yaml文件:companies:- id: 1 name...原创 2020-04-05 21:26:34 · 2559 阅读 · 0 评论 -
pytest.mark.parametrize参数化
1、参数化,前两个变量,后面是对应的数据@pytest.mark.parametrize("test_input,expected",[("3+5",8),("2+5",7),("7*5",30)])def test_eval(test_input,expected): #eval 将字符串str当成有效的表达式来求职,并返回结果 assert eval(test_inp...原创 2020-04-05 19:19:37 · 982 阅读 · 0 评论 -
pytest setup&teardown 各级别
import pytest类似的setup,teardown同样更灵活:模块级(setup_module / teardown_module)模块始末,全局的(优先最高)函数级(setup_function/ teardown_function)只对 函数用例生效(不在类中)类级(setup_class/ teardown_class)只在类中前后运行一次(在类中)方法级(setup_me...原创 2020-04-05 19:17:39 · 472 阅读 · 0 评论