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
相关推荐
APIshop2 分钟前
用“爬虫”思路做淘宝 API 接口测试:从申请 Key 到 Python 自动化脚本
爬虫·python·自动化
子午6 分钟前
【农作物谷物识别系统】Python+TensorFlow+Django+人工智能+深度学习+卷积神经网络算法
人工智能·python·深度学习
红蒲公英9 分钟前
( 教学 )Agent 构建 Prompt(提示词)3. StructuredOutputParser (结构化输出)
人工智能·python·prompt
谷粒.9 分钟前
API测试全解析:从基础到性能压测
java·运维·网络·人工智能·python·测试工具·自动化
月亮!10 分钟前
敏捷开发中测试左移的5个关键实践
java·人工智能·python·selenium·测试工具·测试用例·敏捷流程
___波子 Pro Max.11 分钟前
VS Code配置python.analysis.extraPaths作用
python
专业开发者13 分钟前
MTK GNSS 可见性控制指南
开发语言·python·物联网
码界奇点13 分钟前
基于Django与Ansible的智能运维管理系统设计与实现
运维·python·django·毕业设计·ansible·源代码管理
卿雪17 分钟前
MySQL【索引】:索引的概念与分类
java·数据库·python·mysql·adb·golang
艾莉丝努力练剑24 分钟前
【Python基础:语法第三课】Python 函数详解:定义、参数、返回值与作用域
服务器·人工智能·windows·python·pycharm