Skip to content

Fix CI for pytest 9.2 and rq 3.0 - #869

Merged
quinnmil merged 2 commits into
masterfrom
fix-pytest-asyncio-loop-scope
Oct 29, 2026
Merged

quinnmil merged 2 commits into
masterfrom
fix-pytest-asyncio-loop-scope

Conversation

@quinnmil

@quinnmil quinnmil commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

CI has been failing on master since #866 (and on #868) across every Python test job. Two unpinned test dependencies released new versions between the last green run and now:

1. pytest 9.1.1 → 9.2.0

pytest aborts with INTERNALERROR (exit code 3) before collecting any tests:

pytest.PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.

With pytest 9.2.0, pytest-asyncio's configure-time deprecation warning is turned into an error by our filterwarnings = error in pytest.ini.

2. rq 2.12.0 → 3.0.0

Once tests could run, test_rq.py::test_hello and test_fail failed in every env (assert 1 == 2 on span count). rq < 3.0 called PERSIST on the job key inside Job.perform, so it was captured as a Redis/PERSIST span within Scout's job span. rq 3.0 moved that call into the worker's pipeline. The instrumentation itself is unaffected — the Job span, tags, and error tagging are unchanged; the tests had hard-coded an rq internal.

Fix

  • Set asyncio_default_fixture_loop_scope = function in pytest.ini (the scope pytest-asyncio says will become its default).
  • Only expect the Redis/PERSIST span in the RQ tests on rq < 3.0.

Testing

  • With the repo's pytest.ini and pytest-asyncio 1.4.1, a trivial test crashes on pytest 9.2.0 without the setting and passes with it; still passes on 9.1.1.
  • tests/integration/test_rq.py passes (3/3) against a local Redis on both rq 3.0.0 and rq 2.12.0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NgEia2KuXhw1rAKi99X1ow

pytest 9.2.0 now applies filterwarnings to warnings emitted during
pytest_configure, so pytest-asyncio's PytestDeprecationWarning about the
unset asyncio_default_fixture_loop_scope option is turned into an error
by `filterwarnings = error`. pytest then aborts with INTERNALERROR
before collecting any tests, failing every tox env.

Set the option explicitly to "function", the scope pytest-asyncio says
will become its default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NgEia2KuXhw1rAKi99X1ow

@jrothrock jrothrock left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Confirmed the repo has no async fixtures so function changes no test behavior, and every tox env (py310+) pulls a pytest-asyncio that knows the key — clean fix. 👍

rq 3.0 moved the PERSIST call on the job key out of Job.perform and into
the worker's pipeline, so it no longer happens inside Scout's job span.
The tests hard-coded that rq internal and expected a Redis/PERSIST span
before the Job span, failing on every tox env once rq 3.0.0 was
installed.

Only expect the Redis/PERSIST span on rq < 3.0. The instrumentation
itself is unaffected: the Job span, tags, and error tagging are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NgEia2KuXhw1rAKi99X1ow
@quinnmil quinnmil changed the title Set asyncio_default_fixture_loop_scope to fix CI on pytest 9.2 Fix CI for pytest 9.2 and rq 3.0 Oct 29, 2026
@quinnmil
quinnmil merged commit c28fc21 into master Oct 29, 2026
18 of 19 checks passed
@quinnmil
quinnmil deleted the fix-pytest-asyncio-loop-scope branch October 29, 2026 19:00
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.

2 participants