最近对pytest比较感兴趣,看了pytest的文档classic xunit-style setup,这里做个小结,直接看代码。
# content of test_websites.py
'''
Setup/teardown in pytest, see https://docs.pytest.org/en/3.5.1/xunit_setup.html
Remarks:
1. setup/teardown的结对函数在测试进程中可以被调用多次的。
2. 如果setup函数在执行时失败或被skipped了,相应的tearDown函数不会被调用。
'''
import pytest
def setup_module(module):
"""
这是一个module级别的setup,它会在本module(test_website.py)里
所有test执行之前,被调用一次。
注意,它是直接定义为一个module里的函数"""
print()
print(