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
相关推荐
weixin_4215850112 分钟前
解释代码:val_pred = vxm_model.predict(val_input)--与tensor对比
python
xwill*18 分钟前
python 字符串拼接
linux·windows·python
superman超哥31 分钟前
仓颉锁竞争优化深度解析
c语言·开发语言·c++·python·仓颉
一晌小贪欢32 分钟前
【Python办公自动化】Python办公自动化常用库新手指南
开发语言·python·python自动化办公·python3·python办公自动化·python办公
其美杰布-富贵-李1 小时前
Python 反射完整学习笔记
笔记·python·学习·反射
热心市民小刘05051 小时前
12.23二叉树的层序遍历
python
yaoh.wang1 小时前
力扣(LeetCode) 111: 二叉树的最小深度 - 解法思路
python·程序人生·算法·leetcode·面试·职场和发展·深度优先
HealthScience1 小时前
怎么搜索某个已知的药物的smiles
python
jimmyleeee1 小时前
人工智能基础知识笔记二十八:几款有用的LLM管理工具
人工智能·笔记·python
schinber1 小时前
Python包管理工具全景指南:从pip到现代化工具实战
python·conda·pip·uv