Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest-lsp: Bump pytest-asyncio to 0.24 #182

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/pytest-lsp/changes/182.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bump minimum `pytest-asyncio` verision to `v0.24`
3 changes: 2 additions & 1 deletion lib/pytest-lsp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies = [
"packaging",
"pygls>=2.0.0a1",
"pytest",
"pytest-asyncio>=0.23",
"pytest-asyncio>=0.24",
]

[project.urls]
Expand All @@ -48,6 +48,7 @@ sort = "Cover"

[tool.pytest.ini_options]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"

[tool.towncrier]
filename = "CHANGES.md"
Expand Down
3 changes: 0 additions & 3 deletions lib/pytest-lsp/pyrightconfig.json

This file was deleted.

5 changes: 5 additions & 0 deletions lib/pytest-lsp/pytest_lsp/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ def fixture(
"""

def wrapper(fn):
# pytest-asyncio says `loop_scope` should be present and match `scope`
# https://pytest-asyncio.readthedocs.io/en/latest/how-to-guides/migrate_from_0_23.html
if "scope" in kwargs:
kwargs["loop_scope"] = kwargs["scope"]

@pytest_asyncio.fixture(**kwargs)
async def the_fixture(request):
devtools = request.config.getoption("devtools")
Expand Down
4 changes: 2 additions & 2 deletions lib/pytest-lsp/tests/examples/fixture-scope/t_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def client(lsp_client: LanguageClient):
await lsp_client.shutdown_session()


@pytest.mark.asyncio(scope="module")
@pytest.mark.asyncio(loop_scope="module")
async def test_completion_hello(client: LanguageClient):
"""Ensure that the server implements completions correctly."""

Expand All @@ -42,7 +42,7 @@ async def test_completion_hello(client: LanguageClient):
assert "hello" in labels


@pytest.mark.asyncio(scope="module")
@pytest.mark.asyncio(loop_scope="module")
async def test_completion_world(client: LanguageClient):
"""Ensure that the server implements completions correctly."""

Expand Down
3 changes: 2 additions & 1 deletion lib/pytest-lsp/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def test_client_capabilities(
"""
[pytest]
asyncio_mode = auto
asyncio_default_fixture_loop_scope = function
"""
)

Expand Down Expand Up @@ -116,7 +117,7 @@ async def test_capabilities(client):
)

results = pytester.runpytest("-vv")
results.assert_outcomes(passed=1)
results.assert_outcomes(passed=1, warnings=0)


@pytest.mark.parametrize(
Expand Down
33 changes: 24 additions & 9 deletions lib/pytest-lsp/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def setup_test(pytester: pytest.Pytester, example_name: str):
"""\
[pytest]
asyncio_mode = auto
asyncio_default_fixture_loop_scope = function
"""
)

Expand All @@ -24,21 +25,35 @@ def setup_test(pytester: pytest.Pytester, example_name: str):
@pytest.mark.parametrize(
"name, expected",
[
pytest.param("diagnostics", dict(passed=1), id="diagnostics"),
pytest.param("getting-started", dict(passed=1), id="getting-started"),
pytest.param("fixture-passthrough", dict(passed=1), id="fixture-passthrough"),
pytest.param("fixture-scope", dict(passed=2), id="fixture-scope"),
pytest.param("diagnostics", dict(passed=1, warnings=0), id="diagnostics"),
pytest.param(
"parameterised-clients", dict(passed=2), id="parameterised-clients"
"getting-started", dict(passed=1, warnings=0), id="getting-started"
),
pytest.param(
"fixture-passthrough", dict(passed=1, warnings=0), id="fixture-passthrough"
),
pytest.param("fixture-scope", dict(passed=2, warnings=0), id="fixture-scope"),
pytest.param(
"parameterised-clients",
dict(passed=2, warnings=0),
id="parameterised-clients",
),
pytest.param(
"window-log-message", dict(passed=1, warnings=0), id="window-log-message"
),
pytest.param("window-log-message", dict(passed=1), id="window-log-message"),
pytest.param(
"window-create-progress",
dict(passed=3),
dict(passed=3, warnings=0),
id="window-create-progress",
),
pytest.param("window-show-document", dict(passed=1), id="window-show-document"),
pytest.param("window-show-message", dict(passed=1), id="window-show-message"),
pytest.param(
"window-show-document",
dict(passed=1, warnings=0),
id="window-show-document",
),
pytest.param(
"window-show-message", dict(passed=1, warnings=0), id="window-show-message"
),
pytest.param(
"workspace-configuration",
dict(passed=1, warnings=1),
Expand Down
1 change: 1 addition & 0 deletions lib/pytest-lsp/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def setup_test(pytester: pytest.Pytester, server_name: str, test_code: str):
"""\
[pytest]
asyncio_mode = auto
asyncio_default_fixture_loop_scope = function
"""
)

Expand Down