pytest前后置处理有2种方法
一、通过setup/teardown实现
添加setup和teardown方法,作用于每个方法执行前后
添加setup_class/teardown_class方法,作用于每个类执行前后
import pytest
class Test_C():
def setup(self): # 方法前置
print('\n-----函数开始-----', end='')
def teardown(self): # 方法后置
print('\n-----函数结束-----', end='')
def setup_class(self): # 类前置
print('\n-----类开始-----', end='')
def teardown_class(self): # 类后置
print('\n-----类结束-----', end='')
def