pytest快速入门 - 各种数据的结果验证方式

目录 <<上一章:各种pytest执行方式 下一章:pytest夹具的基本概念>>

1 pytest自动化测试 - 各种数据的结果验证方式

  • 数字的验证方式
      检查数字结果是否与预期相符,可以直接使用==号进行判断即可
def test_integer():
    assert 3 == 3

def test_float():
    assert 1.35 == 1.35

def test_oct():
    assert 0o135 == 0o135

def test_bin():
    assert 0b11011 == 0b11011

def test_hex():
    assert 0xABCD == 0xABCD

输出:

$ pytest test_ft_subf_assert_002.py
======================================= test session starts =======================================
platform win32 -- Python 3.13.1, pytest-8.3.4, pluggy-1.5.0
rootdir: D:\TYYSOFT\Study\Python\pytest
collected 5 items

test_ft_subf_assert_002.py .....                                                             [100%]

======================================== 5 passed in 0.01s ========================================

  • 字符串的验证方式
      检查的字符串可以使用==号进行判断,但是复杂的报文使用==就非常不合时宜了!
import re
def test_match_simple_string_001():
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值