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
相关推荐
dazzle1 分钟前
《DataFrame可视化与高级方法》
python·pandas
Blossom.1183 分钟前
Transformer时序预测实战:用PyTorch构建股价预测模型
运维·人工智能·pytorch·python·深度学习·自动化·transformer
我命由我123453 分钟前
Python Flask 开发问题:ImportError: cannot import name ‘escape‘ from ‘flask‘
服务器·开发语言·后端·python·flask·学习方法·python3.11
baby_hua5 分钟前
20251031_三天速通PyTorch
人工智能·pytorch·python
weixin_404679318 分钟前
pytorch nn.Parameter self.register_parameter() 区别
人工智能·pytorch·python·深度学习·机器学习
idkmn_13 分钟前
Agentic AI 基础概念
人工智能·python·深度学习·chatgpt·langchain
有味道的男人14 分钟前
淘宝图片搜索(拍立淘)+ 店铺全商品爬虫 深度实战指南(Python)
开发语言·爬虫·python
JHC00000020 分钟前
119. 杨辉三角 II
python·算法·面试
加成BUFF25 分钟前
树莓派5控制WS2812 RGB灯带:原理、接线与实战指南
python·嵌入式硬件·远程连接·ws2812·树莓派5
轻竹办公PPT27 分钟前
新媒体运营年终总结PPT常用工具榜单
python·新媒体运营·产品运营·powerpoint