pytest-简单使用

 安装 pytest 

cmd中 pip install pytest==3.8.0 

查看pytest版本

pytest --version

 

pycharm中新建文件 test_sample.py

def fun(x):
    return x+1

def test_answer():
    assert fun(3) == 4

def test_answer1():
    assert fun(4) == 5

 

在cmd中进入 文件所在目录,或者直接在pycharm的 Terminal中运行

pytest test_sample.py

posted @ 2019-01-16 17:36  studylady  阅读(240)  评论(0编辑  收藏  举报