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
相关推荐
风吹夏回5 小时前
Python 全局异常处理:从“满屏 try-except”到优雅兜底
开发语言·python
小熊Coding5 小时前
Python爬取当当网二手图书项目实战!
开发语言·爬虫·python·beautifulsoup·requests·二手图书
秋95 小时前
Java项目运行5天左右自动宕机:系统性定位与解决方案
java·开发语言·python
小江的记录本5 小时前
【JVM虚拟机】垃圾回收GC:垃圾收集器:CMS:核心原理、回收流程、优缺点、废弃原因(附《思维导图》+《面试高频考点清单》)
java·jvm·后端·python·spring·面试·maven
田里的水稻6 小时前
OE_ubuntu26.04与宿主机之间复制粘贴内容
人工智能·python·机器人
jiayong237 小时前
02 创建虚拟环境
python
旺仔来了7 小时前
不联网的Linux下部署python环境
linux·开发语言·python
小江的记录本7 小时前
【JVM虚拟机】垃圾回收GC:垃圾回收算法:标记-清除、标记-复制、标记-整理、分代收集(附《思维导图》+《面试高频考点清单》)
java·jvm·后端·python·算法·安全·面试
IP搭子来一个7 小时前
爬虫采集大量返回 403、429,到底卡在哪一环?
网络·爬虫·python
deepin_sir7 小时前
06 综合对比与实战选型——到底该用哪个?
python