Closed bradydean closed 1 year ago
I suspect #441 is responsible for this. I'll take a look. I may yank v0.10.4.
@bradydean is this isolated to Python 3.11 or all versions of Python for yo6r tests?
It failed on 3.10 and 3.11, those are the only 2 versions I run on.
This part is responsible for your woes. I'm surprised it didn't break our test cases but it broke yours. Could you provide any sample code?
Here's a minimal example that fails for me
topic = app.topic(
"topic", value_serializer="json"
)
@app.agent(topic)
async def testme(stream):
async for event in stream:
yield
@pytest.mark.asyncio
async def test_agent():
async with testme.test_context() as agent:
await agent.put({"foo": "bar"})
https://faust-streaming.github.io/faust/userguide/testing.html#testing-that-an-agent-sends-to-topic-calls-another-agent may be useful to you. I'll still try to look into this though.
Do you use test_app fixture, as provided in documentation? We are using something like this:
@pytest.fixture
def test_app(event_loop):
from app import app
app.loop = event_loop # <-- Here set event loop for app
app.finalize()
app.conf.store = "memory://"
app.flow_control.resume()
try:
yield app
finally:
assert app.tracer is None
Add that and tests passed, thanks!
Thanks for the tips @Roman1us !
If you use a fixture in a conftest.py
file do not forget to add scope=function
:
import pytest
@pytest.fixture(scope="function")
def test_stateless_app(event_loop):
from app import app
app.loop = event_loop
app.finalize()
app.conf.table_cleanup_interval = 1.0
app.flow_control.resume()
return app
Should we update the doc with the line app.loop = event_loop
and also specify that the app's import must be in the fixture?
Closed in #467.
Checklist
master
branch of Faust.Steps to reproduce
Upgrade to 0.10.4
Expected behavior
Event loop is not closed
Actual behavior
Bumping to 0.10.4 breaks tests cases in our CI pipeline. This traceback is from after entering an agent test context.
Full traceback
Versions