1.运行多个测试文件
pytest 会运行 test_ 开头 或者 _test 结尾的文件,在当前目录和子目录中
2. 一个类下的多个用例的运行, pytest会找到 test_ 开头的方法
import pytest
class TestClass(object):
def test_one(self):
x = "this"
assert 'h' in x
def test_two(self):
x = "hello"
assert hasattr(x, 'check')
运行一下,-q 是 在安静模式下运行

博客介绍了Pytest的使用方法。Pytest可运行当前目录和子目录中以test_开头或_test结尾的文件,还能在一个类下找到以test_开头的方法来运行多个用例,且可通过 -q 参数在安静模式下运行。
2522

被折叠的 条评论
为什么被折叠?



