79375797

Date: 2025-01-21 20:08:38
Score: 0.5
Natty:
Report link

You'll have to use pytest-asyncio fixture. The loop scope must be a higher level than the fixture scope (session > module > function)

Documentation: https://pytest-asyncio.readthedocs.io/en/latest/reference/decorators/index.html#decorators-pytest-asyncio-fixture

Define the fixture like this:

@pytest_asyncio.fixture(loop_scope="session", scope="module")
async def tcp_server():
    ...

and when marking the tests as async tests, use the loop_scope="session" too:

pytestmark = pytest.mark.asyncio(loop_scope="session")

or

@pytest.mark.asyncio(loop_scope="session")
async def test_motor_identification_dataFL(tcp_server):
    ...
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Gabriel Salla