这里所说的测试模块实际就是测试脚本的文件,以上在讲的时候测试文件一致命名为test_demo.py,在本章开始也没有说什么要用test_demo.py,反正就这么用着,用到这里就有必要来分析分析文件的命名规则了
在pytest中,测试模块的命名规则是以test_开头或者_test结尾的文件,默认认为是测试文件
同样,话不多说,这里还是先来几个例子,这里需要创建几个文件(https://gitee.com/redrose2100/pytest-demo/tree/master/ch03/ex_004)
test_demo.py文件代码如下
def test_demo():
print("in test_demo.py")
assert 1==1
demo_test.py文件代码如下:
def test_demo():
print<