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
相关推荐
神仙别闹9 分钟前
基于Python实现自动化测试作业—图像增广方案
图像处理·python·计算机视觉
坊钰22 分钟前
【LangGraph框架入门级】12. 人机交互:interrupt 中断与 Command 恢复
开发语言·数据库·python·人机交互·ai编程·langgraph
把我格子衫拿来29 分钟前
四元数为什么突然变号?旋转表示、SLERP 与位姿插值避坑
python·机器人·坐标变换·四元数·slerp
Chasing__Dreams42 分钟前
python杂识--24--Nuitak打包exe
开发语言·python
把我格子衫拿来1 小时前
RANSAC 粗配准:离群点很多时,怎样为 ICP 找到可信初值?
python·计算机视觉·三维重建·ransac·点云配准
Web3&Basketball1 小时前
决策模型vs GPT-5实测:便宜400倍
人工智能·python·gpt·大模型·ai落地·推理优化·决策模型
ljt27249606611 小时前
Python笔记(四)--模式匹配与正则
笔记·python
小羊没烦恼!1 小时前
T-SQL查询高级—SQL Server索引中的碎片和填充因子
开发语言·前端·javascript·数据库·后端·python·web安全
the局外人1 小时前
学会 SQLAlchemy 搭建 Python 与 MySQL 之间的数据访问桥梁 🚀
后端·python·sql
zh路西法1 小时前
【生成式模型入门】(四):Flow Matching——从速度场学习到生成路径
python·深度学习·神经网络·生成式模型·diffusionpolicy·flowmatching