day101 pytest的fixture执行顺序
学习日期:20241218
学习目标:pytest基础用法 -- pytest的fixture执行顺序
学习笔记:
fixtrue的作用范围
实战结果
python
import pytest
@pytest.fixture(scope='session')
def test_session():
print('我是 session fixture')
@pytest.fixture(scope='module')
def t_module():
print('我是 module fixture')
@pytest.fixture(scope='function')
def t_function():
print('我是 function fixture')
@pytest.fixture(scope='class')
def t_class():
print('我是 class fixture')
class TestOrder:
def test_order(self,t_class,t_function,test_session,t_module):
assert 1==1
总结
- fixture的作用范围:session>module>class>function