初识pytest


现在这份工作一直做硬件和算法方面,但本人还是很喜欢玩web,所以自学分享一下。

如何安装pytest

其实很简单

pip install pytest
pip install -U pytest -U 表示升级        

pytest和unittest的优劣势

 快速入门写个小demo

import time
def add(x,y):
    return x+y
def test_add2():
        time.sleep(3)
        assert add(1.2,4) == 4

执行失败的结果

import time
def add(x,y):
    return x+y
def test_add2():
        time.sleep(3)
        assert add(0,4) == 4

 执行成功的结果