Use US_CUSTOMARY_SYSTEM in tests (#80658)

* Use US_CUSTOMARY_SYSTEM in tests

* Don't update test_unit_system
This commit is contained in:
epenet 2022-10-20 15:42:23 +02:00 committed by GitHub
parent 4e4682d2e0
commit e84e5f134e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 147 additions and 93 deletions

View file

@ -30,7 +30,7 @@ from homeassistant.const import (
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from . import init_integration from . import init_integration
@ -704,7 +704,7 @@ async def test_manual_update_entity(hass):
async def test_sensor_imperial_units(hass): async def test_sensor_imperial_units(hass):
"""Test states of the sensor without forecast.""" """Test states of the sensor without forecast."""
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
await init_integration(hass) await init_integration(hass)
state = hass.states.get("sensor.home_cloud_ceiling") state = hass.states.get("sensor.home_cloud_ceiling")

View file

@ -30,7 +30,7 @@ from homeassistant.const import STATE_UNKNOWN, TEMP_FAHRENHEIT
from homeassistant.core import Context from homeassistant.core import Context
from homeassistant.helpers import entityfilter from homeassistant.helpers import entityfilter
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .test_common import ( from .test_common import (
MockConfig, MockConfig,
@ -2020,7 +2020,7 @@ async def test_unknown_sensor(hass):
async def test_thermostat(hass): async def test_thermostat(hass):
"""Test thermostat discovery.""" """Test thermostat discovery."""
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
device = ( device = (
"climate.test_thermostat", "climate.test_thermostat",
"cool", "cool",

View file

@ -3,8 +3,8 @@ import pytest
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.util.unit_system import ( from homeassistant.util.unit_system import (
IMPERIAL_SYSTEM as IMPERIAL,
METRIC_SYSTEM as METRIC, METRIC_SYSTEM as METRIC,
US_CUSTOMARY_SYSTEM as IMPERIAL,
UnitSystem, UnitSystem,
) )

View file

@ -17,7 +17,7 @@ from homeassistant.components.repairs import DOMAIN as REPAIRS_DOMAIN
from homeassistant.helpers.json import JSONEncoder from homeassistant.helpers.json import JSONEncoder
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from tests.components.recorder.common import async_wait_recording_done from tests.components.recorder.common import async_wait_recording_done
@ -84,7 +84,7 @@ async def test_demo_statistics(recorder_mock, mock_history, hass):
async def test_demo_statistics_growth(recorder_mock, mock_history, hass): async def test_demo_statistics_growth(recorder_mock, mock_history, hass):
"""Test that the demo sum statistics adds to the previous state.""" """Test that the demo sum statistics adds to the previous state."""
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
now = dt_util.now() now = dt_util.now()
last_week = now - datetime.timedelta(days=7) last_week = now - datetime.timedelta(days=7)

View file

@ -4,7 +4,7 @@ import voluptuous as vol
from homeassistant.components import water_heater from homeassistant.components import water_heater
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from tests.components.water_heater import common from tests.components.water_heater import common
@ -15,7 +15,7 @@ ENTITY_WATER_HEATER_CELSIUS = "water_heater.demo_water_heater_celsius"
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
async def setup_comp(hass): async def setup_comp(hass):
"""Set up demo component.""" """Set up demo component."""
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
assert await async_setup_component( assert await async_setup_component(
hass, water_heater.DOMAIN, {"water_heater": {"platform": "demo"}} hass, water_heater.DOMAIN, {"water_heater": {"platform": "demo"}}
) )

View file

@ -34,7 +34,7 @@ from homeassistant.const import (
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from . import _generate_mock_feed_entry from . import _generate_mock_feed_entry
@ -208,7 +208,7 @@ async def test_setup(hass):
async def test_setup_imperial(hass): async def test_setup_imperial(hass):
"""Test the setup of the integration using imperial unit system.""" """Test the setup of the integration using imperial unit system."""
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
# Set up some mock feed entries for this test. # Set up some mock feed entries for this test.
mock_entry_1 = _generate_mock_feed_entry( mock_entry_1 = _generate_mock_feed_entry(
"1234", "1234",

View file

@ -37,7 +37,7 @@ from homeassistant.core import DOMAIN as HASS_DOMAIN, CoreState, State, callback
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM from homeassistant.util.unit_system import METRIC_SYSTEM, US_CUSTOMARY_SYSTEM
from tests.common import ( from tests.common import (
assert_setup_component, assert_setup_component,
@ -1201,7 +1201,7 @@ async def setup_comp_9(hass):
async def test_precision(hass, setup_comp_9): async def test_precision(hass, setup_comp_9):
"""Test that setting precision to tenths works as intended.""" """Test that setting precision to tenths works as intended."""
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
await common.async_set_temperature(hass, 23.27) await common.async_set_temperature(hass, 23.27)
state = hass.states.get(ENTITY) state = hass.states.get(ENTITY)
assert state.attributes.get("temperature") == 23.3 assert state.attributes.get("temperature") == 23.3

View file

@ -28,7 +28,7 @@ from homeassistant.const import (
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from . import _generate_mock_feed_entry from . import _generate_mock_feed_entry
@ -171,7 +171,7 @@ async def test_setup(hass):
async def test_setup_imperial(hass): async def test_setup_imperial(hass):
"""Test the setup of the integration using imperial unit system.""" """Test the setup of the integration using imperial unit system."""
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
# Set up some mock feed entries for this test. # Set up some mock feed entries for this test.
mock_entry_1 = _generate_mock_feed_entry("1234", "Title 1", 15.5, (38.0, -3.0)) mock_entry_1 = _generate_mock_feed_entry("1234", "Title 1", 15.5, (38.0, -3.0))

View file

@ -23,7 +23,7 @@ from homeassistant.const import (
) )
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from . import _generate_mock_feed_entry from . import _generate_mock_feed_entry
@ -150,7 +150,7 @@ async def test_setup(hass):
async def test_setup_imperial(hass): async def test_setup_imperial(hass):
"""Test the setup of the integration using imperial unit system.""" """Test the setup of the integration using imperial unit system."""
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
# Set up some mock feed entries for this test. # Set up some mock feed entries for this test.
mock_entry_1 = _generate_mock_feed_entry("1234", "Title 1", 1, 15.5, (38.0, -3.0)) mock_entry_1 = _generate_mock_feed_entry("1234", "Title 1", 1, 15.5, (38.0, -3.0))

View file

@ -12,7 +12,11 @@ from homeassistant.components.google_travel_time.const import (
) )
from homeassistant.const import CONF_UNIT_SYSTEM_IMPERIAL, CONF_UNIT_SYSTEM_METRIC from homeassistant.const import CONF_UNIT_SYSTEM_IMPERIAL, CONF_UNIT_SYSTEM_METRIC
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM, UnitSystem from homeassistant.util.unit_system import (
METRIC_SYSTEM,
US_CUSTOMARY_SYSTEM,
UnitSystem,
)
from .const import MOCK_CONFIG from .const import MOCK_CONFIG
@ -227,7 +231,7 @@ async def test_sensor_deprecation_warning(hass, caplog):
"unit_system, expected_unit_option", "unit_system, expected_unit_option",
[ [
(METRIC_SYSTEM, CONF_UNIT_SYSTEM_METRIC), (METRIC_SYSTEM, CONF_UNIT_SYSTEM_METRIC),
(IMPERIAL_SYSTEM, CONF_UNIT_SYSTEM_IMPERIAL), (US_CUSTOMARY_SYSTEM, CONF_UNIT_SYSTEM_IMPERIAL),
], ],
) )
async def test_sensor_unit_system( async def test_sensor_unit_system(

View file

@ -31,7 +31,11 @@ from homeassistant.const import (
CONF_UNIT_SYSTEM_METRIC, CONF_UNIT_SYSTEM_METRIC,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM, UnitSystem from homeassistant.util.unit_system import (
METRIC_SYSTEM,
US_CUSTOMARY_SYSTEM,
UnitSystem,
)
from .const import ( from .const import (
API_KEY, API_KEY,
@ -232,7 +236,7 @@ async def test_step_destination_coordinates(
"unit_system, expected_unit_option", "unit_system, expected_unit_option",
[ [
(METRIC_SYSTEM, CONF_UNIT_SYSTEM_METRIC), (METRIC_SYSTEM, CONF_UNIT_SYSTEM_METRIC),
(IMPERIAL_SYSTEM, CONF_UNIT_SYSTEM_IMPERIAL), (US_CUSTOMARY_SYSTEM, CONF_UNIT_SYSTEM_IMPERIAL),
], ],
) )
async def test_step_destination_entity( async def test_step_destination_entity(

View file

@ -16,7 +16,7 @@ from homeassistant.const import (
PRESSURE_PSI, PRESSURE_PSI,
) )
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from . import init_integration from . import init_integration
@ -132,7 +132,7 @@ async def test_sensors(hass):
async def test_sensors_imperial_units(hass): async def test_sensors_imperial_units(hass):
"""Test that the sensors work properly with imperial units.""" """Test that the sensors work properly with imperial units."""
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
await init_integration(hass) await init_integration(hass)

View file

@ -13,14 +13,14 @@ from homeassistant.const import (
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
) )
from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM from homeassistant.util.unit_system import METRIC_SYSTEM, US_CUSTOMARY_SYSTEM
@pytest.mark.parametrize( @pytest.mark.parametrize(
"unit_system, state_unit, state1, state2", "unit_system, state_unit, state1, state2",
( (
(METRIC_SYSTEM, TEMP_CELSIUS, "100", "123"), (METRIC_SYSTEM, TEMP_CELSIUS, "100", "123"),
(IMPERIAL_SYSTEM, TEMP_FAHRENHEIT, "212", "253"), (US_CUSTOMARY_SYSTEM, TEMP_FAHRENHEIT, "212", "253"),
), ),
) )
async def test_sensor( async def test_sensor(
@ -124,9 +124,9 @@ async def test_sensor(
"unique_id, unit_system, state_unit, state1, state2", "unique_id, unit_system, state_unit, state1, state2",
( (
("battery_temperature", METRIC_SYSTEM, TEMP_CELSIUS, "100", "123"), ("battery_temperature", METRIC_SYSTEM, TEMP_CELSIUS, "100", "123"),
("battery_temperature", IMPERIAL_SYSTEM, TEMP_FAHRENHEIT, "212", "253"), ("battery_temperature", US_CUSTOMARY_SYSTEM, TEMP_FAHRENHEIT, "212", "253"),
# The unique_id doesn't match that of the mobile app's battery temperature sensor # The unique_id doesn't match that of the mobile app's battery temperature sensor
("battery_temp", IMPERIAL_SYSTEM, TEMP_FAHRENHEIT, "212", "123"), ("battery_temp", US_CUSTOMARY_SYSTEM, TEMP_FAHRENHEIT, "212", "123"),
), ),
) )
async def test_sensor_migration( async def test_sensor_migration(

View file

@ -21,7 +21,11 @@ from homeassistant.const import (
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM, UnitSystem from homeassistant.util.unit_system import (
METRIC_SYSTEM,
US_CUSTOMARY_SYSTEM,
UnitSystem,
)
from tests.common import MockConfigEntry from tests.common import MockConfigEntry
@ -124,7 +128,7 @@ async def test_distance_sensor(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"unit_system, unit", "unit_system, unit",
[(METRIC_SYSTEM, TEMP_CELSIUS), (IMPERIAL_SYSTEM, TEMP_FAHRENHEIT)], [(METRIC_SYSTEM, TEMP_CELSIUS), (US_CUSTOMARY_SYSTEM, TEMP_FAHRENHEIT)],
) )
async def test_temperature_sensor( async def test_temperature_sensor(
hass: HomeAssistant, hass: HomeAssistant,

View file

@ -25,7 +25,7 @@ from homeassistant.core import HomeAssistant, State
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.restore_state import STORAGE_KEY as RESTORE_STATE_KEY from homeassistant.helpers.restore_state import STORAGE_KEY as RESTORE_STATE_KEY
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM from homeassistant.util.unit_system import METRIC_SYSTEM, US_CUSTOMARY_SYSTEM
from tests.common import mock_restore_cache_with_extra_data from tests.common import mock_restore_cache_with_extra_data
@ -435,7 +435,7 @@ async def test_deprecated_methods(
"native_min_value, state_min_value, native_step, state_step", "native_min_value, state_min_value, native_step, state_step",
[ [
( (
IMPERIAL_SYSTEM, US_CUSTOMARY_SYSTEM,
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
100, 100,
@ -450,7 +450,7 @@ async def test_deprecated_methods(
3, 3,
), ),
( (
IMPERIAL_SYSTEM, US_CUSTOMARY_SYSTEM,
TEMP_CELSIUS, TEMP_CELSIUS,
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
38, 38,

View file

@ -6,7 +6,7 @@ from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
from homeassistant.const import ATTR_ATTRIBUTION, STATE_UNKNOWN from homeassistant.const import ATTR_ATTRIBUTION, STATE_UNKNOWN
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
from homeassistant.util import slugify from homeassistant.util import slugify
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM from homeassistant.util.unit_system import METRIC_SYSTEM, US_CUSTOMARY_SYSTEM
from .const import ( from .const import (
EXPECTED_FORECAST_IMPERIAL, EXPECTED_FORECAST_IMPERIAL,
@ -24,7 +24,7 @@ from tests.common import MockConfigEntry
"units,result_observation,result_forecast", "units,result_observation,result_forecast",
[ [
( (
IMPERIAL_SYSTEM, US_CUSTOMARY_SYSTEM,
SENSOR_EXPECTED_OBSERVATION_IMPERIAL, SENSOR_EXPECTED_OBSERVATION_IMPERIAL,
EXPECTED_FORECAST_IMPERIAL, EXPECTED_FORECAST_IMPERIAL,
), ),

View file

@ -15,7 +15,7 @@ from homeassistant.const import STATE_UNAVAILABLE, STATE_UNKNOWN
from homeassistant.helpers import entity_registry as er from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM from homeassistant.util.unit_system import METRIC_SYSTEM, US_CUSTOMARY_SYSTEM
from .const import ( from .const import (
EXPECTED_FORECAST_IMPERIAL, EXPECTED_FORECAST_IMPERIAL,
@ -34,7 +34,7 @@ from tests.common import MockConfigEntry, async_fire_time_changed
"units,result_observation,result_forecast", "units,result_observation,result_forecast",
[ [
( (
IMPERIAL_SYSTEM, US_CUSTOMARY_SYSTEM,
WEATHER_EXPECTED_OBSERVATION_IMPERIAL, WEATHER_EXPECTED_OBSERVATION_IMPERIAL,
EXPECTED_FORECAST_IMPERIAL, EXPECTED_FORECAST_IMPERIAL,
), ),

View file

@ -19,7 +19,7 @@ from homeassistant.components.recorder.statistics import (
from homeassistant.helpers import recorder as recorder_helper from homeassistant.helpers import recorder as recorder_helper
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM from homeassistant.util.unit_system import METRIC_SYSTEM, US_CUSTOMARY_SYSTEM
from .common import ( from .common import (
async_recorder_block_till_done, async_recorder_block_till_done,
@ -126,7 +126,7 @@ async def test_statistics_during_period(recorder_mock, hass, hass_ws_client):
"""Test statistics_during_period.""" """Test statistics_during_period."""
now = dt_util.utcnow() now = dt_util.utcnow()
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
await async_setup_component(hass, "sensor", {}) await async_setup_component(hass, "sensor", {})
await async_recorder_block_till_done(hass) await async_recorder_block_till_done(hass)
hass.states.async_set("sensor.test", 10, attributes=POWER_SENSOR_KW_ATTRIBUTES) hass.states.async_set("sensor.test", 10, attributes=POWER_SENSOR_KW_ATTRIBUTES)
@ -431,7 +431,7 @@ async def test_statistics_during_period_in_the_past(
hass.config.set_time_zone("UTC") hass.config.set_time_zone("UTC")
now = dt_util.utcnow().replace() now = dt_util.utcnow().replace()
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
await async_setup_component(hass, "sensor", {}) await async_setup_component(hass, "sensor", {})
await async_recorder_block_till_done(hass) await async_recorder_block_till_done(hass)
@ -589,27 +589,57 @@ async def test_statistics_during_period_bad_end_time(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"units, attributes, display_unit, statistics_unit, unit_class", "units, attributes, display_unit, statistics_unit, unit_class",
[ [
(IMPERIAL_SYSTEM, DISTANCE_SENSOR_M_ATTRIBUTES, "m", "m", "distance"), (US_CUSTOMARY_SYSTEM, DISTANCE_SENSOR_M_ATTRIBUTES, "m", "m", "distance"),
(METRIC_SYSTEM, DISTANCE_SENSOR_M_ATTRIBUTES, "m", "m", "distance"), (METRIC_SYSTEM, DISTANCE_SENSOR_M_ATTRIBUTES, "m", "m", "distance"),
(IMPERIAL_SYSTEM, DISTANCE_SENSOR_FT_ATTRIBUTES, "ft", "ft", "distance"), (
US_CUSTOMARY_SYSTEM,
DISTANCE_SENSOR_FT_ATTRIBUTES,
"ft",
"ft",
"distance",
),
(METRIC_SYSTEM, DISTANCE_SENSOR_FT_ATTRIBUTES, "ft", "ft", "distance"), (METRIC_SYSTEM, DISTANCE_SENSOR_FT_ATTRIBUTES, "ft", "ft", "distance"),
(IMPERIAL_SYSTEM, ENERGY_SENSOR_WH_ATTRIBUTES, "Wh", "Wh", "energy"), (US_CUSTOMARY_SYSTEM, ENERGY_SENSOR_WH_ATTRIBUTES, "Wh", "Wh", "energy"),
(METRIC_SYSTEM, ENERGY_SENSOR_WH_ATTRIBUTES, "Wh", "Wh", "energy"), (METRIC_SYSTEM, ENERGY_SENSOR_WH_ATTRIBUTES, "Wh", "Wh", "energy"),
(IMPERIAL_SYSTEM, GAS_SENSOR_FT3_ATTRIBUTES, "ft³", "ft³", "volume"), (US_CUSTOMARY_SYSTEM, GAS_SENSOR_FT3_ATTRIBUTES, "ft³", "ft³", "volume"),
(METRIC_SYSTEM, GAS_SENSOR_FT3_ATTRIBUTES, "ft³", "ft³", "volume"), (METRIC_SYSTEM, GAS_SENSOR_FT3_ATTRIBUTES, "ft³", "ft³", "volume"),
(IMPERIAL_SYSTEM, POWER_SENSOR_KW_ATTRIBUTES, "kW", "kW", "power"), (US_CUSTOMARY_SYSTEM, POWER_SENSOR_KW_ATTRIBUTES, "kW", "kW", "power"),
(METRIC_SYSTEM, POWER_SENSOR_KW_ATTRIBUTES, "kW", "kW", "power"), (METRIC_SYSTEM, POWER_SENSOR_KW_ATTRIBUTES, "kW", "kW", "power"),
(IMPERIAL_SYSTEM, PRESSURE_SENSOR_HPA_ATTRIBUTES, "hPa", "hPa", "pressure"), (
US_CUSTOMARY_SYSTEM,
PRESSURE_SENSOR_HPA_ATTRIBUTES,
"hPa",
"hPa",
"pressure",
),
(METRIC_SYSTEM, PRESSURE_SENSOR_HPA_ATTRIBUTES, "hPa", "hPa", "pressure"), (METRIC_SYSTEM, PRESSURE_SENSOR_HPA_ATTRIBUTES, "hPa", "hPa", "pressure"),
(IMPERIAL_SYSTEM, SPEED_SENSOR_KPH_ATTRIBUTES, "km/h", "km/h", "speed"), (US_CUSTOMARY_SYSTEM, SPEED_SENSOR_KPH_ATTRIBUTES, "km/h", "km/h", "speed"),
(METRIC_SYSTEM, SPEED_SENSOR_KPH_ATTRIBUTES, "km/h", "km/h", "speed"), (METRIC_SYSTEM, SPEED_SENSOR_KPH_ATTRIBUTES, "km/h", "km/h", "speed"),
(IMPERIAL_SYSTEM, TEMPERATURE_SENSOR_C_ATTRIBUTES, "°C", "°C", "temperature"), (
US_CUSTOMARY_SYSTEM,
TEMPERATURE_SENSOR_C_ATTRIBUTES,
"°C",
"°C",
"temperature",
),
(METRIC_SYSTEM, TEMPERATURE_SENSOR_C_ATTRIBUTES, "°C", "°C", "temperature"), (METRIC_SYSTEM, TEMPERATURE_SENSOR_C_ATTRIBUTES, "°C", "°C", "temperature"),
(IMPERIAL_SYSTEM, TEMPERATURE_SENSOR_F_ATTRIBUTES, "°F", "°F", "temperature"), (
US_CUSTOMARY_SYSTEM,
TEMPERATURE_SENSOR_F_ATTRIBUTES,
"°F",
"°F",
"temperature",
),
(METRIC_SYSTEM, TEMPERATURE_SENSOR_F_ATTRIBUTES, "°F", "°F", "temperature"), (METRIC_SYSTEM, TEMPERATURE_SENSOR_F_ATTRIBUTES, "°F", "°F", "temperature"),
(IMPERIAL_SYSTEM, VOLUME_SENSOR_FT3_ATTRIBUTES, "ft³", "ft³", "volume"), (US_CUSTOMARY_SYSTEM, VOLUME_SENSOR_FT3_ATTRIBUTES, "ft³", "ft³", "volume"),
(METRIC_SYSTEM, VOLUME_SENSOR_FT3_ATTRIBUTES, "ft³", "ft³", "volume"), (METRIC_SYSTEM, VOLUME_SENSOR_FT3_ATTRIBUTES, "ft³", "ft³", "volume"),
(IMPERIAL_SYSTEM, VOLUME_SENSOR_FT3_ATTRIBUTES_TOTAL, "ft³", "ft³", "volume"), (
US_CUSTOMARY_SYSTEM,
VOLUME_SENSOR_FT3_ATTRIBUTES_TOTAL,
"ft³",
"ft³",
"volume",
),
(METRIC_SYSTEM, VOLUME_SENSOR_FT3_ATTRIBUTES_TOTAL, "ft³", "ft³", "volume"), (METRIC_SYSTEM, VOLUME_SENSOR_FT3_ATTRIBUTES_TOTAL, "ft³", "ft³", "volume"),
], ],
) )

View file

@ -35,7 +35,7 @@ from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.restore_state import STORAGE_KEY as RESTORE_STATE_KEY from homeassistant.helpers.restore_state import STORAGE_KEY as RESTORE_STATE_KEY
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM from homeassistant.util.unit_system import METRIC_SYSTEM, US_CUSTOMARY_SYSTEM
from tests.common import mock_restore_cache_with_extra_data from tests.common import mock_restore_cache_with_extra_data
@ -43,8 +43,8 @@ from tests.common import mock_restore_cache_with_extra_data
@pytest.mark.parametrize( @pytest.mark.parametrize(
"unit_system,native_unit,state_unit,native_value,state_value", "unit_system,native_unit,state_unit,native_value,state_value",
[ [
(IMPERIAL_SYSTEM, TEMP_FAHRENHEIT, TEMP_FAHRENHEIT, 100, 100), (US_CUSTOMARY_SYSTEM, TEMP_FAHRENHEIT, TEMP_FAHRENHEIT, 100, 100),
(IMPERIAL_SYSTEM, TEMP_CELSIUS, TEMP_FAHRENHEIT, 38, 100), (US_CUSTOMARY_SYSTEM, TEMP_CELSIUS, TEMP_FAHRENHEIT, 38, 100),
(METRIC_SYSTEM, TEMP_FAHRENHEIT, TEMP_CELSIUS, 100, 38), (METRIC_SYSTEM, TEMP_FAHRENHEIT, TEMP_CELSIUS, 100, 38),
(METRIC_SYSTEM, TEMP_CELSIUS, TEMP_CELSIUS, 38, 38), (METRIC_SYSTEM, TEMP_CELSIUS, TEMP_CELSIUS, 38, 38),
], ],

View file

@ -26,7 +26,7 @@ from homeassistant.components.recorder.util import get_instance, session_scope
from homeassistant.const import STATE_UNAVAILABLE from homeassistant.const import STATE_UNAVAILABLE
from homeassistant.setup import async_setup_component, setup_component from homeassistant.setup import async_setup_component, setup_component
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM from homeassistant.util.unit_system import METRIC_SYSTEM, US_CUSTOMARY_SYSTEM
from tests.components.recorder.common import ( from tests.components.recorder.common import (
async_recorder_block_till_done, async_recorder_block_till_done,
@ -403,18 +403,18 @@ def test_compile_hourly_statistics_wrong_unit(hass_recorder, caplog, attributes)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"units, device_class, state_unit, display_unit, statistics_unit, unit_class, factor", "units, device_class, state_unit, display_unit, statistics_unit, unit_class, factor",
[ [
(IMPERIAL_SYSTEM, "distance", "m", "m", "m", "distance", 1), (US_CUSTOMARY_SYSTEM, "distance", "m", "m", "m", "distance", 1),
(IMPERIAL_SYSTEM, "distance", "mi", "mi", "mi", "distance", 1), (US_CUSTOMARY_SYSTEM, "distance", "mi", "mi", "mi", "distance", 1),
(IMPERIAL_SYSTEM, "energy", "kWh", "kWh", "kWh", "energy", 1), (US_CUSTOMARY_SYSTEM, "energy", "kWh", "kWh", "kWh", "energy", 1),
(IMPERIAL_SYSTEM, "energy", "Wh", "Wh", "Wh", "energy", 1), (US_CUSTOMARY_SYSTEM, "energy", "Wh", "Wh", "Wh", "energy", 1),
(IMPERIAL_SYSTEM, "gas", "", "", "", "volume", 1), (US_CUSTOMARY_SYSTEM, "gas", "", "", "", "volume", 1),
(IMPERIAL_SYSTEM, "gas", "ft³", "ft³", "ft³", "volume", 1), (US_CUSTOMARY_SYSTEM, "gas", "ft³", "ft³", "ft³", "volume", 1),
(IMPERIAL_SYSTEM, "monetary", "EUR", "EUR", "EUR", None, 1), (US_CUSTOMARY_SYSTEM, "monetary", "EUR", "EUR", "EUR", None, 1),
(IMPERIAL_SYSTEM, "monetary", "SEK", "SEK", "SEK", None, 1), (US_CUSTOMARY_SYSTEM, "monetary", "SEK", "SEK", "SEK", None, 1),
(IMPERIAL_SYSTEM, "volume", "", "", "", "volume", 1), (US_CUSTOMARY_SYSTEM, "volume", "", "", "", "volume", 1),
(IMPERIAL_SYSTEM, "volume", "ft³", "ft³", "ft³", "volume", 1), (US_CUSTOMARY_SYSTEM, "volume", "ft³", "ft³", "ft³", "volume", 1),
(IMPERIAL_SYSTEM, "weight", "g", "g", "g", "mass", 1), (US_CUSTOMARY_SYSTEM, "weight", "g", "g", "g", "mass", 1),
(IMPERIAL_SYSTEM, "weight", "oz", "oz", "oz", "mass", 1), (US_CUSTOMARY_SYSTEM, "weight", "oz", "oz", "oz", "mass", 1),
(METRIC_SYSTEM, "distance", "m", "m", "m", "distance", 1), (METRIC_SYSTEM, "distance", "m", "m", "m", "distance", 1),
(METRIC_SYSTEM, "distance", "mi", "mi", "mi", "distance", 1), (METRIC_SYSTEM, "distance", "mi", "mi", "mi", "distance", 1),
(METRIC_SYSTEM, "energy", "kWh", "kWh", "kWh", "energy", 1), (METRIC_SYSTEM, "energy", "kWh", "kWh", "kWh", "energy", 1),
@ -3307,12 +3307,18 @@ def record_states(hass, zero, entity_id, attributes, seq=None):
@pytest.mark.parametrize( @pytest.mark.parametrize(
"units, attributes, unit, unit2, supported_unit", "units, attributes, unit, unit2, supported_unit",
[ [
(IMPERIAL_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W", "kW", "W, kW"), (US_CUSTOMARY_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W", "kW", "W, kW"),
(METRIC_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W", "kW", "W, kW"), (METRIC_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W", "kW", "W, kW"),
(IMPERIAL_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, "°F", "K", "K, °C, °F"), (
US_CUSTOMARY_SYSTEM,
TEMPERATURE_SENSOR_ATTRIBUTES,
"°F",
"K",
"K, °C, °F",
),
(METRIC_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, "°C", "K", "K, °C, °F"), (METRIC_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, "°C", "K", "K, °C, °F"),
( (
IMPERIAL_SYSTEM, US_CUSTOMARY_SYSTEM,
PRESSURE_SENSOR_ATTRIBUTES, PRESSURE_SENSOR_ATTRIBUTES,
"psi", "psi",
"bar", "bar",
@ -3439,7 +3445,7 @@ async def test_validate_unit_change_convertible(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"units, attributes", "units, attributes",
[ [
(IMPERIAL_SYSTEM, POWER_SENSOR_ATTRIBUTES), (US_CUSTOMARY_SYSTEM, POWER_SENSOR_ATTRIBUTES),
], ],
) )
async def test_validate_statistics_unit_ignore_device_class( async def test_validate_statistics_unit_ignore_device_class(
@ -3493,12 +3499,18 @@ async def test_validate_statistics_unit_ignore_device_class(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"units, attributes, unit, unit2, supported_unit", "units, attributes, unit, unit2, supported_unit",
[ [
(IMPERIAL_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W", "kW", "W, kW"), (US_CUSTOMARY_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W", "kW", "W, kW"),
(METRIC_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W", "kW", "W, kW"), (METRIC_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W", "kW", "W, kW"),
(IMPERIAL_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, "°F", "K", "K, °C, °F"), (
US_CUSTOMARY_SYSTEM,
TEMPERATURE_SENSOR_ATTRIBUTES,
"°F",
"K",
"K, °C, °F",
),
(METRIC_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, "°C", "K", "K, °C, °F"), (METRIC_SYSTEM, TEMPERATURE_SENSOR_ATTRIBUTES, "°C", "K", "K, °C, °F"),
( (
IMPERIAL_SYSTEM, US_CUSTOMARY_SYSTEM,
PRESSURE_SENSOR_ATTRIBUTES, PRESSURE_SENSOR_ATTRIBUTES,
"psi", "psi",
"bar", "bar",
@ -3625,7 +3637,7 @@ async def test_validate_statistics_unit_change_no_device_class(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"units, attributes, unit", "units, attributes, unit",
[ [
(IMPERIAL_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W"), (US_CUSTOMARY_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W"),
], ],
) )
async def test_validate_statistics_unsupported_state_class( async def test_validate_statistics_unsupported_state_class(
@ -3689,7 +3701,7 @@ async def test_validate_statistics_unsupported_state_class(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"units, attributes, unit", "units, attributes, unit",
[ [
(IMPERIAL_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W"), (US_CUSTOMARY_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W"),
], ],
) )
async def test_validate_statistics_sensor_no_longer_recorded( async def test_validate_statistics_sensor_no_longer_recorded(
@ -3750,7 +3762,7 @@ async def test_validate_statistics_sensor_no_longer_recorded(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"units, attributes, unit", "units, attributes, unit",
[ [
(IMPERIAL_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W"), (US_CUSTOMARY_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W"),
], ],
) )
async def test_validate_statistics_sensor_not_recorded( async def test_validate_statistics_sensor_not_recorded(
@ -3808,7 +3820,7 @@ async def test_validate_statistics_sensor_not_recorded(
@pytest.mark.parametrize( @pytest.mark.parametrize(
"units, attributes, unit", "units, attributes, unit",
[ [
(IMPERIAL_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W"), (US_CUSTOMARY_SYSTEM, POWER_SENSOR_ATTRIBUTES, "W"),
], ],
) )
async def test_validate_statistics_sensor_removed( async def test_validate_statistics_sensor_removed(

View file

@ -7,7 +7,7 @@ from homeassistant.components.subaru.sensor import (
SAFETY_SENSORS, SAFETY_SENSORS,
) )
from homeassistant.util import slugify from homeassistant.util import slugify
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .api_responses import ( from .api_responses import (
EXPECTED_STATE_EV_IMPERIAL, EXPECTED_STATE_EV_IMPERIAL,
@ -25,7 +25,7 @@ from .conftest import (
async def test_sensors_ev_imperial(hass, ev_entry): async def test_sensors_ev_imperial(hass, ev_entry):
"""Test sensors supporting imperial units.""" """Test sensors supporting imperial units."""
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
with patch(MOCK_API_FETCH), patch( with patch(MOCK_API_FETCH), patch(
MOCK_API_GET_DATA, return_value=VEHICLE_STATUS_EV MOCK_API_GET_DATA, return_value=VEHICLE_STATUS_EV

View file

@ -25,7 +25,7 @@ from homeassistant.const import ATTR_ATTRIBUTION, CONF_NAME
from homeassistant.core import HomeAssistant, State, callback from homeassistant.core import HomeAssistant, State, callback
from homeassistant.helpers.entity_registry import async_get from homeassistant.helpers.entity_registry import async_get
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .const import API_V4_ENTRY_DATA from .const import API_V4_ENTRY_DATA
@ -172,7 +172,7 @@ async def test_v4_sensor(hass: HomeAssistant) -> None:
async def test_v4_sensor_imperial(hass: HomeAssistant) -> None: async def test_v4_sensor_imperial(hass: HomeAssistant) -> None:
"""Test v4 sensor data.""" """Test v4 sensor data."""
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
await _setup(hass, V4_FIELDS, API_V4_ENTRY_DATA) await _setup(hass, V4_FIELDS, API_V4_ENTRY_DATA)
check_sensor_state(hass, O3, "91.35") check_sensor_state(hass, O3, "91.35")
check_sensor_state(hass, CO, "0.0") check_sensor_state(hass, CO, "0.0")

View file

@ -54,7 +54,7 @@ from homeassistant.util.distance import convert as convert_distance
from homeassistant.util.pressure import convert as convert_pressure from homeassistant.util.pressure import convert as convert_pressure
from homeassistant.util.speed import convert as convert_speed from homeassistant.util.speed import convert as convert_speed
from homeassistant.util.temperature import convert as convert_temperature from homeassistant.util.temperature import convert as convert_temperature
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM from homeassistant.util.unit_system import METRIC_SYSTEM, US_CUSTOMARY_SYSTEM
from tests.testing_config.custom_components.test import weather as WeatherPlatform from tests.testing_config.custom_components.test import weather as WeatherPlatform
@ -143,7 +143,7 @@ async def create_entity(hass: HomeAssistant, **kwargs):
@pytest.mark.parametrize("native_unit", (TEMP_FAHRENHEIT, TEMP_CELSIUS)) @pytest.mark.parametrize("native_unit", (TEMP_FAHRENHEIT, TEMP_CELSIUS))
@pytest.mark.parametrize( @pytest.mark.parametrize(
"state_unit, unit_system", "state_unit, unit_system",
((TEMP_CELSIUS, METRIC_SYSTEM), (TEMP_FAHRENHEIT, IMPERIAL_SYSTEM)), ((TEMP_CELSIUS, METRIC_SYSTEM), (TEMP_FAHRENHEIT, US_CUSTOMARY_SYSTEM)),
) )
async def test_temperature( async def test_temperature(
hass: HomeAssistant, hass: HomeAssistant,
@ -176,7 +176,7 @@ async def test_temperature(
@pytest.mark.parametrize("native_unit", (None,)) @pytest.mark.parametrize("native_unit", (None,))
@pytest.mark.parametrize( @pytest.mark.parametrize(
"state_unit, unit_system", "state_unit, unit_system",
((TEMP_CELSIUS, METRIC_SYSTEM), (TEMP_FAHRENHEIT, IMPERIAL_SYSTEM)), ((TEMP_CELSIUS, METRIC_SYSTEM), (TEMP_FAHRENHEIT, US_CUSTOMARY_SYSTEM)),
) )
async def test_temperature_no_unit( async def test_temperature_no_unit(
hass: HomeAssistant, hass: HomeAssistant,
@ -209,7 +209,7 @@ async def test_temperature_no_unit(
@pytest.mark.parametrize("native_unit", (PRESSURE_INHG, PRESSURE_INHG)) @pytest.mark.parametrize("native_unit", (PRESSURE_INHG, PRESSURE_INHG))
@pytest.mark.parametrize( @pytest.mark.parametrize(
"state_unit, unit_system", "state_unit, unit_system",
((PRESSURE_HPA, METRIC_SYSTEM), (PRESSURE_INHG, IMPERIAL_SYSTEM)), ((PRESSURE_HPA, METRIC_SYSTEM), (PRESSURE_INHG, US_CUSTOMARY_SYSTEM)),
) )
async def test_pressure( async def test_pressure(
hass: HomeAssistant, hass: HomeAssistant,
@ -237,7 +237,7 @@ async def test_pressure(
@pytest.mark.parametrize("native_unit", (None,)) @pytest.mark.parametrize("native_unit", (None,))
@pytest.mark.parametrize( @pytest.mark.parametrize(
"state_unit, unit_system", "state_unit, unit_system",
((PRESSURE_HPA, METRIC_SYSTEM), (PRESSURE_INHG, IMPERIAL_SYSTEM)), ((PRESSURE_HPA, METRIC_SYSTEM), (PRESSURE_INHG, US_CUSTOMARY_SYSTEM)),
) )
async def test_pressure_no_unit( async def test_pressure_no_unit(
hass: HomeAssistant, hass: HomeAssistant,
@ -270,7 +270,7 @@ async def test_pressure_no_unit(
"state_unit, unit_system", "state_unit, unit_system",
( (
(SPEED_KILOMETERS_PER_HOUR, METRIC_SYSTEM), (SPEED_KILOMETERS_PER_HOUR, METRIC_SYSTEM),
(SPEED_MILES_PER_HOUR, IMPERIAL_SYSTEM), (SPEED_MILES_PER_HOUR, US_CUSTOMARY_SYSTEM),
), ),
) )
async def test_wind_speed( async def test_wind_speed(
@ -304,7 +304,7 @@ async def test_wind_speed(
"state_unit, unit_system", "state_unit, unit_system",
( (
(SPEED_KILOMETERS_PER_HOUR, METRIC_SYSTEM), (SPEED_KILOMETERS_PER_HOUR, METRIC_SYSTEM),
(SPEED_MILES_PER_HOUR, IMPERIAL_SYSTEM), (SPEED_MILES_PER_HOUR, US_CUSTOMARY_SYSTEM),
), ),
) )
async def test_wind_speed_no_unit( async def test_wind_speed_no_unit(
@ -338,7 +338,7 @@ async def test_wind_speed_no_unit(
"state_unit, unit_system", "state_unit, unit_system",
( (
(LENGTH_KILOMETERS, METRIC_SYSTEM), (LENGTH_KILOMETERS, METRIC_SYSTEM),
(LENGTH_MILES, IMPERIAL_SYSTEM), (LENGTH_MILES, US_CUSTOMARY_SYSTEM),
), ),
) )
async def test_visibility( async def test_visibility(
@ -369,7 +369,7 @@ async def test_visibility(
"state_unit, unit_system", "state_unit, unit_system",
( (
(LENGTH_KILOMETERS, METRIC_SYSTEM), (LENGTH_KILOMETERS, METRIC_SYSTEM),
(LENGTH_MILES, IMPERIAL_SYSTEM), (LENGTH_MILES, US_CUSTOMARY_SYSTEM),
), ),
) )
async def test_visibility_no_unit( async def test_visibility_no_unit(
@ -400,7 +400,7 @@ async def test_visibility_no_unit(
"state_unit, unit_system", "state_unit, unit_system",
( (
(LENGTH_MILLIMETERS, METRIC_SYSTEM), (LENGTH_MILLIMETERS, METRIC_SYSTEM),
(LENGTH_INCHES, IMPERIAL_SYSTEM), (LENGTH_INCHES, US_CUSTOMARY_SYSTEM),
), ),
) )
async def test_precipitation( async def test_precipitation(
@ -431,7 +431,7 @@ async def test_precipitation(
"state_unit, unit_system", "state_unit, unit_system",
( (
(LENGTH_MILLIMETERS, METRIC_SYSTEM), (LENGTH_MILLIMETERS, METRIC_SYSTEM),
(LENGTH_INCHES, IMPERIAL_SYSTEM), (LENGTH_INCHES, US_CUSTOMARY_SYSTEM),
), ),
) )
async def test_precipitation_no_unit( async def test_precipitation_no_unit(
@ -719,7 +719,7 @@ async def test_backwards_compatibility_convert_values(
precipitation_value = 1 precipitation_value = 1
precipitation_unit = LENGTH_MILLIMETERS precipitation_unit = LENGTH_MILLIMETERS
hass.config.units = IMPERIAL_SYSTEM hass.config.units = US_CUSTOMARY_SYSTEM
platform: WeatherPlatform = getattr(hass.components, "test.weather") platform: WeatherPlatform = getattr(hass.components, "test.weather")
platform.init(empty=True) platform.init(empty=True)