faststream 测试简单说明

faststream 包含了TestBroker可以方便的进行测试,比如与pytest 集成

参考使用

  • app_test.py
import pytest
from faststream.redis import TestRedisBroker,RedisBroker
broker = RedisBroker("redis://localhost:6379",validate=False)
@pytest.mark.asyncio
async def test_correct():
    async with TestRedisBroker(broker,with_real=True) as br:
        await br.publish({
            "name": "John",
            "age": 1,
        }, "test")

说明

对于测试还是比较重要的,我们可以确保功能的稳定性

参考资料

https://faststream.airt.ai/latest/faststream/#testing-the-service

posted on   荣锋亮  阅读(36)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2022-09-16 parca 项目protocol buffers 管理学习
2020-09-16 golang init 文件处理
2019-09-16 关于singer elt 的几篇很不错的文章
2019-09-16 The Ultimate Guide to handling JWTs on frontend clients (GraphQL)
2018-09-16 k8s helm 可视化UI 管理工具 monocular部署试用

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示