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

做网站大公司哪个网站可以做销售记录

做网站大公司,哪个网站可以做销售记录,免费ip地址网站,免费 网站管理系统导读 fixture 是 pytest 中一个非常重要的模块#xff0c;可以让代码更加简洁。 fixture 的 autouse 为 True 可以自动化加载 fixture。 如果不想每条用例执行前都运行初始化方法(可能多个fixture)怎么办#xff1f;可不可以只运行一次初始化方法#xff1f; 答#xf…导读 fixture 是 pytest 中一个非常重要的模块可以让代码更加简洁。 fixture 的 autouse 为 True 可以自动化加载 fixture。 如果不想每条用例执行前都运行初始化方法(可能多个fixture)怎么办可不可以只运行一次初始化方法 答可以使用 scope 。 举例 要先创建一个文件conftest.py 编写代码 import pytestdata  {}pytest.fixture(scopesession) def add():相加return 5  8pytest.fixture(scopesession) def multiply():相乘return 5 * 8pytest.fixture(scopesession, autouseTrue) def init_data():初始化数据print(fstart init_data: {data})data[a]  5data[b]  8data[c]  13data[d]  40data[e]  53data[f]  520pytest.fixture(scopesession, autouseTrue) def init_data2(add, multiply):初始化数据print(fstart init_data2: {data})data[e]  add * multiplydata[f]  add  multiply 这里注意init_data2 引用了 add 和 multiply 这两个fixture所以这两个 fixture 都需要加上: pytest.fixture(scopesession)如果不加上就会报错ScopeMismatch: You tried to access the function scoped fixture add with a session scoped request object。 这是因为 init_data2 的作用域是 session而  add 和 multiply 的作用域是 function。所以要在同级上才能使用。 新建测试文件test_fixtures_scope.py, 编写测试代码 from conftest import datadef test_first_fixture():# Actprint(fa{data[a]})print(fb{data[b]})print(fa  b{data[c]})print(fa * b{data[d]})# Assertassert data[c]  data[a]  data[b]def test_second_fixture():print(fadd * multiply{data[e]})print(fadd  multiply{data[f]})# Assertassert data[e] ! data[f] 测试 正确使用 $ pytest -sv test_fixtures_scope.pytest session starts  platform darwin -- Python 3.12.0, pytest-8.2.2, pluggy-1.5.0 -- /Users/hope/PythonVirtualenv/pytest-sample/bin/python cachedir: .pytest_cache rootdir: /Users/hope/PycharmProjects/pytest-sample collected 2 itemstest_fixtures_scope.py::test_first_fixture start init_data: {} start init_data2: {a: 5, b: 8, c: 13, d: 40, e: 53, f: 520} a5 b8 a  b13 a * b40 PASSED test_fixtures_scope.py::test_second_fixture add * multiply520 add  multiply53 PASSED 2 passed in 0.01s 可以看到 这行日志只运行了一次 start init_data: {} start init_data2: {a: 5, b: 8, c: 13, d: 40, e: 53, f: 520}当两个fixture不在同一作用域 $ pytest -sv test_fixtures_scope.pytest session starts  platform darwin -- Python 3.12.0, pytest-8.2.2, pluggy-1.5.0 -- /Users/hope/PythonVirtualenv/pytest-sample/bin/python cachedir: .pytest_cache rootdir: /Users/hope/PycharmProjects/pytest-sample collected 2 itemstest_fixtures_scope.py::test_first_fixture ERROR test_fixtures_scope.py::test_second_fixture ERROR ERRORS  __________________________ ERROR at setup of test_first_fixture __________________________ ScopeMismatch: You tried to access the function scoped fixture add with a session scoped request object. Requesting fixture stack: conftest.py:18:  def init_data(add, multiply) Requested fixture: conftest.py:6:  def add() _________________________ ERROR at setup of test_second_fixture __________________________ ScopeMismatch: You tried to access the function scoped fixture add with a session scoped request object. Requesting fixture stack: conftest.py:18:  def init_data(add, multiply) Requested fixture: conftest.py:6:  def add()short test summary info  ERROR test_fixtures_scope.py::test_first_fixture - Failed: ScopeMismatch: You tried to access the function scoped fixture add with a ses... ERROR test_fixtures_scope.py::test_second_fixture - Failed: ScopeMismatch: You tried to access the function scoped fixture add with a ses...2 errors in 0.02s 总结 fixtures 会在测试一开始的时候创建会在定义的作用域销毁。 function: 默认的 scope在测试用例(以test开头的方法)结束时销毁。 class: 在一个class类中最后一个测试用例结束时销毁。 module: 在一个模块(也就是一个py文件)中最后一个测试用例结束时销毁。 package: 在一个目录的最后一个测试用例结束时销毁。 session所有测试用例都运行结束时销毁。 每日踩一坑生活更轻松。 本期分享就到这里啦祝君在测开之路上越走越顺越走越远。 最后感谢每一个认真阅读我文章的人看着粉丝一路的上涨和关注礼尚往来总是要有的虽然不是什么很值钱的东西如果你用得到的话可以直接拿走  软件测试面试文档 我们学习必然是为了找到高薪的工作下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料并且有字节大佬给出了权威的解答刷完这一套面试资料相信大家都能找到满意的工作。
http://www.hkea.cn/news/14400319/

相关文章:

  • 寺庙网站建设足球最新比赛消息
  • 新闻发布的网站静态网站开发用到的技术
  • 快手刷赞网站推广软件敬请期待英文翻译
  • 想在意大利做购物网站仿36氪wordpress
  • 做一个高端网站多少钱品质好货
  • 饮料网站模板莞城网页设计
  • 深圳产品推广网站建设方案做网站需要营业执照嘛
  • 虚拟主机 删除网站缓存建立网站费用怎么做会计分录
  • vs2010c 做网站郑州网站开发设计公司电话
  • 成都市锦江区网站建设免费旅行社网站模板
  • 企业网站哪个好石家庄网站开发设计
  • 弹幕网站怎么做网络营销创意方案
  • 石家庄学做网站建设培训班在线网站生成器
  • 网站哪个公司做网络域名也可以用中文名称来命名
  • 网站的二级栏目怎么做怎么建立自己的网站卖东西
  • 想做一个部门的网站怎么做邯郸百度爱采购
  • 贵阳网站建设哪家好开发网站需要什么人员
  • 长沙网站制作公司推荐上海公司牌照申请流程
  • 电脑平面设计培训班多少钱百度seo关键词排名技术
  • 黑龙江省建设银行网站开发一个小程序要多少费用
  • 徐州品牌网站建设|徐州网站优化|徐州网络公司-徐州启思信息科技个人博客登录
  • 哪个网站做自考题目免费新增网站建设方案
  • 网站排名推广推荐怎么做健康咨询网站
  • ui设计自学网站推荐韩城全员核酸检测
  • 基层建设 网站重庆网站制作服务
  • 瑞安商业网站建设个人网站做导购可以吗
  • 东莞效果好的营销型网站建设企业品牌推广网站
  • 手机版企业网站深圳比邻网站建设
  • 在国内做推广产品用什么网站好网站的主机
  • 网站 专题建设服务咸宁网站建设报价