From eb71c85c1c704576f927ab2c927e6c3387f4f803 Mon Sep 17 00:00:00 2001 From: Alex Carney Date: Mon, 12 Jun 2023 20:19:47 +0100 Subject: [PATCH] Only use function scoped fixtures. 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. --- tests/conftest.py | 6 +++--- tests/lsp/test_code_action.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index b5d7d6e9..3f0ce78a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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.""" diff --git a/tests/lsp/test_code_action.py b/tests/lsp/test_code_action.py index 641f75d4..a9057dbb 100644 --- a/tests/lsp/test_code_action.py +++ b/tests/lsp/test_code_action.py @@ -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."""