Skip to content

Stop pytest 9.2 from failing at plugin load on solara's websockets warning - #4012

Merged
quaquel merged 1 commit into
mesa:mainfrom
lahari936:fix-ci-werror-solara-websockets
Oct 28, 2026
Merged

quaquel merged 1 commit into
mesa:mainfrom
lahari936:fix-ci-werror-solara-websockets

Conversation

@lahari936

Copy link
Copy Markdown
Contributor

Every CI job that runs pytest with -Werror currently dies before collecting a single test:

Error while loading plugin "pytest11".
  solara/test/pytest_plugin.py:29: from solara.server.starlette import ServerStarlette
  solara/server/starlette.py:27:  import websockets.legacy.http
E DeprecationWarning: websockets.legacy is deprecated

Cause

pytest 9.2.0 shipped pytest-dev/pytest#12697 — warnings raised while importing plugins via entry-point autoloading "are now captured, filtered, and reported like other warnings."

Solara registers a pytest plugin by entry point. That plugin imports websockets.legacy, whose __init__ has emitted a DeprecationWarning since websockets 14.0. Previously that warning escaped the filter pipeline and was harmless; as of pytest 9.2.0 it goes through the filters, where -Werror promotes it to an error and pytest exits 3 with zero tests run.

Nothing in mesa changed. Two pieces of evidence:

  • build (ubuntu, 3.14) was green on main at 2026-10-27 10:15 and has failed on every run since.
  • coverage is the only job still passing, and the only one that does not pass -Werror — it runs python -Im pytest -p pytest_cov --cov ... tests/.

Fix

A message-scoped ignore on the two commands that pass -Werror, in the same style as the -Wdefault::PendingDeprecationWarning carve-out already on both:

-W "ignore:websockets.legacy is deprecated:DeprecationWarning"

Verified

Against the exact versions CI installs (pytest 9.2.0, solara 1.64.1, websockets 17.3), in a clean venv:

result
-Werror -Wdefault::PendingDeprecationWarning exit 3 at plugin load, 0 tests collected
plus the ignore 1 passed — collection and run proceed
an unrelated DeprecationWarning raised inside a test, with the ignore on still 1 failed

That last row is the one that matters: the ignore is scoped to this warning's message, so -Werror keeps its value for everything else.

Alternative that does not work

Putting it in pyproject.toml instead:

[tool.pytest.ini_options]
filterwarnings = ["ignore:websockets.legacy is deprecated:DeprecationWarning"]

A command-line -W takes precedence over the ini option, so the -Werror already on these commands overrides it and the run still exits 3. Tested, not assumed.

Scope

CI only; no library code touched. Pinning pytest<9.2 would also turn CI green, but it freezes the toolchain to hide a warning that solara will have to address upstream either way.

…rning

Every CI job that runs pytest with `-Werror` now dies before collecting a
single test:

    Error while loading plugin "pytest11".
      solara/test/pytest_plugin.py:29: from solara.server.starlette import ServerStarlette
      solara/server/starlette.py:27:  import websockets.legacy.http
    E DeprecationWarning: websockets.legacy is deprecated

pytest 9.2.0 shipped pytest-dev/pytest#12697, which makes warnings raised
while importing entry-point plugins go through the normal filter pipeline.
Solara registers a pytest plugin by entry point, that plugin imports
`websockets.legacy`, and `websockets.legacy.__init__` has emitted a
`DeprecationWarning` since websockets 14.0. Under `-Werror` it is now
promoted to an error, so pytest exits 3 with zero tests run.

Nothing in mesa changed. `build (ubuntu, 3.14)` was green on `main` at
2026-10-27 10:15 and has failed on every run since, and the `coverage` job
is the only one still passing because it is the only one that does not pass
`-Werror`.

Add a message-scoped ignore for that one warning, in the same style as the
`-Wdefault::PendingDeprecationWarning` carve-out already on both commands.

Verified against the versions CI installs (pytest 9.2.0, solara 1.64.1,
websockets 17.3):

- `-Werror` alone: exit 3 at plugin load
- with the ignore: collection and the run proceed normally
- an unrelated `DeprecationWarning` raised in a test still fails, so
  `-Werror` keeps its value

A `filterwarnings` entry in `pyproject.toml` does not work here: a
command-line `-W` takes precedence over the ini option, so the `-Werror`
on these commands overrides it and the run still exits 3. Tested.

Co-Authored-By: Claude Opus 5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 28, 2026 02:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions github-actions Bot added the ci Release notes label label Oct 28, 2026
@quaquel

quaquel commented Oct 28, 2026

Copy link
Copy Markdown
Member

thanks for the quick fix!

@quaquel
quaquel merged commit 811d330 into mesa:main Oct 28, 2026
14 of 16 checks passed
EwoutH pushed a commit that referenced this pull request Oct 28, 2026
…rning (#4012)

Every CI job that runs pytest with `-Werror` now dies before collecting a
single test:

    Error while loading plugin "pytest11".
      solara/test/pytest_plugin.py:29: from solara.server.starlette import ServerStarlette
      solara/server/starlette.py:27:  import websockets.legacy.http
    E DeprecationWarning: websockets.legacy is deprecated

pytest 9.2.0 shipped pytest-dev/pytest#12697, which makes warnings raised
while importing entry-point plugins go through the normal filter pipeline.
Solara registers a pytest plugin by entry point, that plugin imports
`websockets.legacy`, and `websockets.legacy.__init__` has emitted a
`DeprecationWarning` since websockets 14.0. Under `-Werror` it is now
promoted to an error, so pytest exits 3 with zero tests run.

Nothing in mesa changed. `build (ubuntu, 3.14)` was green on `main` at
2026-10-27 10:15 and has failed on every run since, and the `coverage` job
is the only one still passing because it is the only one that does not pass
`-Werror`.

Add a message-scoped ignore for that one warning, in the same style as the
`-Wdefault::PendingDeprecationWarning` carve-out already on both commands.

Verified against the versions CI installs (pytest 9.2.0, solara 1.64.1,
websockets 17.3):

- `-Werror` alone: exit 3 at plugin load
- with the ignore: collection and the run proceed normally
- an unrelated `DeprecationWarning` raised in a test still fails, so
  `-Werror` keeps its value

A `filterwarnings` entry in `pyproject.toml` does not work here: a
command-line `-W` takes precedence over the ini option, so the `-Werror`
on these commands overrides it and the run still exits 3. Tested.

Co-authored-by: Claude Opus 5 <[email protected]>
(cherry picked from commit 811d330)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants