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
相关推荐
PFFstronger3 分钟前
基于 Dify 知识库 + Ollama 大模型,自动生成测试用例并导出 XMind 的完整方案
人工智能·python·测试用例·xmind
SomeBottle20 分钟前
【小记】图片托管从又拍云迁移到腾讯云 EO + COS(兼容图片处理参数)
python·计算机网络·学习笔记·对象存储·cdn·折腾
cts6181 小时前
FDE架构师前端选型指南
python
2601_962293792 小时前
【Python教程:自动化处理文件】
python·自动化·编程·文件处理·os模块
禹凕2 小时前
快速幂算法详解与实战
python·算法
sylviiiiiia2 小时前
leetcode hot 100
python·算法·leetcode
半摆烂日常2 小时前
自建WMS和买成品:三年成本对比
大数据·服务器·数据库·python·深度学习·低代码·numpy
2601_962296512 小时前
Python的哈希hashlib模块详细解读
python·md5·sha·加密算法·hashlib
chinesegf2 小时前
comfyui便携版的基础使用
python
OPEN-F2 小时前
ROS2系列教程:Gazebo插件(关节控制/IMU/激光雷达)
c++·python·数码相机·算法·机器人