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
相关推荐
钱栈up40 分钟前
长安汽车把海外年销钉在100万辆,2030年要翻到200万——出海从故事变成基建
爬虫·python·数据分析
富贵儿9981 小时前
NL2SQL 实践手记 03:让模型决定下一步——把 Workflow 改造成 SQL Agent
数据库·python·sql·ai·自然语言处理·langchain
九蝶科技1 小时前
运费分摊的二开实现:BigDecimal 精确分摊 + 尾差补齐 + 暂估调整
开发语言·python
Ryan-Zhong2 小时前
一次接入 16 个平台:视频链接元数据解析 API 的 Python 实战与踩坑记录
开发语言·python·dreamweaver
aihuge20264 小时前
RAG 检索要不要加缓存:同查询二次命中省一次计算,语料一变就得失效
python·大模型·rag
向科→向总工→空间动态计系统4 小时前
动态零轴融合三铁律
大数据·开发语言·人工智能·python·机器人
Cosolar5 小时前
Agent Harness 架构演进与核心设计原则:基于 Pi、OpenCode、Hermes、OpenClaw 的对比研究
python·llm·agent
鸽嗷高.5 小时前
基于博客系统的接口自动化测试报告
python·功能测试·可用性测试
砚底藏山河5 小时前
量化行情横截面中性化闭式与回归实现
android·java·python·金融·kotlin
CCblandy6 小时前
尾延迟请求对冲实测:20ms阈值让p99降至54–56ms,代价是约60%冗余流量
python·性能优化·架构·分布式系统·尾延迟