Skip to content

test(lsp): silence asyncio DeprecationWarning in sync tests#773

Merged
DevonFulcher merged 2 commits into
mainfrom
fix/lsp-test-asyncio-deprecation
May 13, 2026
Merged

test(lsp): silence asyncio DeprecationWarning in sync tests#773
DevonFulcher merged 2 commits into
mainfrom
fix/lsp-test-asyncio-deprecation

Conversation

@DevonFulcher
Copy link
Copy Markdown
Collaborator

Summary

  • Four tests in TestMessageHandling (tests/unit/lsp/test_lsp_connection.py) construct an asyncio.Future() synchronously without a current event loop, which emits DeprecationWarning: There is no current event loop under Python 3.12+.
  • Adds a small _sync_test_event_loop context manager that binds a fresh loop for the duration of each affected test, and switches to loop.create_future().
  • No behavior change; warning is gone and the tests stay future-proof against Python removing implicit loop creation.

Test plan

  • task test:unit — 692 passed
  • task check — lint, ruff, mypy clean
  • Verified the same five TestMessageHandling tests still pass with no warnings

🤖 Generated with AI assistance

Bind a fresh event loop in the four `TestMessageHandling` tests that
build futures synchronously, and use `loop.create_future()` instead of
bare `asyncio.Future()`. Without this, pytest emits a
`DeprecationWarning: There is no current event loop` and the tests
will eventually fail outright on Python versions that drop implicit
loop creation.

Co-Authored-By: AI Assistant <noreply@ai>
Copilot AI review requested due to automatic review settings May 13, 2026 13:56
@DevonFulcher DevonFulcher requested review from a team, b-per, jairus-m and jasnonaz as code owners May 13, 2026 13:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the LSP connection unit tests to avoid asyncio deprecation warnings on Python 3.12+ by ensuring synchronous tests have an explicit event loop when creating futures.

Changes:

  • Added a _sync_test_event_loop() context manager to bind a fresh event loop during specific synchronous tests.
  • Updated affected tests to use loop.create_future() instead of asyncio.Future().
  • Added an “Under the Hood” changelog entry documenting the test-only adjustment.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/unit/lsp/test_lsp_connection.py Introduces a sync test event-loop context manager and updates tests to create futures from the bound loop.
.changes/unreleased/Under the Hood-20260513-085513.yaml Changelog entry describing the warning-suppression change in unit tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/unit/lsp/test_lsp_connection.py
@DevonFulcher DevonFulcher enabled auto-merge (squash) May 13, 2026 14:14
Copy link
Copy Markdown
Collaborator

@jairus-m jairus-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran tests locally - no deprecations!

@DevonFulcher DevonFulcher merged commit 2dcd754 into main May 13, 2026
4 checks passed
@DevonFulcher DevonFulcher deleted the fix/lsp-test-asyncio-deprecation branch May 13, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants