Skip to content

Commit 9674676

Browse files
authored
Disable automatic start of HTTP server in tests (#155857)
1 parent b87b5cf commit 9674676

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tests/components/http/test_init.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626
from tests.typing import ClientSessionGenerator
2727

2828

29+
@pytest.fixture(autouse=True)
30+
def disable_http_server() -> None:
31+
"""Override the global disable_http_server fixture with an empty fixture.
32+
33+
This allows the HTTP server to start in tests that need it.
34+
"""
35+
return
36+
37+
2938
def _setup_broken_ssl_pem_files(tmp_path: Path) -> tuple[Path, Path]:
3039
test_dir = tmp_path / "test_broken_ssl"
3140
test_dir.mkdir()

tests/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,3 +2129,14 @@ def _dhcp_service_info_init(self: DhcpServiceInfo, *args: Any, **kwargs: Any) ->
21292129

21302130

21312131
DhcpServiceInfo.__init__ = _dhcp_service_info_init
2132+
2133+
2134+
@pytest.fixture(autouse=True)
2135+
def disable_http_server() -> Generator[None]:
2136+
"""Disable automatic start of HTTP server during tests.
2137+
2138+
This prevents the HTTP server from starting in tests that setup
2139+
integrations which depend on the HTTP component.
2140+
"""
2141+
with patch("homeassistant.components.http.start_http_server_and_save_config"):
2142+
yield

0 commit comments

Comments
 (0)