随笔分类 -  python接口自动化

摘要:对于JSON文件,通过load反序列化,把JSON转化为字典,再取出字典里的列表,把列表的数据通过装饰器传给函数,装饰器会让函数循环执行,直到没数据 对于excel文件,通过读取excel,两层循环把数据拿出来形成一个列表(excel有几行就n-1个子列表),把子列表的数据通过装饰器传给函数,装饰器 阅读全文
posted @ 2025-12-10 11:57 咸阳的小铁匠 阅读(18) 评论(0) 推荐(0)
摘要:"""测试创建新闻的异常场景"""import pytestimport business.common as commoncookie=common.root_login()test_data=[ ( { "action": "", "data": { "name": "", "coverimag 阅读全文
posted @ 2025-12-08 14:28 咸阳的小铁匠 阅读(20) 评论(0) 推荐(0)
摘要:"""测试创建新闻的异常场景"""import pytestimport business.common as commoncookie=common.root_login()test_data=[ { "action": "", "data": { "name": "", "coverimage" 阅读全文
posted @ 2025-12-08 13:55 咸阳的小铁匠 阅读(15) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2025-12-08 12:49 咸阳的小铁匠 阅读(11) 评论(0) 推荐(0)
摘要:1 import pytest 2 3 4 @pytest.mark.order(index=3,before='test_third') #啥都不填默认最后执行,使用index,before插入到原来的3前执行 也可以设置after 5 def test_bar(): 6 assert True 阅读全文
posted @ 2022-10-27 11:58 咸阳的小铁匠 阅读(115) 评论(0) 推荐(0)
摘要:conftest.py 通过yield分隔执行前和执行后运行 session:整个用例执行前后 module:py文件执行前后 class:类前后执行 function:每个方法前后 conftest.py 的文件名称是固定的, pytest 会自动识别该文件,我们可以理解成一个专门存放 fixtu 阅读全文
posted @ 2022-10-26 18:00 咸阳的小铁匠 阅读(104) 评论(0) 推荐(0)
摘要:setup_module() teardown_module() 模块级别(py文件) setup_class() teardown_class() 类级别 setup_function() teardown_function() 函数级别(不在类中的用例) setup_method() teard 阅读全文
posted @ 2022-10-26 17:59 咸阳的小铁匠 阅读(46) 评论(0) 推荐(0)
摘要:pytest --collect-only 搜集要运行的测试用例,不运行 匹配表达式 -k D:\tools\pycharm\autotest>pytest -k "test_create_article or test_article_edit_alias" --collect-only 匹配包含 阅读全文
posted @ 2022-10-26 12:16 咸阳的小铁匠 阅读(169) 评论(0) 推荐(0)
摘要:创建任务 中午12点 H/5 * * * 代表5分钟一次 cd /var/jenkins_home/workspace/autotest 代表进入jenkins从git拉取到的项目路径,这个项目路径下有个文件test_ruall.py import pytestpytest.main(["-v",f 阅读全文
posted @ 2022-10-25 15:06 咸阳的小铁匠 阅读(61) 评论(0) 推荐(0)