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
相关推荐
AIFQuant18 分钟前
Python实时外汇行情接入实战:WebSocket与REST K线查询
开发语言·python·websocket
babe小鑫41 分钟前
生物统计学专业校招:SAS、R、Python学习顺序实用指南
python·学习·r语言
vx_Biye_Design43 分钟前
springboot游泳馆系统93765-计算机课程设计、毕业设计
java·javascript·spring boot·后端·python·spring·课程设计
固定资产管理系统软件1 小时前
该去哪里找专业靠谱的智慧智能设备固定资产管理系统?
人工智能·python
ctlover1 小时前
LangChain 概述
python·langchain
专业程序开发源1 小时前
springbootLivehouse票务系统-计算机课程设计、毕业设计
vue.js·spring boot·后端·python·django·课程设计·pygame
李高钢1 小时前
Python Django 框架入门:从零搭建你的第一个 Web 应用
前端·python·django
2601_966949651 小时前
从轮询到策略消费:量化系统如何高效处理五档盘口数据
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
萧鼎2 小时前
2026实战:用 accelerate 库加速 PyTorch 训练,核心语法与避坑指南
python·开源·教程·python库·accelerate
我命由我123452 小时前
人脸识别 - 去重时间窗口
java·开发语言·python·学习·java-ee·学习方法·python3.11