Repository navigation
test: pass timeout=0 explicitly in test_event_loop_blocked - #1676
Merged
Merged
Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test_event_loop_blockedwas taking 9.00s because the@patch("zeroconf._core._STARTUP_TIMEOUT", 0)decorator nevertook effect —
async_wait_for_start(self, timeout: float = _STARTUP_TIMEOUT)in
src/zeroconf/_core.py:239captures the constant as adefault-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 raisingNotRunningException.Details
Pass
timeout=0to the call directly and drop the no-op patchdecorator. 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_blockedpasses in 0.08s (was 9.00s).