数据驱动
import pytest @pytest.mark.parametrize(("a", "b", "expected"), [ [1, 2, 3], [10, 11, 21], [1, 1, 1], ]) def test_1(a, b, expected): assert a + b == expected if __name__ == "__main__": pytest.main(["-v"]) ================================== test_pytest.py::test_1[1-2-3] PASSED [ 33%] test_pytest.py::test_1[10-11-21] PASSED [ 66%] test_pytest.py::test_1[1-1-1] FAILED [100%]