基本测试
def test_add(): assert add(2, 3) == 5
fixture 使用
import pytest @pytest.fixture def sample_data(): return [1, 2, 3, 4, 5] def test_sum(sample_data): assert sum(sample_data) == 15
转载请注明:周志洋的博客 » Python实用技巧-pytest 测试框架
def test_add(): assert add(2, 3) == 5
import pytest @pytest.fixture def sample_data(): return [1, 2, 3, 4, 5] def test_sum(sample_data): assert sum(sample_data) == 15
转载请注明:周志洋的博客 » Python实用技巧-pytest 测试框架