文章分类 -  pytest

摘要:1、fixture 测试用例可以接收fixture的名字作为入参,其实参是对应的fixture函数的返回值。通过@pytest.fixture装饰器可以注册一个fixture; fixture作为函数参数 import pytest @pytest.fixture def login(): prin 阅读全文
posted @ 2020-03-04 18:07 xyztank 阅读(136) 评论(0) 推荐(0)
摘要:一、pytest安装和入门 1、安装和升级 安装命令 pip install pytest 升级命令 pip install -U pytest 2、第一个测试函数 def func(x): return x + 1 def test_answer(): assert func(3) == 5 执行 阅读全文
posted @ 2020-03-04 18:05 xyztank 阅读(436) 评论(0) 推荐(0)
摘要:一、pytest-sugar 安装pytest-sugar后,执行测试用例时,可以改变pytest执行的默认外观,让测试用例执行显示进度条等信息。如图: 安装pytest-sugar pip install pytest-sugar 一般执行方法 pytest demo.py 显示更多信息 pyte 阅读全文
posted @ 2020-03-04 18:03 xyztank 阅读(717) 评论(0) 推荐(0)