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
相关推荐
小陳参上15 小时前
用Python创建一个Discord聊天机器人
jvm·数据库·python
minstbe17 小时前
IC设计私有化AI助手实战:基于Docker+OpenCode+Ollama的数字前端综合增强方案(进阶版)
人工智能·python·语言模型·llama
zyq99101_118 小时前
优化二分查找:前缀和降复杂度
数据结构·python·蓝桥杯
qyzm18 小时前
天梯赛练习(3月13日)
开发语言·数据结构·python·算法·贪心算法
Qt学视觉20 小时前
AI2-Paddle环境搭建
c++·人工智能·python·opencv·paddle
廋到被风吹走20 小时前
【LangChain4j】特点功能及使用场景
后端·python·flask
Eward-an20 小时前
LeetCode 239. 滑动窗口最大值(详细技术解析)
python·算法·leetcode
喵手21 小时前
Python爬虫实战:用代码守护地球,追踪WWF濒危物种保护动态!
爬虫·python·爬虫实战·濒危物种·零基础python爬虫教学·wwf·濒危物种保护动态追踪
梦想的旅途221 小时前
如何通过 QiWe API 实现企业微信主动发消息
开发语言·python
喵手21 小时前
Python爬虫实战:自动化抓取 Pinterest 热门趋势与创意!
爬虫·python·爬虫实战·pinterest·零基础python爬虫教学·采集pinterest热门趋势·热门趋势预测