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
相关推荐
OreoCC2 小时前
第N5周:Pytorch文本分类入门
人工智能·pytorch·python
zimoyin4 小时前
解决 Java/Kotlin 资源加载问题
java·python·kotlin
wjcroom4 小时前
数字投屏叫号器-发射端python窗口定制
开发语言·python
静候光阴4 小时前
python使用venv命令创建虚拟环境(ubuntu22)
linux·开发语言·python
Y1nhl4 小时前
力扣hot100_二叉树(4)_python版本
开发语言·pytorch·python·算法·leetcode·机器学习
wjcroom5 小时前
文本转语音-音画适时推送rtsp并播放
python
老胖闲聊6 小时前
Flask 全栈学习指南
后端·python·flask
小枫小疯6 小时前
Pytorch 转向TFConv过程中的卷积转换
人工智能·pytorch·python
油盐不进的吗6 小时前
4.桥接模式
开发语言·python·桥接模式
魔障阿Q6 小时前
labelimg标注的xml标签转换为yolo格式标签
xml·人工智能·python·深度学习·yolo·计算机视觉