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
相关推荐
Dust-Chasing1 分钟前
Claude Code源码剖析 - ShellTool与真实动作
人工智能·python·ai
仙俊红10 分钟前
Java JUC:CompletableFuture 详解,多个任务并行执行并等待全部完成
java·python·spring
学习3人组13 分钟前
Python 评论朴素贝叶斯文本情感分析示例
人工智能·python·机器学习
用户3379225456817 分钟前
A2A Python SDK 源码架构解读:一个请求是如何被处理的
python
2401_8856651917 分钟前
从零搭建卷积神经网络:基于PyTorch实现MNIST手写数字分类
pytorch·python·神经网络·算法·机器学习·分类·cnn
SilentSamsara21 分钟前
MLflow 实验追踪与模型注册:从实验到生产的可复现工作流
开发语言·人工智能·pytorch·python·青少年编程
曲幽22 分钟前
写爬虫时用了代理还被封?Python 代理的那些隐藏坑,我替你踩明白了
python·http·https·proxy·socks·requests·socks5·proxies
装不满的克莱因瓶23 分钟前
掌握多头自注意力机制(Multi-Head Self-Attention)——Transformer 强大表达能力的核心来源
人工智能·python·深度学习·数学·ai·transformer
下班走回家29 分钟前
RAG 技术的进化:从朴素检索到 Agentic RAG
开发语言·人工智能·python
用什么都重名37 分钟前
Python文本匹配利器:FlashText与RapidFuzz深度对比
python·flash text·rapidfuzz