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
相关推荐
拾贰_C1 分钟前
[Python | pytorch | torchvision ] models like ResNet... 命名变量说明
开发语言·pytorch·python
清水白石00811 分钟前
《Python 装饰器模式与代理模式深度剖析:从语法技巧到架构实战》
python·代理模式·装饰器模式
dagouaofei11 分钟前
AI自动生成PPT工具横评,真实使用感受分享
人工智能·python·powerpoint
阿华田51236 分钟前
如何基于Jupyter内核自研NoteBook
ide·python·jupyter·自研notebook
W如Q扬1 小时前
python程序使用supervisor启停
python·supervisor
Piar1231sdafa1 小时前
蓝莓果实检测与识别——基于decoupled-solo_r50_fpn_1x_coco模型实现
python
拾零吖1 小时前
Python 常用内置函数
python
行走的bug...1 小时前
python项目管理
开发语言·python
其美杰布-富贵-李1 小时前
tsai 完整训练流程实践指南
python·深度学习·时序学习·fastai
m0_462605221 小时前
第N9周:seq2seq翻译实战-Pytorch复现-小白版
人工智能·pytorch·python