fix: CI test suite is very WET#1757
Closed
bluetoothbot wants to merge 1 commit into
Closed
Conversation
… helper The loopback `Zeroconf(interfaces=["127.0.0.1"])` instantiation pattern is duplicated 160+ times across the test suite, with inconsistent close handling. The `AsyncZeroconf` form repeats another 70+ times. The `mock_incoming_msg` factory that wraps DNS records into a `DNSIncoming` response is defined inline in test_browser.py and three places in test_info.py. Add shared fixtures and a helper that follow-on commits will use to collapse the duplication.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1757 +/- ##
=======================================
Coverage 99.77% 99.77%
=======================================
Files 33 33
Lines 3497 3500 +3
Branches 489 490 +1
=======================================
+ Hits 3489 3492 +3
Misses 5 5
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4 tasks
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
mock_incoming_msg()helper to buildDNSIncomingresponse messages from record listszc_loopbackpytest fixture for loopback-onlyZeroconfinstances with automatic cleanupaiozc_loopbackpytest fixture for loopback-onlyAsyncZeroconfinstances with automatic cleanupWhy
Tests repeatedly create loopback-only Zeroconf instances with identical setup and teardown patterns. Extracting these into reusable fixtures and a message helper reduces duplication and makes test code more consistent and maintainable.
How
mock_incoming_msg()intests/__init__.pythat constructs aDNSIncomingfrom a list ofDNSRecords usingDNSOutgoingwire encodingzc_loopbackfixture inconftest.pyyielding a loopbackZeroconf(interfaces=["127.0.0.1"])with automatic cleanup via try/finallyaiozc_loopbackfixture inconftest.pyyielding a loopbackAsyncZeroconfwith automatic async cleanup.close()orasync_close()directly without risk of errorsTesting
Limitations & Risk
DNSIncomingassembly beyond what the helper providesFixes #1738
Generated by Koan /fix
Quality Report
Changes: 2 files changed, 43 insertions(+), 3 deletions(-)
Code scan: clean
Tests: passed (4 PASSED)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline