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
相关推荐
平常心cyk11 分钟前
Python基础快速复习——集合和字典
开发语言·数据结构·python
阿钱真强道12 分钟前
34 Python 离群点检测:什么是离群点?为什么要做异常检测?
python·sklearn·异常检测·异常·离群点检测
AC赳赳老秦13 分钟前
OpenClaw关键词挖掘Agent配置(附SOP脚本,可直接复制使用)
java·大数据·开发语言·人工智能·python·pygame·openclaw
qq_4160187215 分钟前
数据分析与科学计算
jvm·数据库·python
深藏功yu名20 分钟前
Day24(进阶篇):向量数据库 Chroma_FAISS 深度攻坚 —— 索引优化、性能调优与生产级落地
数据库·人工智能·python·ai·agent·faiss·chroma
njidf42 分钟前
趣味项目与综合实战
jvm·数据库·python
李昊哲小课1 小时前
PyMySQL完整教程
服务器·数据库·python·pymysql
sqyno1sky1 小时前
Python数据库操作:SQLAlchemy ORM指南
jvm·数据库·python
belldeep1 小时前
python:spaCy 源代码解析,性能优化方法
python·性能优化·cython·spacy
deephub1 小时前
TPU 架构与 Pallas Kernel 编程入门:从内存层次结构到 FlashAttention
人工智能·python·深度学习·tpu