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
相关推荐
小羊羔heihei7 分钟前
Python编程实战:12道趣味算法题
笔记·python·学习·其他·算法·学习方法·交友
南 阳24 分钟前
Python从入门到精通day59
开发语言·python·php
JMchen12324 分钟前
Android NDK开发从入门到实战:解锁应用性能的终极武器
android·开发语言·c++·python·c#·android studio·ndk开发
weixin_4577600025 分钟前
深入解析 Beam Search:从原理到实践的高效解码算法
python·算法
小羊羔heihei1 小时前
Python列表操作全攻略
经验分享·笔记·python·学习·其他·交友
2501_908329851 小时前
实战:用OpenCV和Python进行人脸识别
jvm·数据库·python
老刘说AI2 小时前
WorkFlow Agent案例:auto_document_agent(文件自动处理)
开发语言·数据库·人工智能·python·神经网络·自然语言处理
ZhengEnCi2 小时前
M1-如何转换为HTML
python·html
科学创新前沿2 小时前
逆向设计新范式:深度学习驱动的声学超材料智能优化!
人工智能·python·深度学习·声学·逆向设计·声学超材料
Sagittarius_A*2 小时前
传统图像分割:阈值 / 区域生长 / 分水岭 / 图割全解析【计算机视觉】
图像处理·人工智能·python·opencv·计算机视觉·图像分割