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

氧os哪个网站做的最好泉州搜索推广

氧os哪个网站做的最好,泉州搜索推广,wdlinux wordpress,医疗器械分类目录2021pythonpytestpytest-htmlallure集成测试案例 下面是pythonpytestpytest-htmlallure四个组件同时集成使用的简单案例。 1. 项目结构 project/ │ ├── src/ │ ├── __init__.py │ ├── main.py │ ├── tests/ │ ├── __init__.py │ ├── conftest.p…pythonpytestpytest-htmlallure集成测试案例 下面是pythonpytestpytest-htmlallure四个组件同时集成使用的简单案例。 1. 项目结构 project/ │ ├── src/ │ ├── __init__.py │ ├── main.py │ ├── tests/ │ ├── __init__.py │ ├── conftest.py │ └── test_main.py │ ├── __init__.py ├── requirements.txt ├── pytest.ini └── README.md安装上述目录以此创建测试文件文件内容参考如下。 2. 依赖文件 在requirements.txt文件中添加的依赖项内容如下 pytest pytest-html allure-pytest requests2. pytest 配置文件 创建配置文件pytest.ini [pytest] addopts --htmlreport.html --self-contained-html --alluredirallure-results其中 --htmlreport.html --self-contained-html为pytest-html的参数运行测试后会在当前路径下生成report.html的报告同时html集成了CSS样式内容。 --alluredirallure-results为allure-pytest的参数指定allure结果文件的路径。 3. 被测试的模块 src/main.py文件内容如下实现一个接口通过requests的get方法请求测试站点的资源。 def get_post(post_id):import requestsresponse requests.get(fhttps://jsonplaceholder.typicode.com/posts/{post_id})return response.json()说明 JSONPlaceholder 是一个免费的在线 REST API用于测试和原型开发。它提供了一系列虚拟的 API 端点开发者可以用来模拟实际的 RESTful API 请求和响应。这对于开发和测试前端应用程序、学习和实验 API 调用等非常有帮助而不需要自己搭建服务器或实际的数据存储。 4. 编写测试用例 将fixture写入到tests/conftest.py: import pytestpytest.fixture(scopesession) def base_url():return https://jsonplaceholder.typicode.com测试用例tests/test_main.py内容如下 from src.main import get_postdef test_get_post(base_url):post_id 1post get_post(post_id)assert post[id] post_idassert post[title] is not Noneassert post[body] is not None5. 准备运行环境 下面通过windows环境进行测试 创建一个虚拟环境并激活 在项目路径下打开cmd窗口使用下面命令创建测试的虚拟环境 python -m venv pytest-demo.\pytest-demo\Scripts\activate安装依赖项 pip install -r requirements.txt6. 运行测试和生成报告 pytest说明 由于测试站点在国外测试时偶尔会出现网络问题可以多运行几次测试。 如果遇到错误ModuleNotFoundError: No module named src 可以尝试如下解决办法 方法 1调整 PYTHONPATH 确保项目根目录在 PYTHONPATH 中。可以在运行 pytest 前设置 PYTHONPATH 环境变量 在 Unix 或 macOS 上 export PYTHONPATH$(pwd) pytest在 Windows 上 set PYTHONPATH%cd% pytest方法2pytest.ini配置 在 pytest.ini 中添加 pythonpath 设置 [pytest] addopts --htmlreport.html --self-contained-html --alluredirallure-results pythonpath .方法3使用相对导入 from ..src.main import get_post 同时需要在项目根路径project/下创建一个__init__.py文件指示当前文件夹为一个包。 方法4在conftest.py中添加路径 在 tests/conftest.py 文件中手动添加src的绝对路径到 sys.path import sys import os sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), .., src)))7. 查看测试报告 allure serve allure-results执行上述命令后会自动打开浏览器显示Allure报告 另外根路径下也生成了由pytest-html生成的报告 对比可以看出allure报告框架的功能更强大一些。 本文由mdnice多平台发布
http://www.dnsts.com.cn/news/253267.html

相关文章:

  • 网站 主办单位性质 个人织梦网站安装教程视频
  • 网站空间网站虚拟空间抚州建设工程网站
  • 外贸网站模板 下载php cms网站建设
  • 网站制作外包价格怎么做自己的个人网站
  • 专业网页设计培训西安网站关键词优化推荐
  • 江门网站建设服务为什么平面设计最后都转行了
  • 浏阳做网站的公司价格对高校网站建设的期待
  • 北京网站建设 义创做教育机构的设计哪些网站好
  • 网站内容建设要求age06html静态网页首页模板
  • 扬州品牌网站设计网站的佣金怎么做会计分录
  • 惠山网站建设网站备案号是什么意思
  • 房产信息查询平台seo网站分析案例
  • 云服务器建设网站软件电商平台是做什么
  • 做网站vi系统是什么wordpress文章添加标签居中
  • 天津 网站 备案深圳做小程序开发哪家好
  • 网站开发属于什么会计科目哈尔滨个人建站模板
  • 新建网站怎么做有名的网页游戏
  • 阿里巴巴做网站联系人番禺网站开发价格
  • 曹鹏wordpress建站seo视频做2手车网站需要多少钱
  • 网页制作网站制作注册公司线上的网址
  • 私人网站怎么注册南充做网站公司
  • html5美食网站东莞建工集团
  • 云南网站开发网络公司前10网页制作基本步骤
  • 商业网站建设目标建设公司网站的申请
  • 化妆品网站建设实施方案桥 网站建设
  • 百度站长工具有哪些苏州网站制作公司排名
  • 阐述网站建设的步骤韩国出线了吗
  • 全县网站建设情况通报房屋装修案例
  • 如何用模板建网站咋样做网站快照
  • qq空间做单页网站有哪些网站是可以接单做任务的