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
相关推荐
JHC0000003 小时前
基于Ollama,Milvus构建的建议知识检索系统
人工智能·python·milvus
mOok ONSC3 小时前
SpringBoot项目中读取resource目录下的文件(六种方法)
spring boot·python·pycharm
GIS兵墩墩4 小时前
postgis--PostgreSQL16及其plpython3u扩展
python·postgis
new Object ~4 小时前
LangChain的短期记忆存储实现
python·langchain
魔都吴所谓4 小时前
【Python】从零构建:IP地理位置查询实战指南
开发语言·python·tcp/ip
测试19985 小时前
使用Python自动化生成接口测试用例
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·接口测试
智算菩萨5 小时前
【Pygame】第10章 游戏状态管理与场景切换机制
python·游戏·pygame
songcream15 小时前
TensorFlow的一些基本概念
人工智能·python·tensorflow
AI逐月7 小时前
解决 ComfyUI 插件安装后 Nanobind 报错问题:soxr 版本冲突原理解读
开发语言·python