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
相关推荐
惊讶的猫3 小时前
LSTM论文解读
开发语言·python
测试老哥4 小时前
软件测试之单元测试知识总结
自动化测试·软件测试·python·测试工具·职场和发展·单元测试·测试用例
buvsvdp50059ac4 小时前
如何在VSCode中设置Python解释器?
ide·vscode·python
njxiejing5 小时前
Python进度条工具tqdm的安装与使用
开发语言·python
Mr_Dwj6 小时前
【Python】Python 基本概念
开发语言·人工智能·python·大模型·编程语言
2401_841495646 小时前
【自然语言处理】基于规则基句子边界检测算法
人工智能·python·自然语言处理·规则·文本·语言·句子边界检测算法
E_ICEBLUE8 小时前
Python 教程:如何快速在 PDF 中添加水印(文字、图片)
开发语言·python·pdf