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):
...