当前位置: 首页 > news >正文

vps服务器怎么创建多个网站sem seo什么意思

vps服务器怎么创建多个网站,sem seo什么意思,标书制作教程视频网站,wordpress4.94中文版哈咯#xff0c;大家#xff0c;我们今天来学习pytest单元测试框架#xff0c;这个框架要比unittest更加易于使用#xff0c;结构性也更加好#xff0c;希望大家能够从中学习到有用的东西#xff0c;然后在下一章#xff0c;我们来使用pytest单元测试框架来搭建一个web自…哈咯大家我们今天来学习pytest单元测试框架这个框架要比unittest更加易于使用结构性也更加好希望大家能够从中学习到有用的东西然后在下一章我们来使用pytest单元测试框架来搭建一个web自动化测试项目一起加油直接上整体学习项目结构图pytest项目结构pytest1.安装pytestpip3 install pytest2.pytest框架下的测试文件和测试函数都要以test开头3.在命令行输入pytest即会执行test开头的文件4.pytest.main()也同样可以开始执行 - pytest会在当前命令行所在目录下全局搜索test开头的文件进行执行测试这里我们主要针对unittest 和 pytest的不同之处进行学习一、断言pytest并没有提供专门的断言方法而是直接使用assert进行断言如assert a bassert a in bassert abc() is Trueassert not abc()assert abc() is False二、Fixture是对测试方法、测试函数、测试类和整个测试文件进行初始化或还原测试环境例# 装饰器从session - module - class - function(都是针对每个里面包含的用例去执行,覆盖单位是用例)session:多个文件调用一次可以跨.py文件调用每个.py是一个modulemodule:每个.py文件调用一次每个.py是一个moduleclass:每个类调用一次function:每个函数或方法调用一次# 如果你想一个module下的都用上那就打开改成True, 如下这样就不需要往每个函数里传入fixture# yield xxx接着后续的代码实现tearDown的功能# 如果是把fixture单独存放定义一个conftest.py, 该文件要和case在同级目录下case文件中声明# content of conftest.pyconftest.py:# coding utf8import osos.path.abspath(.)from time import sleepimport pytesta py file which saved pytests fixture for usepytest.fixture(scope function)def before_case_execute():sleep(3)yield before_case_executesleep(3)test_sample.py:# coding utf8# content of conftest.pyimport osos.path.abspath(.)import pytestfrom time import sleep# 装饰器从session - module - class - function# 如果你想一个module下的都用上那就打开改成True, 如下这样就不需要往每个函数里传入fixture# yield实现tearDown的功能pytest.fixture(scope function)def before_each_case():sleep(3)print(Set up now)yield before_each_casesleep(3)print(Tear down now)def add(x):return x 1# def test_add(before_each_case):def test_add(before_case_execute):assert add(3) 4if __name__ __main__:pytest.main()三、参数化pytest的参数化与unittest类似通过pytest.mark.parameterize进行装饰传入需要的值名、值、以及为每一个值指定对应的case名test_parameterize.py:# coding utf8import osos.path.abspath(.)# pytest参数化import pytestpytest.mark.parametrize(x, y, z,[(1, 2, 9), (4, 5, 9), (7, 8, 5)],ids [case1, case2, case3])def test_add(x, y, z):assert x y z# terminal进入当前py文件路径,pytest -v test_parameterize.py指定执行# if __name__ __main__:# pytest.main([-v, -k add, ./test_parameterize.py])四、运行测试1.指定名称中包含某字符串的用例执行pytest -k add test_parameterize.py2.减少运行的冗长日志信息pytest -q test_parameterize.py3.如果出现一条测试用例失败则退出测试pytest -x test_parameterize.py4.运行测试目录pytest ./pytest_object5.指定特定类或方法执行pytest test_parameterize.py::test_add 用::进行分隔6.通过main()运行测试pytest.main([-v, -k add, ./test_parameterize.py]) 每个参数用逗号隔开五、生成测试报告1.生成JUnit XML文件pytest ./pytest_project --junit-xml./pytest_project/report/pytest_log.xml2.生成在线测试报告pytest test_parameterize.py --pastebinall 执行到最后会生成一个链接如下View paste B3CA​bpaste.net六、conftest配置文件(conftest.py 是pytest特有到本地测试配置文件1.可以用来设置项目级别的Fixture2.导入外部插件3.指定钩子函数)pytest扩展1.生成HTML格式的测试报告pip3 install pytest-html pytest ./pytest_project --html./pytest_project/report/pytest_html_result.html2.在用例失败时重试pip3 install pytest-rerunfailurespytest -v pytest_expand.py --reruns 3(重试机制可以增加测试用例的稳定性避免因为一些网络原因、机器卡顿导致的问题)3.pytest-parallel扩展pip3 install pytest-parallelpytest -q pytest_expand.py --tests-per-worker auto(使用并行运行测试case测试可能会导致互相产生干扰需要谨慎使用)# coding utf8import osos.path.abspath(.)import pytestpytest扩展# pytest ./pytest_project --html./pytest_project/report/pytest_html_result.htmldef test_add():assert 1 1 3关注 收藏 点赞哦谢谢啦
http://www.pierceye.com/news/96420/

相关文章:

  • 阜南做网站搜索引擎优化seo多少钱
  • 贵州建设厅网站怎样查询电工证天津网站备案
  • 常州做网站的公司在盐城做网站的网络公司电话
  • seo站外推广如何用wampp 做网站
  • 怎样用手机做网站中企动力百度百科
  • 哪些网站可以做任务挣钱免费app软件
  • 国内简约网站平潭县机场建设网站
  • wordpress 全站通知wordpress怎样打开速度快
  • 广州市建设职业培训学校网站移除wordpress版本
  • 如何申请一个网站 新网动画制作大师
  • 动易后台 网站统计调查 报表类型怎样使用手机相册备份网站源码
  • 做网站放到百度上需要什么查看wordpress使用什么主题
  • 深圳企业网站seo郑州汉狮专业做网站公司
  • 广东网站建设多少钱辛集专业网站建设
  • 怎样做网站公司的销售小程序推广计划怎么赚钱
  • 网站开发文档编写wordpress小说站群
  • 南宁网站开发推广网站html模板下载
  • 网络编辑的网站建设题二手域名交易平台
  • 定制网站开发商业计划书贵南县网站建设公司
  • 如何免费发布个人网站网站项目需求分析
  • 太原免费网站建设网站开发合作协议书
  • 深圳龙华做网站上海响应式网站制作公司
  • 招投标 网站建设专业型网站和个人网站
  • 网站建设需要那些基础增城线上教学
  • 专注移动网站建设免费咨询电脑维修
  • 六里桥做网站公司惠州做网站 百度优化
  • 做网站怎么选择上市公司wordpress 进销存
  • 做视频网站用哪个模板昆明贤邦网站建设
  • 自建网站工具wordpress仿内涵段子
  • 做推广最好的网站是哪个菜鸟网站建设