Skip to content

chore(test): pin asyncio_default_fixture_loop_scope to function#51

Closed
mikemolinet wants to merge 6 commits into
mainfrom
chore/pytest-asyncio-default-loop-scope
Closed

chore(test): pin asyncio_default_fixture_loop_scope to function#51
mikemolinet wants to merge 6 commits into
mainfrom
chore/pytest-asyncio-default-loop-scope

Conversation

@mikemolinet
Copy link
Copy Markdown
Collaborator

Summary

Per cue-pm-pr-watcher PMW-NUDGE 2026-05-06: 11 Dependabot PRs were stuck on a separate token-secret bug (now fixed via Item 5 fan). Of the 2 with REAL test failures distinct from the secret bug:

Root cause

pytest-asyncio 1.x changed the default fixture loop scope. With the scope unset (current state), pytest-asyncio 1.x emits a deprecation warning AND session-scoped fixtures bind to a different event loop than the per-test functions. The first test in the session works; everything after errors.

Fix

Pin asyncio_default_fixture_loop_scope = function explicitly in pytest.ini. Keeps pytest-asyncio 0.24.x and 1.x behaviorally identical so the bump can land cleanly.

Cascade

Once this merges:

  1. chore(deps): bump pytest-asyncio from 0.24.0 to 1.3.0 #40 (pytest-asyncio 1.3.0) sentinel-rebases against main → CI passes → auto-merges.
  2. chore(deps): bump pytest from 8.3.0 to 9.0.3 #38 (pytest 9.0.3) sentinel-rebases → pytest-asyncio is now 1.3.0 (which supports pytest>=8.2 including 9.x) → CI passes → auto-merges.

Test plan

🤖 Generated with Claude Code

pytest-asyncio 1.x changed the default fixture loop scope. With the
scope unset (current state), pytest-asyncio 1.x emits a deprecation
warning AND session-scoped fixtures bind to a different event loop
than the per-test functions, which produces:

* asyncpg.exceptions._base.InterfaceError: cannot perform operation:
  another operation is in progress
* RuntimeError: ... got Future ... attached to a different loop

Empirically reproduced on Dependabot PR #40 (pytest-asyncio 0.24.0 →
1.3.0): every test except the first one in the session ERRORs.

Pinning the scope explicitly to ``function`` keeps pytest-asyncio
0.24.x and 1.x behaviorally identical and unblocks the bump.

Per CC-cue-pm-pr-watcher PMW-NUDGE 2026-05-06: 11 Dependabot PRs
were stuck on a separate token-secret bug (now fixed via Item 5 fan).
This pytest-asyncio change was the only remaining real (non-plumbing)
failure that blocks #40 from auto-merging once sentinel-rebase pulls
this fix in.

#38 (pytest 8.3.0 → 9.0.3) is dep-chained behind #40: pytest-asyncio
0.24.0 caps pytest<9, so pytest 9.0.3 can only land after #40
merges and pytest-asyncio bumps to 1.3.0 (which supports pytest>=8.2
including 9.x). This PR doesn't touch #38; it cascades naturally
once #40 lands.
@mikemolinet
Copy link
Copy Markdown
Collaborator Author

Closing as stale — branch diverged from main by ~8871 deletions across 57 files. Rebase infeasible.

Pin still needed: the asyncio_default_fixture_loop_scope deprecation warning still fires on every test run (verified in this session). cueapi-core uses pytest.ini (not pyproject.toml). One-line addition to pytest.ini will silence it.

Next step: trivial fresh PR — single line addition to pytest.ini. Will pick up alongside the other re-ports.

Branch retained for reference.

auto-merge was automatically disabled May 11, 2026 15:33

Pull request was closed

mikemolinet added a commit that referenced this pull request May 11, 2026
Silences the deprecation warning that pytest-asyncio emits on every
test run:

  PytestDeprecationWarning: The configuration option
  "asyncio_default_fixture_loop_scope" is unset. The event loop scope
  for asynchronous fixtures will default to the fixture caching
  scope. Future versions of pytest-asyncio will default the loop
  scope for asynchronous fixtures to function scope.

Pin the default to ``function`` explicitly. Matches the future
pytest-asyncio default and silences the warning.

Re-port of closed PR #51 (was on stale base ~8870 deletions behind
current main). Same one-line fix; fresh against `f9ec4ea`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant