quart icon indicating copy to clipboard operation
quart copied to clipboard

ContextVars are not propagated from fixtures with pytest-asyncio

Open pgjones opened this issue 3 years ago • 2 comments

This is more of a pytest-asyncio bug, see https://github.com/pytest-dev/pytest-asyncio/issues/127

@pytest.fixture(scope='class')
async def test_context(self):
    async with app.app_context():
        async with app.test_request_context("/"):
            setattr(quart.g, 'test', 'value')
            yield

@pytest.mark.asyncio
async def test_global(test_context):
    assert quart.g.test == 'value'

pgjones avatar Jul 07 '22 10:07 pgjones

https://github.com/pallets/quart/issues/415

khteh avatar Feb 23 '25 03:02 khteh

The referenced pytest-asyncio issue has been resolved as of v1.1.0.

Can you try upgrading pytest-asyncio and report back if this resolves your issue? I see you're already on v1.0.0, so the upgrade should be painless.

seifertm avatar Sep 17 '25 19:09 seifertm