首页 > 其他分享 >pytest + yaml 框架 -47.parameters参数化支持笛卡尔积

pytest + yaml 框架 -47.parameters参数化支持笛卡尔积

时间:2023-07-06 09:11:25浏览次数:35  
标签:parameters 47 hello yaml test world config yml

前言

v1.3.8 版本对 parameters 参数化格式重新做了定义,支持笛卡尔积了。当然以前旧版本的格式还是继续兼容。

parameters 参数化

新版本对 parameters 参数化重新做了定义,简化了步骤,更加清晰简洁.

1.只有一个变量需要参数化的情况

test_p1.yml

config:
  parameters:
    x: ["a", "b", "c"]


test_a:
  print: "输出-${x}"

运行结果

test_p1.yml 输出-a
.输出-b
.输出-c
.

2.有2个变量需要参数化的情况,变量中间用逗号隔开(或者-)
test_p2.yml

config:
  parameters:
    x,y: [["a", "b"], ['c', 'd']]

test_b:
  print: "输出-${x}-${y}"

也可以实现横线隔开

config:
  parameters:
    x-y: [["a", "b"], ['c', 'd']]

运行结果

test_p2.yml 输出-a-b
.输出-c-d
.

笛卡尔积

对2个变量同时参数化,生成笛卡尔积的情况
x 变量只有一个值,可以写成x: "a", 也可以写成x: ["a"]
test_p3.yml

config:
  parameters:
    x: "a"
    y: ["hello", "world"]


test_r:
  name: 11
  print: "组合-${x}-${y}"

x 变量也可以有多个值
test_p4.yml

config:
  parameters:
    x: ["a", 'b']
    y: ["hello", "world"]


test_r:
  name: 11
  print: "组合-${x}-${y}"

运行结果

test_p4.yml 组合-a-hello
.组合-a-world
.组合-b-hello
.组合-b-world
.

模块级别和用例级别参数化

支持模块级别和用例级别参数化

  • config 中 parameters 参数化,作用域是整个模块级别
  • 用例中 parameters 参数化,作用域只针对单个用例

用例级别参数化
test_p5.yml

config:
   name: demo

test_1:
  name: 用例1
  parameters:
    user: [hello, world]
  print: "case-${user}"

运行结果

test_p5.yml case-hello
.case-world
.

config 中 parameters 参数化,作用域是整个模块级别, test_p6.yml 文件示例

config:
  parameters:
    x: ["a", 'b']
    y: ["hello", "world"]


test_a:
  print: "组合-${x}-${y}"

test_b:
  print: "组合-${x}-${y}"

运行结果

test_p6.yml 组合-a-hello
.组合-a-hello
.组合-a-world
.组合-a-world
.组合-b-hello
.组合-b-hello
.组合-b-world
.组合-b-world
.

标签:parameters,47,hello,yaml,test,world,config,yml
From: https://www.cnblogs.com/yoyoketang/p/17531164.html

相关文章

  • 【并查集】 HDOJ 4786 Fibonacci Tree
    就是求出搞成最小生成树的最少白边和最多白边的数量。。。。#include<iostream>#include<queue>#include<stack>#include<map>#include<set>#include<bitset>#include<cstdio>#include<algorithm>#include<cstring>#include<......
  • golang 解析yaml文件
    初始化packagemainimport( "github.com/spf13/viper")funcinitConfig(){ viper.SetConfigName("config") viper.AddConfigPath("./") iferr:=viper.ReadInConfig();err!=nil{ fmt.Println("Initsetingerror:",......
  • 代码随想录算法训练营第二十四天| 491.递增子序列 46.全排列 47.全排列 II
     491.递增子序列 此题的难点:1,前提需要保留原有顺序2,保证递增3,保证去重注意:去重一定要有set的同时保证有顺序代码:1voidfindSubsequences_trackBack(vector<int>&nums,intstartIndex,vector<int>&path,vector<vector<int>>&result)2{3if(path.size(......
  • pytest + yaml 框架 -46.支持模块级别和用例级别参数化
    前言对parameters功能做了优化,支持模块级别和用例级别参数化config中parameters参数化,作用域是整个模块级别用例中parameters参数化,作用域只针对单个用例v1.3.7版本优化此功能模块级别参数化config中parameters参数化,作用域是整个模块级别,test_a.yaml文件示例......
  • Hydro #4766. 文艺计算姬 题解--zhengjun
    link前置知识:Prufer序列,二分图别的题解都是直接给答案,没有比较易懂的思路。首先,考虑Prufer序列,发现右边点删除一定会加入一个左边点,另一边类似。且生成Prufer序列的最后一定会留下左右边各一个点。所以左边点在Prufer序列中出现的次数即为\(m-1\),右边即为\(n-1\)。......
  • 钡铼技术多功能RTU S475多功能RTU改变养殖行业现殖效率
    在养殖行业中,对环境参数的精确监测与控制至关重要。然而,传统的监测方法往往存在诸多痛点,如数据采集不准确、传输速度慢、可视化效果差等。为了解决这些问题,钡铼技术公司推出了其旗舰产品——S475多功能RTU,该产品在养殖行业监测中展现出了显著的优势。钡铼S475多功能RTU是一款......
  • 油田智能化转型:钡铼技术多功能RTUS475的关键角色
    标题:S475在油田数据采集中的应用摘要:本文介绍了钡铼技术多功能RTUS475在油田数据采集中的应用。该设备基于高性能微处理器MCU和嵌入式实时操作系统,支持ModbusSlave和ModbusMaster功能,并能通过无线网络实现短信报警和数据传输到监控中心,为油田数据采集提供了稳定可靠的解决方......
  • efficienthrnet读取H-2yaml文件
    代码读取配置文件创建的网络['features.0.1.weight:torch.Size([24,3,3,3])','features.0.2.weight:torch.Size([24])','features.0.2.bias:torch.Size([24])','features.1.conv.0.1.weight:torch.Size([24,1,3,3])','features.1.......
  • yaml创建模型结构,代码阅读
    *前言.最近读到类似Detectron2结构的训练代码,实在是太痛苦了。因此,做笔记记录一下。1.整体结构:Trainingkit;      |----configs:存储各种网络的yaml配置文件;      |----docs        |----imxcv:运行代码的核心组件;......
  • yaml文件类型解析
    yaml文件类型mysql:host:127.0.0.1user:testport:35039db:testpassword:1234567dp_ip:-192.168.0.1-192.168.0.2-192.168.0.3读取后结果为{'mysql':{'host':'127.0.0.1','user':'test',......