文章目录
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 函数...")