mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Speed up tests by making mock_get_source_ip session scoped (#117096)
This commit is contained in:
parent
03dcede211
commit
6eeeafa8b8
@ -4,10 +4,13 @@ import pytest
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_get_source_ip():
|
||||
"""Override mock of network util's async_get_source_ip."""
|
||||
def mock_network():
|
||||
"""Override mock of network util's async_get_adapters."""
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_network():
|
||||
"""Override mock of network util's async_get_adapters."""
|
||||
def override_mock_get_source_ip(mock_get_source_ip):
|
||||
"""Override mock of network util's async_get_source_ip."""
|
||||
mock_get_source_ip.stop()
|
||||
yield
|
||||
mock_get_source_ip.start()
|
||||
|
@ -1145,14 +1145,18 @@ def mock_network() -> Generator[None, None, None]:
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_get_source_ip() -> Generator[None, None, None]:
|
||||
@pytest.fixture(autouse=True, scope="session")
|
||||
def mock_get_source_ip() -> Generator[patch, None, None]:
|
||||
"""Mock network util's async_get_source_ip."""
|
||||
with patch(
|
||||
patcher = patch(
|
||||
"homeassistant.components.network.util.async_get_source_ip",
|
||||
return_value="10.10.10.10",
|
||||
):
|
||||
yield
|
||||
)
|
||||
patcher.start()
|
||||
try:
|
||||
yield patcher
|
||||
finally:
|
||||
patcher.stop()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
Loading…
x
Reference in New Issue
Block a user