D101【python 接口自动化学习】- pytest进阶之fixture用法

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
总结
  1. fixture的作用范围:session>module>class>function
相关推荐
Chase_______17 小时前
计算机数据存储全解:从底层进制转换到存储介质演进
java·开发语言·python
构建的乐趣18 小时前
测度(Measure)和概率测度(Probability Measure) 测度和度量的区别
python
清水白石00819 小时前
把事故变成护城河:如何设计回归测试,防止“订单重复创建”这类历史 Bug 卷土重来?
python·bug
狐狐生风19 小时前
LangGraph 工具调用集成
python·langchain·prompt·agent·langgraph
MATLAB代码顾问19 小时前
【智能优化】无穷优化算法(INFO)原理与Python实现
开发语言·python·算法
SilentSamsara19 小时前
迭代器协议:`__iter__` / `__next__` 的完整执行流程
开发语言·人工智能·python·算法·机器学习
yuanpan19 小时前
Python + psutil 实战:开发一个简易系统监控工具
linux·运维·python
MATLAB代码顾问19 小时前
【智能优化】鹈鹕优化算法(POA)原理与Python实现
开发语言·python·算法
研究点啥好呢19 小时前
凯捷 自动化测试(Java+Selenium)面试题精选:10道高频考题+答案解析
java·开发语言·python·selenium·测试工具·求职招聘
SilentSamsara20 小时前
生成器进阶:`yield from`、协程历史与双向通信
开发语言·python·青少年编程·pycharm