Skip to content

fix: pin pytest-asyncio default fixture loop scope (#189) - #234

Merged
Olen merged 1 commit into
mainfrom
fix/pytest-asyncio-fixture-scope
May 14, 2026
Merged

fix: pin pytest-asyncio default fixture loop scope (#189)#234
Olen merged 1 commit into
mainfrom
fix/pytest-asyncio-fixture-scope

Conversation

@Olen

@Olen Olen commented May 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Set asyncio_default_fixture_loop_scope = "function" in a new [tool.pytest.ini_options] block.
  • Addresses Tests: pytest emits deprecation warning #189 by pinning the future default explicitly, which is the recommendation in the issue's last paragraph.

Context

The literal deprecation warning text in #189 no longer fires in pytest-asyncio 1.3.0 (verified locally with pytest -W error::DeprecationWarning — silent). But the underlying behaviour-drift risk is still real: asyncio_default_fixture_loop_scope was unset, and pytest-asyncio's CHANGELOG warns it will default to "function" in a future release. Setting it now means our test setup is immune to that flip whenever it lands.

Verified locally — pytest header now reads:

asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=function, ...

(was =None before this change).

⚠️ Release workflow side-effect on merge

Because this PR touches pyproject.toml, merging will trigger .github/workflows/release.yml (which has paths: pyproject.toml). The tag-exists guard (workflow line 48-54) catches it — version is still 1.2.1, tag v1.2.1 exists, the step exits 1 — so no release will be cut, but the workflow run will show as red on the merge commit. Wanted to flag this rather than have it surprise you.

(Long-term fix: scope paths: to only fire when the version actually changes, e.g. via a if: contains(github.event.head_commit.modified, 'pyproject.toml') && ... check or by gating on a release PR label. Out of scope for this PR.)

Test plan

  • Local pytest — 21 tests pass
  • Local ruff check — clean
  • Local ruff format --check — clean
  • CI: full Python matrix green

Not addressed in this PR

Issue #189 also suggests adopting pytest-github-actions-annotate-failures so warnings surface in the Actions UI. That's a separate, additive change — left for a follow-up if you want it.

🤖 Generated with Claude Code

pytest-asyncio's `asyncio_default_fixture_loop_scope` is currently
unset and will default to "function" in a future release. Setting it
explicitly now pins the behaviour and silences the original
deprecation warning that prompted #189.

(The literal warning text no longer fires in pytest-asyncio 1.3.0,
but the behaviour-drift risk remains until the value is explicit.)
@Olen
Olen requested a review from Copilot May 14, 2026 12:47
@Olen Olen added the updateme Automatically update PR from main label May 14, 2026

Copilot AI 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.

Pull request overview

Pins pytest-asyncio’s default event loop scope for async fixtures to avoid future behavior changes when pytest-asyncio flips its default.

Changes:

  • Add a [tool.pytest.ini_options] block in pyproject.toml.
  • Set asyncio_default_fixture_loop_scope = "function" explicitly to prevent future default drift.

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

@Olen
Olen merged commit 48078ed into main May 14, 2026
12 checks passed
@Olen
Olen deleted the fix/pytest-asyncio-fixture-scope branch May 14, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

updateme Automatically update PR from main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants