Skip to content

tests: drop unused 'event_loop' fixture arg from test_resolver.py (3 collection errors) #214

Closed

Description

@bluet

Problem

Three tests in tests/test_resolver.py declare event_loop as a fixture argument but never use it:

async def test_get_real_ext_ip(event_loop, mocker, resolver):  # line 63
async def test_resolve(event_loop, mocker, resolver):          # line 101
async def test_resolve_cache(event_loop, mocker, resolver):    # line 224

pytest-asyncio deprecated the auto-provided event_loop fixture in 0.21 and removed it in 0.23. This project is on 0.26.0 (per pyproject.toml), so all three tests error at collection with:

fixture 'event_loop' not found

Root cause

These declarations date back to 2017 (commit d5602973, Constverum). At that time, declaring event_loop as an arg ensured pytest-asyncio set up a loop before the test body ran. Modern pytest-asyncio handles loop setup automatically via @pytest.mark.asyncio (or auto mode), so the arg is redundant.

The arg is never used inside any of the three function bodies — grep -c "event_loop" tests/test_resolver.py would show 0 references inside the bodies.

Fix (15-minute change)

Remove the unused event_loop arg from the three function signatures:

async def test_get_real_ext_ip(mocker, resolver):
async def test_resolve(mocker, resolver):
async def test_resolve_cache(mocker, resolver):

That's the entire change. No other code modifications.

Acceptance criteria

  • All 3 tests collect cleanly (no fixture 'event_loop' not found).
  • All 3 tests pass against the existing mocks.
  • No new fixtures introduced; no conftest.py change needed.
  • pytest tests/ reports zero collection errors.

Why this is safe

  • The arg has been unused for years; removing it can't change test semantics.
  • pytest-asyncio's automatic loop management (already enabled per pyproject.toml) handles what event_loop arg used to handle.
  • Existing @pytest.mark.asyncio decorator stays.

Why this matters

These 3 errors mask real test failures — every full-suite run reports "3 errors" alongside actual passes/failures, so a contributor scanning CI output for new breakage has to mentally subtract these. PR #212 already trained me to filter them out, which is exactly the sort of "noise drowns signal" anti-pattern that makes test suites lose their value over time.

Out of scope

  • Pinning pytest-asyncio<0.23 (regression to old behavior, not the modern path)
  • Defining a custom event_loop fixture in conftest.py (overkill; the arg isn't even used)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions