富文本描述插件
pytest-describe-it的Python项目详细描述
pytest描述它
示例
一些简单的测试:
importpytestdefadd(x:int,y:int)->int:returnx+y@pytest.mark.describe('add')classTestAdd:@pytest.mark.parametrize(['x','y','expected'],[(1,2,3),(3,4,7),(5,6,10),])@pytest.mark.it('returns {expected} for add({x}, {y})')deftest_add(self,x,y,expected):assertadd(x,y)==expected
pytest输出:
collected3itemstest_add.py..F[100%]======================================FAILURES=======================================________________TestAdd.test_add[[add—returns10foradd(5,6)]]_________________self=<test_add.TestAddobjectat0x10b740b70>,x=5,y=6,expected=10@pytest.mark.parametrize(['x','y','expected'],[(1,2,3),(3,4,7),(5,6,10),])@pytest.mark.it('returns {expected} for add({x}, {y})')deftest_add(self,x,y,expected):>assertadd(x,y)==expectedEassert11==10E+where11=add(5,6)test_add.py:18:AssertionError=========================1failed,2passedin0.05seconds==========================
含pytest糖:
collecting...test_add.py✓✓67%██████▋――――――――――――――――TestAdd.test_add[[add—returns10foradd(5,6)]]―――――――――――――――――self=<test_add.TestAddobjectat0x10e4e3550>,x=5,y=6,expected=10@pytest.mark.parametrize(['x','y','expected'],[(1,2,3),(3,4,7),(5,6,10),])@pytest.mark.it('returns {expected} for add({x}, {y})')deftest_add(self,x,y,expected):>assertadd(x,y)==expectedEassert11==10E+where11=add(5,6)test_add.py:18:AssertionErrortest_add.py⨯100%██████████Results(0.10s):2passed1failed-test_add.py:11TestAdd.test_add[[add—returns10foradd(5,6)]]