目录 | <<上一章:各种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():