pytest 参数化
pytest 参数化
import pytest
@pytest.mark.parametrize('amount,expected', [
(1, True), (99, True), (0, False), (100, False),
])
def test_withdraw(amount, expected):
assert can_withdraw(amount) is expected参数组合要显式列出测试意图:给每组关键数据加注释或命名,评审更直观。