Skip to content

Commit

Permalink
Only use function scoped fixtures.
Browse files Browse the repository at this point in the history
I don't know why, but there is a particularly annoying edge case when
running the entire test suite, on Python 3.7, on Linux.

As far as I can tell, the server process for the code actions test
case never terminates. The test case works perfectly on all other
Python versions and platforms. It even works fine if you run the test
case on its own! But run the test case along with everything else, on
Linux using Python 3.7 - the server process hangs, hanging the rest of
the test suite with it.

Luckily, the fix appears to be simply not re-using the event loop
across test cases, thankfully we don't have any test cases that
require this yet.
  • Loading branch information
alcarney authored and tombh committed Jun 12, 2023
1 parent f0fab95 commit eb71c85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,21 @@ def client_server(request):
client_server.stop()


@pytest.fixture(scope="session")
@pytest.fixture()
def server_dir():
"""Returns the directory where all the example language servers live"""
path = pathlib.Path(__file__) / ".." / ".." / "examples" / "servers"
return path.resolve()


@pytest.fixture(scope="session")
@pytest.fixture()
def workspace_dir():
"""Returns the directory containing the example workspace."""
path = pathlib.Path(__file__) / ".." / ".." / "examples" / "workspace"
return path.resolve()


@pytest.fixture(scope="session")
@pytest.fixture()
def event_loop():
"""Redefine `pytest-asyncio's default event_loop fixture to match the scope
of our client fixture."""
Expand Down
2 changes: 1 addition & 1 deletion tests/lsp/test_code_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from pygls.lsp.client import LanguageClient


@pytest_asyncio.fixture(scope="module")
@pytest_asyncio.fixture()
async def client(server_dir):
"""Setup and teardown the client."""

Expand Down

0 comments on commit eb71c85

Please sign in to comment.