首页 > 其他分享 >pytest + yaml 框架 -38.新增--start-project命令快速创建项目demo结构

pytest + yaml 框架 -38.新增--start-project命令快速创建项目demo结构

时间:2023-06-19 22:22:32浏览次数:35  
标签:38 -- demo untitled start pytest file test

前言

新增 --start-project 命令, 帮助初学者快速创建项目 demo 结构, 并自动创建几个简单的用例。

创建项目demo结构

执行以下命令

pytest --start-project

运行日志

(venv) D:\demo\untitled_start>pytest --start-project
create ini file: D:\demo\untitled_start\pytest.ini
create config file: D:\demo\untitled_start\config.py
create file: D:\demo\untitled_start\case_demo
create yaml file: D:\demo\untitled_start\case_demo\test_get.yml
create yaml file: D:\demo\untitled_start\case_demo\test_post.yml
create yaml file: D:\demo\untitled_start\case_demo\test_extract.yml

执行完成会自动生成以下文件

test_extract.yml 内容

config:
  name: 参数关联-用例a提取结果给到用例b

test_a:
  name: extract提取结果
  request:
    method: POST
    url: /post
    json:
      username: test
      password: "123456"
  extract:
      url:  body.url
  validate:
  - eq: [status_code, 200]
  - eq: [headers.Server, gunicorn/19.9.0]
  - eq: [$..username, test]
  - eq: [body.json.username, test]

test_b:
  name: 引用上个接口返回
  request:
    method: GET
    url: http://httpbin.org/get
    headers:
      url: ${url}
  validate:
  - eq: [status_code, 200]

自动创建 pytest.ini 文件,并添加 2 个配置参数

[pytest]
log_cli = true
env = test

看到项目结构生成后,仅需执行 pytest 命令即可运行用例

pytest

执行结果

标签:38,--,demo,untitled,start,pytest,file,test
From: https://www.cnblogs.com/yoyoketang/p/17492382.html

相关文章

  • 编码基础
    一、DPCMDPCM编码是一种信号编码器,它以脉冲编码调制(PCM)为基础,基于信号样本的预测添加了一些功能。DPCM的输入信号可以是模拟信号,也可以是数字信号。编码器原始图像输入xk,与预测的xk_hat相减得到残差ek,将残差ek进行量化得到量化编码ek_hat,ek_hat与上一帧预测的图像相加得到预测......
  • 尚医通-day14【创建订单】(内附源码)
    页面预览订单详情订单列表第01章-创建订单生成订单分析生成订单方法参数:就诊人id与排班id生成订单需要获取就诊人信息(微服务远程调用service-user)获取排班信息与规则信息(微服务远程调用service-hosp)下单后,通过接口去医院预约下单(httpclient远程调用医院端的接口)下单......
  • 报错:Failed to execute goal org.codehaus.mojo:........快速解决!
    解决:Failedtoexecutegoalorg.codehaus.mojo:exec-maven-plugin:3.0.0:exec(default-cli)onprojectspring_aop:Commandexecutionfailed.的问题出现如下问题:Failedtoexecutegoalorg.codehaus.mojo:exec-maven-plugin:3.0.0:exec(default-cli)onprojectsprin......
  • MySQL 基本语句总结
    MySQL语句,需要知道一下~总结的一些MySQL语句,仅供参考创建数据库createdatabasemydb1;createdatabaseifnotexistsmydb2charactersetGBK;#(不为空,字符集)createdatabasemydb3charactersetGBKcollategbk_chinese_ci;#(字符集,级别)查看所有数据库showdatab......
  • BindingException异常:Type interface com.niuyun.dao.UserDao is not known to the Ma
    Mybatis出现:org.apache.ibatis.binding.BindingException:Typeinterfacecom.niuyun.dao.UserDaoisnotknowntotheMapperRegistry.的错误,如何解决?错误如下:类型接口dao不知道mapper注册中心点的问题org.apache.ibatis.binding.BindingException:Typeinterfacecom.niuy......
  • 错误:“java.lang.ClassNotFoundException: com.mysql.jdbc.Driver“ 如何解决?
    ——运行项目时遇到java.lang.ClassNotFoundException:com.mysql.jdbc.Driver问题,解决方案:错误如下:java.lang.ClassNotFoundException:com.mysql.jdbc.Driver atorg.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1358) atorg.......
  • 第五届“强网杯”全国网络安全挑战赛-线上赛Writeup
    文章目录WEB[强网先锋]赌徒[强网先锋]寻宝MISC签到BlueTeamingISO1995CipherManEzTime问卷题WEB[强网先锋]赌徒目录扫描发现www.zip下载得到源码index.php<metacharset="utf-8"><?php//hintisinhint.phperror_reporting(1);classStart{public$name='guest';......
  • 2021数字中国创新大赛虎符网络安全赛-Writeup
    文章目录Web签到“慢慢做”管理系统Misc你会日志分析吗Web签到http://cn-sec.com/archives/313267.htmlUser-Agentt:zerodiumsystem("cat/flag");“慢慢做”管理系统根据题目提示,这里第一步登录应该利用一些字符串被md5($string,true)之后会形成如下,从而造成注入PSC:\Users\A......
  • 第十四届全国大学生信息安全竞赛-线上赛Writeup
    文章目录场景实操开场卷WEBeasy_sqleasy_sourceMISCtinytrafficrunning_pixel场景实操二阶卷WEBmiddle_sourceMISC隔空传话场景实操冲刺卷MISCrobot场景实操开场卷WEBeasy_sql有sql报错简单fuzz了一下发现过滤了union、information、column、inno等关键字。无表名,无列名注入......
  • BUUCTF:[安洵杯 2019]easy_web
    https://buuoj.cn/challenges#[%E5%AE%89%E6%B4%B5%E6%9D%AF%202019]easy_webTXpVek5UTTFNbVUzTURabE5qYz0经过base64decode->base64decode->hexdecode得到555.png解码编码脚本或者自己利用在线工具编码也行frombinasciiimport*frombase64import*defdecode(param):r......