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
相关推荐
invicinble5 小时前
这里对java的知识体系做一个全域的介绍
java·开发语言·python
m0_674294646 小时前
如何编写SQL存储过程性能对比_记录执行时间评估优化效果
jvm·数据库·python
运气好好的6 小时前
怎样开启phpMyAdmin的操作审计日志_记录每条执行的SQL
jvm·数据库·python
2401_871492857 小时前
Layui如何修改Layui默认的UI主题颜色(换肤功能实现)
jvm·数据库·python
南子北游7 小时前
Python学习(基础语法1)
开发语言·python·学习
步辞8 小时前
Redis如何利用LFU算法优化缓存命中率
jvm·数据库·python
forEverPlume8 小时前
golang如何实现日志按级别过滤_golang日志按级别过滤实现教程
jvm·数据库·python
m0_624578599 小时前
MySQL主从复制支持跨版本吗_不同版本间同步的注意事项
jvm·数据库·python
yuanpan9 小时前
Python Pygame 入门教程:从零学会创建窗口、绘图和游戏交互
python·游戏·pygame
2401_8714928510 小时前
如何在 React Router v6 中正确配置多路由组件显示
jvm·数据库·python