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
相关推荐
程序员杰哥2 小时前
Python自动化测试之线上流量回放:录制、打标、压测与平台选择
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·压力测试
吴佳浩2 小时前
LangChain v1 重大更新讲解⚠⚠⚠
python·langchain·agent
顾安r4 小时前
11.20 开源APP
服务器·前端·javascript·python·css3
萧鼎5 小时前
Python PyTesseract OCR :从基础到项目实战
开发语言·python·ocr
没有bug.的程序员6 小时前
Java 字节码:看懂 JVM 的“机器语言“
java·jvm·python·spring·微服务
下午见。8 小时前
Python基础入门:用Anaconda搭建环境的启蒙之旅
python
奶茶精Gaaa8 小时前
【ZJ】Pytest框架搭建
pytest
我叫汪枫8 小时前
Python 办公自动化入门:玩转 Excel 与 Word
python·word·excel
E_ICEBLUE9 小时前
三步完成 Markdown 到 Word/PDF 的转换:Python 教程
python·pdf·word·markdown·格式转换
后台开发者Ethan10 小时前
LangGraph ReAct应用
python·langgraph