pytest单元测试框架(day01)

安装pytest

pip install pytest

查看pytest版本: pytest --version

pytest 例子

1、默认执行当前目录下的所有以test_为前缀(test_*.py)或以_test为后缀(*_test.py)的文件中以test_为前缀的函数

def test_one(self):
x ='this'

assert 'h' in x


def test_two(self):

x ='hello'

assert hasattr(x,'check')

2、执行

小结:执行文件中以 test开头的函数名

原文地址:https://www.cnblogs.com/ioan/p/9779250.html