我有一个异步函数,它异步计算url列表,并且我想使用parameterize为每个url生成一个异步测试,用于断言状态码。 我想做的事情类似于这样:
import pytest
@pytest.fixture
async def compute_urls():
urls = await compute_urls_helper()
return urls
@pytest.mark.asyncio
@pytest.mark.parameterize('url',await compute_urls())
async def test_url(compute_urls,url):
resp = await get_url(url)
assert resp.status_code == 200
我知道在参数化内部使用'await'是不可能的,因此我希望听到这种操作的建议。