pytest的基础入门

ops/2024/10/21 3:51:37/

pytest判断用例的成功或者失败

pytest识别用例失败时会报AssertionError或者xxxError错误,当捕获异常时pytest无法识别到失败的用例

pytest的fixture夹具

pytest的参数化

#coding:utf-8
import pytestfrom PythonProject.pytest_test.funcs.guess_point import get_the_number_of_points
test_datas = [6,9,10,4,5]
class TestGuessPoint:@classmethoddef setup_class(cls):print("测试类当中,第一个执行用例之前,做的准备工作代码...")@classmethoddef teardown_class(cls):print("测试类当中所有的用例执行完毕之后做的清理干工作...")# def setup_method(self):#     print("===每一个测试用例之前都要执行===")# def teardown_method(self):#     print("===每一个测试用例之后都要执行===")@pytest.mark.parametrize("case",test_datas)def test_guess(self,case):point = get_the_number_of_points()assert case == point

pytest和allure的结合

#coding:utf-8
import pytest
import allure
from PythonProject.pytest_test.funcs.log_fuc import login
all_datas=[{"user":"1234","passwd":"123456","check":"恭喜登录成功"},{"user":"None123","passwd":"False12345","check":"用户名或密码不正确"},{"user":"123","passwd":"123456","check":"用户名长度小于4"},{"user":"12345","passwd":"12345","check":"密码长度小于6"}
]
# @pytest.mark.usefixtures("class_fix")
class TestLogin:# def setup_method(self):#     print("每一个测试用例之前执行")# def teardown_method(self):#     print("每一个测试用例都要执行的后置")@pytest.mark.parametrize("casep",all_datas)@allure.description("登录模块测试,后端管理员用户角色---")@allure.issue("https://www.baidu.com","bug地址")@allure.testcase("https://www.baidu.com","xx平台测试用例地址")def test_login(self,casep):res = login(casep.get("user"),casep.get("passwd"))assert res == casep.get("check")


http://www.ppmy.cn/ops/123411.html

相关文章

一台电脑轻松接入CANFD总线_来可CNA板卡介绍

在工业控制领域,常常使用的总线技术有CAN(FD)、RS-232、RS-485、Modbus、Profibus、Profinet、EtherCAT等。RS-485以其长距离通信能力著称,Modbus广泛应用于PLC等设备,EtherCAT则以其低延迟和高实时性在自动化系统中备受青睐。 其中&#xff…

YOLOv5改进——普通卷积和C3模块更换为GhostConvV2卷积和C3GhostV2模块

目录 一、GhostNetV2核心代码 二、修改common.py 三、修改yolo.py 三、建立yaml文件 四、训练 一、GhostNetV2核心代码 在models文件夹下新建modules文件夹,在modules文件夹下新建一个py文件。这里为GhostV2.py。复制以下代码到文件里面。 # TODO: ghostnetv…

Qt打开excel文件,并读取指定单元格数据

1. 下载并安装QXlsx库,详见之前的博文Qt子线程创建excel文件报错QObject: Cannot create children for a parent that is in a different thread.-CSDN博客 2. // 创建一个XlsxDocument对象QString filename "D:\\mydocuments\\data_acquisition\\data\\tes…

【mysql】使用AbstractRoutingDataSource实现多数据源 与 获取mapper上注解

使用AbstractRoutingDataSource实现多数据源 与 获取mapper上注解 背景 随着业务发展速度越来越快,数据的增长也呈现倍数级别增长,数据库的压力,对于查询和写入等所有操作,都依赖于主库,其实有一些对于时效性要求不高…

使用idea和vecode创建vue项目并启动(超详细)

一、idea创建vue项目 创建项目之前先下载好插件 新建项目找到vue生成器 写好名称,找到自己需要存放的地址,node解释器安装方式可以看我上一个博客,vueCLI是选择vue的版本,我们可以使用idea自带的vue版本默认是vue3,创…

SQLite Developer使用说明

1.SQLite Developer下载 SQLite Developer官方版是SharpPlus出品的一款数据库管理工具。支持对sqlite3数据库的管理,能够自动完成窗口显示和执行数据库命令等多种特色。并且支持打开.db文件,适用于Android的开发。另外,使用Sqlite Developer…

PGMP-05相关方

目录 1.主要内容 2.概括 3.相关方人员 1.主要内容 Stakeholders IdentificationStakeholders AnalysisStakeholders Engagement PlanningStakeholders EngagementStakeholder communications 2.概括 识别:产生相关方登记册,使用头脑风暴分析&#x…

​el-table去除表格表头多选框或者更换为文字​

多选框那一列加label-class-name 1 <el-table-column type"selection" width"55" label-class-name"DisabledSelection" :reserve-selection"true"></el-table-column> style加样式 1 2 3 4 5 6 7 8 9 10 11 /*表格全…