-
Notifications
You must be signed in to change notification settings - Fork 289
Open
Labels
bugSomething isn't workingSomething isn't working
Description
This happens with FastStream 0.6.*. I have a few remarks, that might helpfully narrow down the scope
- This requires one to use a RabbitRouter. Declaring the subscriber directly on the RabbitBroker leads to unbroken behavior
- This requires one to use Context(). Depends works fine
import pytest
from faststream import Context
from faststream.rabbit import TestRabbitBroker
from faststream.rabbit import RabbitBroker, RabbitRouter
router = RabbitRouter()
@router.subscriber("in-queue")
async def handle_msg(broker=Context()) -> str:
return "test"
@pytest.fixture
async def test_broker():
broker = RabbitBroker()
broker.include_router(router)
async with TestRabbitBroker(broker) as br:
yield br
async def test_correct(test_broker) -> None:
await test_broker.publish(
{},
"in-queue",
)
async def test_again(test_broker) -> None:
await test_broker.publish(
{},
"in-queue",
)
The error message is:
future: <Future finished exception=1 validation error for handle_msg
broker
Field required [type=missing, input_value={'context__': <faststream...ject at 0x7dadbcb9ead0>}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing>
Traceback (most recent call last):
To reproduce save as file, and run with pytest. My pyproject.toml
for this is
[project]
name = "faststream-ex-1"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"faststream[rabbit]>=0.6.0",
"pytest>=8.4.2",
"pytest-asyncio>=1.2.0",
"pytest-watcher>=0.4.3",
]
[tool.pytest.ini_options]
asyncio_mode = "auto"
Lancetnik
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working