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

pytest的基础入门

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.lryc.cn/news/458999.html

相关文章:

  • (31)非零均值信号的时域分析:均值、方差、与功率
  • 架设传奇SF时提示此服务器满员,GEE引擎点开始游戏弹出服务器满员的解决方法
  • QT day06
  • 微信小程序-npm支持-如何使用npm包
  • Spring Cloud Stream 3.x+kafka 3.8整合
  • JavaScript中的数组
  • UE5运行时动态加载场景角色动画任意搭配-场景角色相机动画音乐加载方法(三)
  • c# 中 中文、英文、数字、空格、标点符号占的字符大小
  • 前端_003_js扫盲
  • ValueError: You cannot perform fine-tuning on purely quantized models.
  • DELL R720服务器阵列数据恢复,磁盘状态为Foreign
  • VMDK 0X80BB0005 VirtualBOX虚拟机错误处理-数据恢复——未来之窗数据恢复
  • 【Verilog学习日常】—牛客网刷题—Verilog企业真题—VL67
  • 51、AVR、ARM、DSP等常用芯片之对比
  • PostgreSQL 和Oracle 表压缩的对比
  • 【pyspark学习从入门到精通3】弹性分布式数据集_1
  • 宠物健康监测仪健康守护者
  • 手写mybatis之解析和使用ResultMap映射参数配置
  • LDR6500:低成本一拖二快充线解决方案
  • DS线性表之单链表的讲解和实现(2)
  • LeetCode 73 Set Matrix Zeroes 题目解析和python代码
  • 鸿蒙--WaterFlow 实现商城首页
  • QT 中如何保存matlab 能打开的.mat数据矩阵!
  • 菱形继承(多继承)
  • 【功能安全】什么是Aspice?
  • 基于SpringBoot的国家基础信息管理功能的设计与实现
  • Python酷库之旅-第三方库Pandas(145)
  • 最懂生活的年轻人,都在喝十元奶茶
  • MinIO 学习订阅服务
  • 【D3.js in Action 3 精译_029】3.5 给 D3 条形图加注图表标签(上)