Is there any way to run pytest testcase in async mode?

Viewed 155

As time goes on, testcase groups very fast, but pytest run cases one by one, it will take a very long time to finished all of them, so I really want to run cases with async mode, I also tried pytest-xdist, but it needs a better machine hardware support, is there any ways to run all testcase in a async mode to speed up test duration? I have tried @pytest.mark.asyncio but it didn't any help.

test_tmp.py

import logging
import pytest
import asyncio
import time


@pytest.mark.asyncio
async def test_async_01():
    logging.info(f"time => {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))}")
    await asyncio.sleep(5)


@pytest.mark.asyncio
async def test_async_02():
    logging.info(f"time => {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))}")
    await asyncio.sleep(5)

enter image description here

0 Answers
Related