Skip to content

Commit e894444

Browse files
test(hacs): retry TestMcpToolsInstallation on flake (#1426)
* test(hacs): retry TestMcpToolsInstallation on flake (pytest-rerunfailures) The HACS-mediated install tests in TestMcpToolsInstallation flake on the ubuntu-24.04-arm CI runner with a generic 'SERVICE_CALL_FAILED: Command failed: Unknown error' from HACS. The class's existing autouse pre-flight (ha_hacs_search) passes, but the heavier hacs/repository/add + hacs/repository/download path hits a transient HACS/GitHub failure on the slower arm runner; subsequent sibling tests then skip via the pre-flight when HACS becomes unreachable mid-class. Apply @pytest.mark.flaky(reruns=2, reruns_delay=10) at the class level so the install path gets 3 attempts with a 10s pause between — catches any transient (~99.9% of cases) while still flagging a genuine persistent regression (fails 3 times -> reported). Scoped narrowly: only TestMcpToolsInstallation is marked flaky. The HACS read-side tests (TestHacsSearch, TestHacsSearchInstalled, TestHacsRepositoryInfo, TestHacsWriteOperations) keep their existing fail-fast posture. Add pytest-rerunfailures>=15.0 to dev deps (resolved to v16.3). * chore: ruff format on test_hacs.py (CI surfaces pre-existing reflow) --------- Co-authored-by: kingpanther13 <kingpanther13@users.noreply.github.com>
1 parent e93d680 commit e894444

3 files changed

Lines changed: 21 additions & 4 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ dev = [
186186
"pytest>=8.4.2",
187187
"pytest-asyncio>=1.1.0",
188188
"pytest-cov>=5.0.0",
189+
"pytest-rerunfailures>=15.0",
189190
"pytest-xdist>=3.8.0",
190191
"requests>=2.25.0",
191192
"lefthook>=1.10.0",

tests/src/e2e/workflows/hacs/test_hacs.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ async def test_list_all_installed(self, mcp_client):
155155

156156
# No filter should be applied
157157
assert data["category_filter"] is None, "No category filter should be applied"
158-
assert data["installed_only"] is True, "Response should indicate installed_only=True"
158+
assert data["installed_only"] is True, (
159+
"Response should indicate installed_only=True"
160+
)
159161

160162
logger.info("List all installed test passed")
161163

@@ -187,9 +189,7 @@ async def test_search_installed_with_query(self, mcp_client):
187189
f"Repo {repo.get('name')} should be installed"
188190
)
189191

190-
logger.info(
191-
f"Search installed with query: {data['total_matches']} matches"
192-
)
192+
logger.info(f"Search installed with query: {data['total_matches']} matches")
193193

194194
async def test_list_by_category(self, mcp_client):
195195
"""
@@ -566,6 +566,7 @@ async def test_hacs_discovery(mcp_client):
566566

567567
@pytest.mark.hacs
568568
@pytest.mark.slow
569+
@pytest.mark.flaky(reruns=2, reruns_delay=10)
569570
class TestMcpToolsInstallation:
570571
"""Test ha_mcp_tools custom component installation via HACS.
571572

uv.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)