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
相关推荐
我的xiaodoujiao3 分钟前
API 接口自动化测试详细图文教程学习系列20--结合Pytest框架使用
python·学习·测试工具·pytest
python在学ing20 分钟前
前端-CSS学习笔记
前端·css·python·学习
IT策士1 小时前
Django 从 0 到 1 打造完整电商平台:为什么用 Django 做电商?
后端·python·django
zkkkkkkkkkkkkk2 小时前
Linux进行管理工具Supervisor配置与使用
linux·python·supervisor
2301_783848652 小时前
mysql数据库迁移到云平台流程_使用数据传输服务DTS工具
jvm·数据库·python
开发者联盟league2 小时前
linux普通用户使用pip安装模块
linux·python·pip
老纪2 小时前
如何解决OUI图形界面无法调用_xhost与DISPLAY变量设置
jvm·数据库·python
知行合一。。。2 小时前
Python--05--面向对象(继承,多态)
android·开发语言·python
m0_617493943 小时前
PyTorch CUDA设备不可用错误解决方案
人工智能·pytorch·python
小郑加油3 小时前
python学习Day15:综合训练——数据清洗与缺失值补充
开发语言·python·学习