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 1 year ago • 0 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