Skip to content

test: add blockbuster to detect blocking calls in asyncio tests#1761

Merged
bdraco merged 3 commits into
masterfrom
test/add-blockbuster
May 20, 2026
Merged

test: add blockbuster to detect blocking calls in asyncio tests#1761
bdraco merged 3 commits into
masterfrom
test/add-blockbuster

Conversation

@bdraco

@bdraco bdraco commented May 20, 2026

Copy link
Copy Markdown
Member

Summary

Wires blockbuster into an
autouse fixture in tests/conftest.py so any synchronous IO that
slips into the asyncio event loop fails the test instead of going
unnoticed. Mirrors the integration just landed in
dbus-fast#690.

Downstream consumers (Home Assistant in particular) keep catching
async-loop blockers for us; surfacing them in this repo's own CI is
cheap and forces the fix at the source.

Details

  • Adds blockbuster = ">=1.5.5,<2.0.0" to the dev dependency group.
  • Adds a blockbuster autouse fixture that wraps every non-benchmark
    test in blockbuster_ctx(). Benchmarks under tests/benchmarks/
    are skipped — CodSpeed runs there should measure real workload, not
    pay the cost of monkeypatched builtins.
  • Falls back to a no-op when blockbuster isn't importable (e.g. the
    PyPy / QEMU matrix legs that don't install it).
  • pytest_collection_modifyitems marks entries in _KNOWN_BLOCKING
    as xfail(strict=False) so a future addition lands green and the
    list shrinks over time as the underlying blocks are removed.

The only test the full suite trips on today is
tests/test_core.py::Framework::test_use_asyncio_false_forces_thread_when_loop_running,
which is deliberately documenting the sync-bootstrap path that
Zeroconf(use_asyncio=False) takes from inside a running event loop
(it blocks waiting for the loop thread to come up — the test pins
that behavior). It stays xfail by design; the comment on
_KNOWN_BLOCKING calls that out.

Test plan

  • `REQUIRE_CYTHON=1 poetry run pytest --timeout=60 tests` — 383 passed, 3 skipped, 2 xfailed (call + teardown of the by-design test above).
  • `SKIP_CYTHON=1 poetry run pytest --timeout=60 tests` — same shape, confirms pure-Python path.
  • `poetry run pre-commit run --files tests/conftest.py pyproject.toml poetry.lock` — clean.

@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.77%. Comparing base (3e5ac4f) to head (1071664).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1761   +/-   ##
=======================================
  Coverage   99.77%   99.77%           
=======================================
  Files          33       33           
  Lines        3509     3509           
  Branches      493      493           
=======================================
  Hits         3501     3501           
  Misses          5        5           
  Partials        3        3           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq

codspeed-hq Bot commented May 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 14 untouched benchmarks


Comparing test/add-blockbuster (1071664) with master (3e5ac4f)

Open in CodSpeed

@bdraco bdraco merged commit 90a5a39 into master May 20, 2026
33 of 34 checks passed
@bdraco bdraco deleted the test/add-blockbuster branch May 20, 2026 19:37
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.

1 participant