跳转到主要内容

并发设置异步pytest fixtures

项目描述

Pytest-Gather-Fixtures:并行运行async fixtures

文档

pytest-gather-fixtures 是一个pytest库,允许您并行设置和销毁 fixtures。当您有多个耗时较长的独立 fixtures 时,它非常有用。

import asyncio
from pytest_gather_fixtures import ConcurrentFixtureGroup

my_fixture_group = ConcurrentFixtureGroup('my_fixture_group')

@my_fixture_group.fixture
async def my_fixture_1():
    await asyncio.sleep(1)

@my_fixture_group.fixture
async def my_fixture_2():
    await asyncio.sleep(1)

def test_foo(my_fixture_1, my_fixture_2):
    # setup for this test will only take 1 second
    pass

由以下支持