Skip to content

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Nov 2, 2025

This PR contains the following updates:

Package Change Age Confidence
pytest-asyncio (changelog) >=0.21.0,<1.0.0 -> >=1.2.0,<1.3.0 age confidence

Release Notes

pytest-dev/pytest-asyncio (pytest-asyncio)

v1.2.0: pytest-asyncio 1.2.0

Compare Source

1.2.0 - 2025-09-12

Added

  • --asyncio-debug CLI option and asyncio_debug configuration option to enable asyncio debug mode for the default event loop. (#​980)
  • A pytest.UsageError for invalid configuration values of asyncio_default_fixture_loop_scope and asyncio_default_test_loop_scope. (#​1189)
  • Compatibility with the Pyright type checker (#​731)

Fixed

  • RuntimeError: There is no current event loop in thread 'MainThread' when any test unsets the event loop (such as when using asyncio.run and asyncio.Runner). (#​1177)
  • Deprecation warning when decorating an asynchronous fixture with @pytest.fixture in [strict]{.title-ref} mode. The warning message now refers to the correct package. (#​1198)

Notes for Downstream Packagers

  • Bump the minimum required version of tox to v4.28. This change is only relevant if you use the tox.ini file provided by pytest-asyncio to run tests.
  • Extend dependency on typing-extensions>=4.12 from Python<3.10 to Python<3.13.

v1.1.1: pytest-asyncio 1.1.1

Compare Source

v1.1.1 - 2025-09-12

Notes for Downstream Packagers

- Addresses a build problem with setuptoos-scm >= 9 caused by invalid setuptools-scm configuration in pytest-asyncio. (#​1192)

v1.1.0: pytest-asyncio 1.1.0

Compare Source

Added

  • Propagation of ContextVars from async fixtures to other fixtures and tests on Python 3.10 and older (#​127)
  • Cancellation of tasks when the loop_scope ends (#​200)
  • Warning when the current event loop is closed by a test

Fixed

  • Error about missing loop when calling functions requiring a loop in the finally clause of a task (#​878)
  • An error that could cause duplicate warnings to be issued

Notes for Downstream Packagers

v1.0.0: pytest-asyncio 1.0.0

Compare Source

1.0.0 - 2025-05-26

Removed

  • The deprecated event_loop fixture.
    (#​1106)

Added

  • Prelimiary support for Python 3.14
    (#​1025)

Changed

  • Scoped event loops (e.g. module-scoped loops) are created once rather
    than per scope (e.g. per module). This reduces the number of fixtures
    and speeds up collection time, especially for large test suites.
    (#​1107)
  • The loop_scope argument to pytest.mark.asyncio no longer forces
    that a pytest Collector exists at the level of the specified scope.
    For example, a test function marked with
    pytest.mark.asyncio(loop_scope="class") no longer requires a class
    surrounding the test. This is consistent with the behavior of the
    scope argument to pytest_asyncio.fixture.
    (#​1112)

Fixed

  • An error caused when using pytest's [--setup-plan]{.title-ref}
    option.
    (#​630)
  • Unsuppressed import errors with pytest option
    --doctest-ignore-import-errors
    (#​797)
  • A "fixture not found" error in connection with package-scoped loops
    (#​1052)

Notes for Downstream Packagers

  • Removed a test that had an ordering dependency on other tests.
    (#​1114)

v0.26.0: pytest-asyncio 0.26.0

Compare Source

  • Adds configuration option that sets default event loop scope for all tests #​793
  • Improved type annotations for pytest_asyncio.fixture #​1045
  • Added typing-extensions as additional dependency for Python <3.10 #​1045

v0.25.3: pytest-asyncio 0.25.3

Compare Source

  • Avoid errors in cleanup of async generators when event loop is already closed #​1040

v0.25.2: pytest-asyncio 0.25.2

Compare Source

  • Call loop.shutdown_asyncgens() before closing the event loop to ensure async generators are closed in the same manner as asyncio.run does #​1034

v0.25.1: pytest-asyncio 0.25.1

Compare Source

  • Fixes an issue that caused a broken event loop when a function-scoped test was executed in between two tests with wider loop scope #​950
  • Improves test collection speed in auto mode #​1020
  • Corrects the warning that is emitted upon redefining the event_loop fixture

v0.25.0: pytest-asyncio 0.25.0

Compare Source

0.25.0 (2024-12-13)

  • Deprecated: Added warning when asyncio test requests async @pytest.fixture in strict mode. This will become an error in a future version of flake8-asyncio. #​979
  • Updates the error message about pytest.mark.asyncio's scope keyword argument to say loop_scope instead. #​1004
  • Verbose log displays correct parameter name: asyncio_default_fixture_loop_scope #​990
  • Propagates contextvars set in async fixtures to other fixtures and tests on Python 3.11 and above. #​1008

v0.24.0: pytest-asyncio 0.24.0

Compare Source

0.24.0 (2024-08-22)

  • BREAKING: Updated minimum supported pytest version to v8.2.0
  • Adds an optional loop_scope keyword argument to pytest.mark.asyncio. This argument controls which event loop is used to run the marked async test. #​706, #​871
  • Deprecates the optional scope keyword argument to pytest.mark.asyncio for API consistency with pytest_asyncio.fixture. Users are encouraged to use the loop_scope keyword argument, which does exactly the same.
  • Raises an error when passing scope or loop_scope as a positional argument to @pytest.mark.asyncio. #​812
  • Fixes a bug that caused module-scoped async fixtures to fail when reused in other modules #​862 #​668

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@coderabbitai
Copy link

coderabbitai bot commented Nov 2, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Nov 2, 2025

Pull Request Review: pytest-asyncio v0.x to v1.x Upgrade

Overview

This PR updates pytest-asyncio from >=0.21.0,<1.0.0 to >=1.2.0,<1.3.0, a major version upgrade with breaking changes.

Critical Issue: Breaking Change Detected

The event_loop fixture has been removed in pytest-asyncio v1.0.0

Your codebase defines a custom event_loop fixture in tests/conftest.py lines 14-19. This will cause issues because:

  1. pytest-asyncio v1.0+ removed the deprecated event_loop fixture
  2. Defining your own event_loop fixture conflicts with pytest-asyncio internal loop management
  3. pytest-asyncio v1.0+ uses loop_scope instead

Required Changes

Option 1 (Recommended): Remove the custom event_loop fixture - delete lines 14-19 in tests/conftest.py

Option 2: Use loop_scope configuration in pyproject.toml

Positive Aspects

  • Good dependency hygiene
  • Well-tested in CI
  • Python 3.11+ fully supported

New Features in v1.x

  1. loop_scope parameter for pytest.mark.asyncio
  2. Better context variable propagation
  3. Task cancellation when loop_scope ends
  4. --asyncio-debug CLI option
  5. Improved performance for large test suites

Testing Recommendations

  1. Remove custom event_loop fixture from tests/conftest.py
  2. Run full test suite locally
  3. Check for warnings
  4. Wait for CI to pass

Security and Performance

  • No security concerns
  • Performance improvement expected
  • No breaking changes to test logic

Recommendation

DO NOT MERGE YET - Requires code changes to tests/conftest.py

Action Items:

  1. Remove custom event_loop fixture (lines 14-19)
  2. Test locally
  3. Review warnings
  4. Merge after tests pass

@renovate renovate bot force-pushed the renovate/pytest-asyncio-1.x branch from b46e35b to c84f7c4 Compare November 3, 2025 00:42
@claude
Copy link

claude bot commented Nov 3, 2025

Pull Request Review: Update pytest-asyncio to v1.2.0

Summary

This PR updates pytest-asyncio from version <1.0.0 to >=1.2.0,<1.3.0, a major version upgrade that includes breaking changes and new features.

Breaking Changes & Issues

1. CRITICAL: Deprecated event_loop fixture is being used

Recommended Fix: Remove the custom event_loop fixture from tests/conftest.py (lines 14-19). pytest-asyncio v1.x manages event loops automatically.

2. Async fixtures

Good news: I didn't find any async fixtures in your test suite, so you're safe from deprecation warnings.

Required Actions Before Merge

MUST DO:

  1. Remove the custom event_loop fixture from tests/conftest.py (lines 14-19)
  2. Run full test suite to verify compatibility: make test
  3. Check for test failures related to event loop issues

SHOULD DO:

  1. Consider adding asyncio_default_fixture_loop_scope to pytest configuration if needed
  2. Review the v1.0.0 migration guide

Benefits of This Upgrade

  1. Improved ContextVars propagation - Context variables now properly propagate from async fixtures to tests
  2. Task cancellation - Tasks are properly cancelled when loop scope ends
  3. Better error messages - More helpful warnings and errors for misconfiguration
  4. Performance improvements - Scoped event loops are created once per scope
  5. Bug fixes - Multiple fixes for event loop management and cleanup

Security Considerations

  • No security concerns with this dependency update
  • The update is from a trusted, well-maintained project (pytest-dev)

Test Coverage Impact

  • High risk of test failures without the required fix above
  • All async tests use @pytest.mark.asyncio correctly
  • No test coverage gaps introduced by this change

Code Quality & Best Practices

  • Version constraint is appropriate: >=1.2.0,<1.3.0 (allows patch updates)
  • Renovate bot made this change - automated updates are good, but major version bumps need careful review

Recommendation

DO NOT MERGE until addressing the critical issue:

  1. Remove the custom event_loop fixture from tests/conftest.py
  2. Run the full test suite and ensure all tests pass
  3. Consider adding asyncio_default_fixture_loop_scope = session to pytest configuration if needed

Once the fixture is removed and tests pass, this upgrade is highly recommended for the improvements and bug fixes it provides.

Review performed by Claude Code following CLAUDE.md guidelines.

@renovate renovate bot force-pushed the renovate/pytest-asyncio-1.x branch from c84f7c4 to 46473dc Compare November 4, 2025 10:26
@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 27.48%. Comparing base (4f408bf) to head (46473dc).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop      #42   +/-   ##
========================================
  Coverage    27.48%   27.48%           
========================================
  Files           31       31           
  Lines         2965     2965           
========================================
  Hits           815      815           
  Misses        2150     2150           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@claude
Copy link

claude bot commented Nov 4, 2025

Pull Request Review: pytest-asyncio v1.2.0 Upgrade

Summary

This PR upgrades pytest-asyncio from >=0.21.0,<1.0.0 to >=1.2.0,<1.3.0, a major version bump that includes several breaking changes and important improvements.

Code Quality & Best Practices ⚠️

Critical Issue: Deprecated event_loop Fixture

Location: tests/conftest.py:14-19

The codebase currently uses a custom event_loop fixture with session scope:

@pytest.fixture(scope="session")
def event_loop() -> Generator[asyncio.AbstractEventLoop, None, None]:
    """Create an instance of the default event loop for the test session."""
    loop = asyncio.get_event_loop_policy().new_event_loop()
    yield loop
    loop.close()

Problem: The event_loop fixture was removed in pytest-asyncio v1.0.0 (see changelog). This fixture is now deprecated and should not be overridden.

Impact: Tests may fail or behave unexpectedly with the new version.

Recommendation: Remove the custom event_loop fixture from tests/conftest.py. pytest-asyncio v1.x manages event loops automatically using the new loop_scope system.

Breaking Changes in pytest-asyncio v1.x

1. Event Loop Management (v1.0.0)

  • Removed: The deprecated event_loop fixture
  • Changed: Scoped event loops are created once per scope (improves performance)
  • Added: New loop_scope argument for @pytest.mark.asyncio decorator

2. Fixture Compatibility (v1.2.0)

  • Fixed: RuntimeError: There is no current event loop when tests use asyncio.run() or asyncio.Runner
  • Added: Better type annotations and Pyright compatibility

3. Configuration Options

The new version adds configuration options you may want to consider:

  • asyncio_default_fixture_loop_scope - Sets default loop scope for fixtures
  • asyncio_default_test_loop_scope - Sets default loop scope for tests
  • --asyncio-debug - Enables asyncio debug mode

Potential Issues

1. Test Configuration Missing

Your pyproject.toml doesn't specify asyncio_mode. Consider adding:

[tool.pytest.ini_options]
asyncio_mode = "auto"  # or "strict"

Recommendation: Use "auto" mode for automatic async test detection, or "strict" if you want explicit marking.

2. Dependencies Added

The new version adds a runtime dependency on typing-extensions for Python < 3.13, which is correctly included in the lock file.

Performance Considerations ✅

Positive Impact: The new version creates scoped event loops once per scope instead of multiple times, which should improve test collection time, especially beneficial for your large test suite.

Security Concerns ✅

No security concerns identified. This is a routine dependency upgrade from a trusted source (pytest-dev).

Test Coverage Recommendations

Required Actions:

  1. Remove custom event_loop fixture from tests/conftest.py:14-19
  2. Add asyncio configuration to pyproject.toml:
    [tool.pytest.ini_options]
    asyncio_mode = "auto"
    asyncio_default_fixture_loop_scope = "function"  # or "session" if needed
  3. Run full test suite to verify compatibility:
    make test
    # or
    uv run pytest tests/ -v

Optional Improvements:

  • Consider using loop_scope parameter in @pytest.mark.asyncio for tests requiring non-function scope
  • Review async fixtures to ensure they work correctly with the new loop management

Migration Path

# 1. Remove the custom event_loop fixture
# Edit tests/conftest.py and remove lines 14-19

# 2. Add asyncio configuration to pyproject.toml
# Add under [tool.pytest.ini_options]:
asyncio_mode = "auto"

# 3. Test the changes
uv sync --all-groups
make test

# 4. If tests fail, check for:
#    - Tests that directly manipulate event loops
#    - Fixtures that depend on the old event_loop fixture
#    - Tests using asyncio.run() or asyncio.Runner

Verdict

⚠️ Do Not Merge Yet - This PR requires code changes before merging:

  1. Must Fix: Remove the deprecated event_loop fixture from tests/conftest.py
  2. Recommended: Add asyncio_mode = "auto" to pytest configuration
  3. Required: Run full test suite to verify compatibility

Once these issues are addressed, this is a good upgrade that brings performance improvements and better async test handling.


References:

Generated by Claude Code 🤖

@robin-watcha robin-watcha merged commit 1c6559b into develop Nov 4, 2025
11 checks passed
@renovate renovate bot changed the title Update dependency pytest-asyncio to v1 Update dependency pytest-asyncio to v1 - autoclosed Nov 4, 2025
@renovate renovate bot deleted the renovate/pytest-asyncio-1.x branch November 4, 2025 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants