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

大连网站建设价格低服装网都有哪些网站

大连网站建设价格低,服装网都有哪些网站,网站运营核心,为什么语音转文字里面没有海南的unittest使用ddt来实现测试用例参数化、或parameterized实现测试用例参数化#xff0c;pytest测试用例里面对应的参数可以用 parametrize 实现参数化#xff0c;今天我们来了解下fixture参数化paramsfixture的参数可以解决大量重复代码工作,比如数据库的连接、查询、关闭等.同… unittest使用ddt来实现测试用例参数化、或parameterized实现测试用例参数化pytest测试用例里面对应的参数可以用 parametrize 实现参数化今天我们来了解下fixture参数化paramsfixture的参数可以解决大量重复代码工作,比如数据库的连接、查询、关闭等.同样可以使用参数化来测试多条数据用例。fixture源码传入参数scopeparamsautouseidsnamedef fixture(scopefunction, paramsNone, autouseFalse, idsNone, nameNone):Decorator to mark a fixture factory function.This decorator can be used, with or without parameters, to define afixture function.The name of the fixture function can later be referenced to cause itsinvocation ahead of running tests: testmodules or classes can use the pytest.mark.usefixtures(fixturename)marker.Test functions can directly use fixture names as inputarguments in which case the fixture instance returned from the fixturefunction will be injected.Fixtures can provide their values to test functions using return or yieldstatements. When using yield the code block after the yield statement is executedas teardown code regardless of the test outcome, and must yield exactly once.:arg scope: the scope for which this fixture is shared, one offunction (default), class, module,package or session.package is considered **experimental** at this time.:arg params: an optional list of parameters which will cause multipleinvocations of the fixture function and all of the testsusing it.The current parameter is available in request.param.:arg autouse: if True, the fixture func is activated for all tests thatcan see it. If False (the default) then an explicitreference is needed to activate the fixture.:arg ids: list of string ids each corresponding to the paramsso that they are part of the test id. If no ids are providedthey will be generated automatically from the params.:arg name: the name of the fixture. This defaults to the name of thedecorated function. If a fixture is used in the same module inwhich it is defined, the function name of the fixture will beshadowed by the function arg that requests the fixture; one wayto resolve this is to name the decorated functionfixture_fixturename and then usepytest.fixture(namefixturename).if callable(scope) and params is None and autouse is False:# direct decorationreturn FixtureFunctionMarker(function, params, autouse, namename)(scope)if params is not None and not isinstance(params, (list, tuple)):params list(params)return FixtureFunctionMarker(scope, params, autouse, idsids, namename) params 参数一个可选的参数列表它将导致多次调用fixture函数和使用它的所有测试获取当前参数可以使用request.paramrequest 是pytest的内置 fixture 主要用于传递参数1、获取账号密码案例import pytestdata [(username1, password1), (username2, password2)] # data ((username1, password1), (username2, password2)) # data [[username1, password1], [username2, password2]]pytest.fixture(scope function, params data) def get_data(request):print(request.param)return request.paramdef test_login(get_data):print(账号%s%get_data[0],密码%s%get_data[1])if __name__ __main__:pytest.main([-s, test_C_01.py])test_C_01.py (username1, password1) 账号username1 密码password1 .(username2, password2) 账号username2 密码password2 . 2 passed in 0.08s Process finished with exit code 02、前置准备后置清理案例import pytest # 封装删除用户sql def delete_user(user):sql delete from user where mobile %s%userprint(删除用户sql:%s%sql) # 测试数据 mobile_data [18200000000, 18300000000]pytest.fixture(scopefunction, paramsmobile_data) def users(request):注册用户参数化# 前置操作delete_user(request.param)yield request.param# 后置操作delete_user(request.param)def test_register(users):print(注册用户%s%users)if __name__ __main__:pytest.main([-s, test_C_01.py])test_C_01.py 删除用户sql:delete from user where mobile 18200000000 注册用户18200000000 .删除用户sql:delete from user where mobile 18200000000 删除用户sql:delete from user where mobile 18300000000 注册用户18300000000 .删除用户sql:delete from user where mobile 18300000000 2 passed in 0.12s Process finished with exit code 0
http://www.pierceye.com/news/159272/

相关文章:

  • 河南省建设厅网站查询佛山著名网站建设公司
  • 山东搜点网站建设哪家公司做网站最好
  • 云购物网站建设wordpress离线编辑
  • 有没有网站开发团队郑州网站制作电话
  • 网站怎么做登陆免费虚拟机
  • 中国移动网站备案管理系统不能用科普网站建设的支持力度
  • 谁教我做啊谁会做网站啊企业网站模板seo
  • 自己建立一个网站需要什么wordpress 平衡插件
  • 邯郸手机建站价格青海网站开发 建设
  • 苏州 手机网站免费个人简历模板电子版可填写
  • 永州内部网站建设公司wordpress 模版开发
  • 云建站优势门户网站如何建设方案
  • 网站建设收费标准不一湖州网站开发公司
  • asp制作网站青岛建网站公司
  • 人人商城程序做的网站打不开百度网盘客户端下载
  • 医疗器械注册证查询网站优化推广服务
  • 网站制作网页做简单的网站首页
  • 怎样做网站上的语种链接泰安网络犯罪案件
  • soap公司网站建设国家游戏网站
  • 网站可以用什么做安阳区号是什么
  • 网站建设实战李静如何建设网站的能力
  • 威海 网站开发做家具的网站有哪些
  • 宁波网站建设公司怎么报价网页打开速度慢的解决方法
  • 有趣的网站有哪些推荐关键词没有排名的网站怎么做
  • 昆山网站制作哪家强海淀区企业网络公司
  • 北京网站制建设公司永兴县网站建设服务商
  • 嘉兴做网站优化公司江阴网站优化公司
  • dz可以做旅游网站吗wordpress 4.1.1 漏洞
  • 谷歌网站地图生成福州便民网免费发布信息
  • 最新军事战争新闻超级优化大师