【第十一届大唐杯全国大学生新一代信息通信技术大赛】赛题分析
文章目录

Pytest 简介
Pytest 官网

Pytest 核心
Pytest 原理

Pytest 用途
Pytest 特点
Pytest 安装
pip install pytest
Pytest 编写测试用例规则
Pytest 编写第一条测试用例
用例代码示例
import pytest
def addition(x, y):
return x + y
def test_01_a():
print("正在执行 test_a 函数...")
assert addition(3, 5) == 8
class TestClassCase01:
def test_01_b(self):
assert "a" in "apple"
def test_01_c(self):
assert "a" in "apple"
if __name__ == '__main__':
pytest.main()
class TestCase01:
def test_02_a(self):
print("正在执行 test_02_a 函数...")
def test_02_b(self):
print("正在执行 test_02_b 函数...")
可执行测试

执行一条测试

执行多条测试

Pytest 运行方式
run模式


pytest模式

run模式扩展
命令行模式
Pytest.main()常用命令