swyddfa / lsp-devtools

Tooling for working with language servers and clients.
https://lsp-devtools.readthedocs.io/en/latest/
47 stars 8 forks source link

pytest-asyncio v0.23 support #126

Closed alcarney closed 5 months ago

alcarney commented 6 months ago

This release includes some breaking changes that at the very least will require an update to the documentation.

Something else to investigate is that esbonio's test suite will hang (on my machine at least ...) if a test requests a fixture with a scope and that scope is not also explicitly requested in the test's mark

@pytest_lsp.fixture(
    scope="session",
    config=ClientServerConfig(
        server_command=[sys.executable, *SERVER_CMD],
    ),
)
async def client(lsp_client: LanguageClient, uri_for, tmp_path_factory):
    ...

@pytest.mark.asyncio(scope="session")  # <-- hangs if not set!
async def test_workspace_symbols(client: LanguageClient, ...):
    ...

Interestingly however, the following tests appear to run fine without issue

@pytest_asyncio.fixture(scope="session")
async def slow_start():
    await asyncio.sleep(1)
    yield True

@pytest.mark.asyncio
async def test_one(slow_start):
    await asyncio.sleep(1)
    assert slow_start is True

@pytest.mark.asyncio
async def test_two(slow_start):
    await asyncio.sleep(1)
    assert slow_start is False

Which suggests perhaps pytest-lsp is doing something that doesn't quite agree with pytest-asyncio's new setup.