Make scapy imports in DHCP local (#55647)

This commit is contained in:
Erik Montnemery 2021-09-06 19:10:27 +02:00 committed by GitHub
parent b99a22cd4d
commit dd7dea9a3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 12 deletions

View file

@ -390,9 +390,9 @@ async def test_setup_and_stop(hass):
)
await hass.async_block_till_done()
with patch("homeassistant.components.dhcp.AsyncSniffer.start") as start_call, patch(
with patch("scapy.sendrecv.AsyncSniffer.start") as start_call, patch(
"homeassistant.components.dhcp._verify_l2socket_setup",
), patch("homeassistant.components.dhcp.compile_filter",), patch(
), patch("scapy.arch.common.compile_filter"), patch(
"homeassistant.components.dhcp.DiscoverHosts.async_discover"
):
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
@ -461,12 +461,10 @@ async def test_setup_fails_with_broken_libpcap(hass, caplog):
)
await hass.async_block_till_done()
with patch("homeassistant.components.dhcp._verify_l2socket_setup",), patch(
"homeassistant.components.dhcp.compile_filter",
with patch("homeassistant.components.dhcp._verify_l2socket_setup"), patch(
"scapy.arch.common.compile_filter",
side_effect=ImportError,
) as compile_filter, patch(
"homeassistant.components.dhcp.AsyncSniffer",
) as async_sniffer, patch(
) as compile_filter, patch("scapy.sendrecv.AsyncSniffer") as async_sniffer, patch(
"homeassistant.components.dhcp.DiscoverHosts.async_discover"
):
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)