From 77af741099fba3a016fede57d687ae05637c490c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 4 Oct 2021 08:25:09 -1000 Subject: [PATCH] Prevent tplink from opening sockets in tests (#57058) Supports #55516 --- tests/components/tplink/conftest.py | 5 +++++ tests/components/tplink/test_init.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/components/tplink/conftest.py b/tests/components/tplink/conftest.py index 1963b595176..20ce09b9ec8 100644 --- a/tests/components/tplink/conftest.py +++ b/tests/components/tplink/conftest.py @@ -25,3 +25,8 @@ def device_reg_fixture(hass): def entity_reg_fixture(hass): """Return an empty, loaded, registry.""" return mock_registry(hass) + + +@pytest.fixture(autouse=True) +def tplink_mock_get_source_ip(mock_get_source_ip): + """Mock network util's async_get_source_ip.""" diff --git a/tests/components/tplink/test_init.py b/tests/components/tplink/test_init.py index c3f7e814ed6..ee57a500a8d 100644 --- a/tests/components/tplink/test_init.py +++ b/tests/components/tplink/test_init.py @@ -21,7 +21,7 @@ async def test_configuring_tplink_causes_discovery(hass): await async_setup_component(hass, tplink.DOMAIN, {tplink.DOMAIN: {}}) await hass.async_block_till_done() - assert len(discover.mock_calls) == 1 + assert discover.mock_calls async def test_config_entry_reload(hass):