1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Prevent tests changing units from affecting other tests (#70300)

* Prevent tests changing temperature_unit from affecting other tests

* tweak
This commit is contained in:
J. Nick Koston
2022-04-19 11:38:52 -10:00
committed by GitHub
parent 27c9e96865
commit 309424d3b9
9 changed files with 20 additions and 23 deletions

View File

@@ -4,6 +4,9 @@ from unittest.mock import AsyncMock, patch
import pytest
from homeassistant.core import HomeAssistant
from homeassistant.util.unit_system import IMPERIAL_SYSTEM
@pytest.fixture(scope="session", autouse=True)
def patch_zeroconf_multiple_catcher():
@@ -33,3 +36,10 @@ def entity_registry_enabled_by_default() -> Generator[AsyncMock, None, None]:
return_value=True,
) as mock_entity_registry_enabled_by_default:
yield mock_entity_registry_enabled_by_default
@pytest.fixture
def units_imperial(hass: HomeAssistant) -> Generator[None, None, None]:
"""Fixture to temporary change units to imperial."""
with patch.object(hass.config, "units", IMPERIAL_SYSTEM):
yield