Skip to content

test: pass timeout=0 explicitly in test_event_loop_blocked - #1676

Merged
bdraco merged 2 commits into
masterfrom
speedup-test-event-loop-blocked
May 15, 2026
Merged

bdraco merged 2 commits into
masterfrom
speedup-test-event-loop-blocked

Conversation

@bdraco

@bdraco bdraco commented May 15, 2026

Copy link
Copy Markdown
Member

Summary

test_event_loop_blocked was taking 9.00s because the
@patch("zeroconf._core._STARTUP_TIMEOUT", 0) decorator never
took effect — async_wait_for_start(self, timeout: float = _STARTUP_TIMEOUT)
in src/zeroconf/_core.py:239 captures the constant as a
default-arg at function-definition time, so patching the
module-level name afterwards does not change the default the
call resolves to.

The test was therefore using timeout=9 (the real
_STARTUP_TIMEOUT) and waiting the full 9 seconds before raising
NotRunningException.

Details

Pass timeout=0 to the call directly and drop the no-op patch
decorator. The @patch("zeroconf._core.AsyncEngine._async_setup", ...)
decorator is kept — that one does work and is what prevents the
engine from actually starting, which is what the test is
exercising.

Test plan

  • poetry run pytest tests/test_core.py::test_event_loop_blocked
    passes in 0.08s (was 9.00s).
  • Pre-commit (ruff, mypy, etc.) clean.

The `@patch("zeroconf._core._STARTUP_TIMEOUT", 0)` decorator never
took effect — `async_wait_for_start(self, timeout: float = _STARTUP_TIMEOUT)`
captures the constant as a default-arg at function-definition time,
so patching the module-level name afterwards does not change the
default. The test was therefore using `timeout=9` (the real
_STARTUP_TIMEOUT) and waiting the full 9 seconds before raising
NotRunningException.

Pass `timeout=0` to the call directly and drop the no-op patch.
Test goes from 9.00s to ~0.08s.
@codspeed

codspeed Bot commented May 15, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing speedup-test-event-loop-blocked (f9fa060) with master (ba58754)1

Open in CodSpeed

Footnotes

  1. No successful run was found on master (dd8ede3) during the generation of this report, so ba58754 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@codecov

codecov Bot commented May 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.76%. Comparing base (dd8ede3) to head (f9fa060).
⚠️ Report is 109 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1676   +/-   ##
=======================================
  Coverage   99.76%   99.76%           
=======================================
  Files          33       33           
  Lines        3401     3401           
  Branches      461      461           
=======================================
  Hits         3393     3393           
  Misses          5        5           
  Partials        3        3           

☔ View full report in Codecov by Harness.
📢 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.

@bdraco
bdraco merged commit 1b31ed5 into master May 15, 2026
38 checks passed
@bdraco
bdraco deleted the speedup-test-event-loop-blocked branch May 15, 2026 20:53

This branch had an error being deployed

1 failed deployment
release — f9fa060b Deployed May 15, 2026 by bdraco via release #5205
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