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
相关推荐
这里有鱼汤1 小时前
📊量化实战篇:如何计算RSI指标的“拥挤度指标”?
后端·python
JJJJ_iii1 小时前
【机器学习05】神经网络、模型表示、前向传播、TensorFlow实现
人工智能·pytorch·python·深度学习·神经网络·机器学习·tensorflow
William.csj2 小时前
服务器/Pytorch——对于只调用一次的函数初始化,放在for训练外面和里面的差异
人工智能·pytorch·python
Ingsuifon2 小时前
pytorch踩坑记录
人工智能·pytorch·python
smj2302_796826522 小时前
解决leetcode第3721题最长平衡子数组II
python·算法·leetcode
m0_626535202 小时前
力扣题目练习 换水问题
python·算法·leetcode
软件技术NINI2 小时前
MATLAB疑难诊疗:从调试到优化的全攻略
javascript·css·python·html
Q_Q19632884752 小时前
python+uniapp基于微信小程序的助眠小程序
spring boot·python·小程序·django·flask·uni-app·node.js
ZYMFZ2 小时前
python面向对象
前端·数据库·python
wangqiaowq2 小时前
ImmutableList.of() 是 Google Guava 库 提供的一个静态工厂方法,用于创建一个不可变的(immutable)列表。
开发语言·windows·python