Skip to content

Add test for endpoint initialization failure#719

Merged
TheJulianJES merged 2 commits intozigpy:devfrom
TheJulianJES:tjj/coverage_init_endpoint_failure
Mar 24, 2026
Merged

Add test for endpoint initialization failure#719
TheJulianJES merged 2 commits intozigpy:devfrom
TheJulianJES:tjj/coverage_init_endpoint_failure

Conversation

@TheJulianJES
Copy link
Copy Markdown
Contributor

Proposed change

This adds a small test for endpoint initialization failure here:

zha/zha/zigbee/device.py

Lines 995 to 996 in 5848461

except Exception: # pylint: disable=broad-exception-caught
self.debug("Failed to initialize endpoint", exc_info=True)

Needed for code coverage in below PR (since a surrounding line is touched by that PR):

@TheJulianJES TheJulianJES marked this pull request as ready for review March 24, 2026 06:58
Copilot AI review requested due to automatic review settings March 24, 2026 06:58
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.64%. Comparing base (47f7048) to head (264092e).
⚠️ Report is 2 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #719      +/-   ##
==========================================
+ Coverage   97.62%   97.64%   +0.01%     
==========================================
  Files          62       62              
  Lines       10950    10951       +1     
==========================================
+ Hits        10690    10693       +3     
+ Misses        260      258       -2     

☔ 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a regression/unit test to exercise the Device.async_initialize() code path that catches and logs exceptions raised during per-endpoint initialization, improving coverage for the endpoint-initialization failure branch.

Changes:

  • Add an async test that patches an endpoint’s async_initialize to raise and then calls zha_device.async_initialize(from_cache=True).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_device.py Outdated
Comment thread tests/test_device.py Outdated
@TheJulianJES TheJulianJES merged commit 5f0b223 into zigpy:dev Mar 24, 2026
9 checks passed
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.

2 participants