diff --git a/tests/components/androidtv_remote/test_media_player.py b/tests/components/androidtv_remote/test_media_player.py index ad7c049e32f..46678f18fd3 100644 --- a/tests/components/androidtv_remote/test_media_player.py +++ b/tests/components/androidtv_remote/test_media_player.py @@ -345,7 +345,7 @@ async def test_browse_media( ) response = await client.receive_json() assert response["success"] - assert { + assert response["result"] == { "title": "Applications", "media_class": "directory", "media_content_type": "apps", @@ -377,7 +377,7 @@ async def test_browse_media( "thumbnail": "", }, ], - } == response["result"] + } async def test_media_player_connection_closed( diff --git a/tests/components/automation/test_init.py b/tests/components/automation/test_init.py index 0c300540644..8bac0c15db9 100644 --- a/tests/components/automation/test_init.py +++ b/tests/components/automation/test_init.py @@ -178,7 +178,7 @@ async def test_service_specify_entity_id( hass.bus.async_fire("test_event") await hass.async_block_till_done() assert len(calls) == 1 - assert ["hello.world"] == calls[0].data.get(ATTR_ENTITY_ID) + assert calls[0].data.get(ATTR_ENTITY_ID) == ["hello.world"] async def test_service_specify_entity_id_list( @@ -202,7 +202,7 @@ async def test_service_specify_entity_id_list( hass.bus.async_fire("test_event") await hass.async_block_till_done() assert len(calls) == 1 - assert ["hello.world", "hello.world2"] == calls[0].data.get(ATTR_ENTITY_ID) + assert calls[0].data.get(ATTR_ENTITY_ID) == ["hello.world", "hello.world2"] async def test_two_triggers(hass: HomeAssistant, calls: list[ServiceCall]) -> None: @@ -1641,7 +1641,7 @@ async def test_automation_not_trigger_on_bootstrap(hass: HomeAssistant) -> None: await hass.async_block_till_done() assert len(calls) == 1 - assert ["hello.world"] == calls[0].data.get(ATTR_ENTITY_ID) + assert calls[0].data.get(ATTR_ENTITY_ID) == ["hello.world"] @pytest.mark.parametrize( diff --git a/tests/components/automation/test_recorder.py b/tests/components/automation/test_recorder.py index fc45e6aee5b..af3d0c41151 100644 --- a/tests/components/automation/test_recorder.py +++ b/tests/components/automation/test_recorder.py @@ -48,7 +48,7 @@ async def test_exclude_attributes( hass.bus.async_fire("test_event") await hass.async_block_till_done() assert len(calls) == 1 - assert ["hello.world"] == calls[0].data.get(ATTR_ENTITY_ID) + assert calls[0].data.get(ATTR_ENTITY_ID) == ["hello.world"] await async_wait_recording_done(hass) states = await hass.async_add_executor_job( diff --git a/tests/components/bayesian/test_binary_sensor.py b/tests/components/bayesian/test_binary_sensor.py index e4f646572cb..818e9bed909 100644 --- a/tests/components/bayesian/test_binary_sensor.py +++ b/tests/components/bayesian/test_binary_sensor.py @@ -718,17 +718,18 @@ async def test_observed_entities(hass: HomeAssistant) -> None: await hass.async_block_till_done() state = hass.states.get("binary_sensor.test_binary") - assert ["sensor.test_monitored"] == state.attributes.get( - "occurred_observation_entities" - ) + assert state.attributes.get("occurred_observation_entities") == [ + "sensor.test_monitored" + ] hass.states.async_set("sensor.test_monitored1", "on") await hass.async_block_till_done() state = hass.states.get("binary_sensor.test_binary") - assert ["sensor.test_monitored", "sensor.test_monitored1"] == sorted( - state.attributes.get("occurred_observation_entities") - ) + assert sorted(state.attributes.get("occurred_observation_entities")) == [ + "sensor.test_monitored", + "sensor.test_monitored1", + ] async def test_state_attributes_are_serializable(hass: HomeAssistant) -> None: @@ -785,9 +786,10 @@ async def test_state_attributes_are_serializable(hass: HomeAssistant) -> None: await hass.async_block_till_done() state = hass.states.get("binary_sensor.test_binary") - assert ["sensor.test_monitored", "sensor.test_monitored1"] == sorted( - state.attributes.get("occurred_observation_entities") - ) + assert sorted(state.attributes.get("occurred_observation_entities")) == [ + "sensor.test_monitored", + "sensor.test_monitored1", + ] for attrs in state.attributes.values(): json.dumps(attrs) diff --git a/tests/components/demo/test_notify.py b/tests/components/demo/test_notify.py index 4ebbfbdac04..e9aa97f3d06 100644 --- a/tests/components/demo/test_notify.py +++ b/tests/components/demo/test_notify.py @@ -81,6 +81,6 @@ async def test_calling_notify_from_script_loaded_from_yaml( await hass.services.async_call("script", "test") await hass.async_block_till_done() assert len(events) == 1 - assert { + assert events[0].data == { "message": "Test 123 4", - } == events[0].data + } diff --git a/tests/components/ecobee/test_climate.py b/tests/components/ecobee/test_climate.py index ae53132fe46..1c9dcec0ad2 100644 --- a/tests/components/ecobee/test_climate.py +++ b/tests/components/ecobee/test_climate.py @@ -195,7 +195,7 @@ async def test_hvac_mode(ecobee_fixture, thermostat) -> None: async def test_hvac_modes(thermostat) -> None: """Test operation list property.""" - assert ["heat_cool", "heat", "cool", "off"] == thermostat.hvac_modes + assert thermostat.hvac_modes == ["heat_cool", "heat", "cool", "off"] async def test_hvac_mode2(ecobee_fixture, thermostat) -> None: @@ -208,51 +208,51 @@ async def test_hvac_mode2(ecobee_fixture, thermostat) -> None: async def test_extra_state_attributes(ecobee_fixture, thermostat) -> None: """Test device state attributes property.""" ecobee_fixture["equipmentStatus"] = "heatPump2" - assert { + assert thermostat.extra_state_attributes == { "fan": "off", "climate_mode": "Climate1", "fan_min_on_time": 10, "equipment_running": "heatPump2", - } == thermostat.extra_state_attributes + } ecobee_fixture["equipmentStatus"] = "auxHeat2" - assert { + assert thermostat.extra_state_attributes == { "fan": "off", "climate_mode": "Climate1", "fan_min_on_time": 10, "equipment_running": "auxHeat2", - } == thermostat.extra_state_attributes + } ecobee_fixture["equipmentStatus"] = "compCool1" - assert { + assert thermostat.extra_state_attributes == { "fan": "off", "climate_mode": "Climate1", "fan_min_on_time": 10, "equipment_running": "compCool1", - } == thermostat.extra_state_attributes + } ecobee_fixture["equipmentStatus"] = "" - assert { + assert thermostat.extra_state_attributes == { "fan": "off", "climate_mode": "Climate1", "fan_min_on_time": 10, "equipment_running": "", - } == thermostat.extra_state_attributes + } ecobee_fixture["equipmentStatus"] = "Unknown" - assert { + assert thermostat.extra_state_attributes == { "fan": "off", "climate_mode": "Climate1", "fan_min_on_time": 10, "equipment_running": "Unknown", - } == thermostat.extra_state_attributes + } ecobee_fixture["program"]["currentClimateRef"] = "c2" - assert { + assert thermostat.extra_state_attributes == { "fan": "off", "climate_mode": "Climate2", "fan_min_on_time": 10, "equipment_running": "Unknown", - } == thermostat.extra_state_attributes + } async def test_is_aux_heat_on(hass: HomeAssistant) -> None: diff --git a/tests/components/filter/test_sensor.py b/tests/components/filter/test_sensor.py index 0ece61708f2..a9581b78f4e 100644 --- a/tests/components/filter/test_sensor.py +++ b/tests/components/filter/test_sensor.py @@ -467,7 +467,7 @@ def test_throttle(values: list[State]) -> None: new_state = filt.filter_state(state) if not filt.skip_processing: filtered.append(new_state) - assert [20, 21] == [f.state for f in filtered] + assert [f.state for f in filtered] == [20, 21] def test_time_throttle(values: list[State]) -> None: @@ -480,7 +480,7 @@ def test_time_throttle(values: list[State]) -> None: new_state = filt.filter_state(state) if not filt.skip_processing: filtered.append(new_state) - assert [20, 18, 22] == [f.state for f in filtered] + assert [f.state for f in filtered] == [20, 18, 22] def test_time_sma(values: list[State]) -> None: diff --git a/tests/components/group/test_init.py b/tests/components/group/test_init.py index 7434de74f63..bbbe22cba83 100644 --- a/tests/components/group/test_init.py +++ b/tests/components/group/test_init.py @@ -405,13 +405,13 @@ async def test_expand_entity_ids_does_not_return_duplicates( order=None, ) - assert ["light.bowl", "light.ceiling"] == sorted( + assert sorted( group.expand_entity_ids(hass, [test_group.entity_id, "light.Ceiling"]) - ) + ) == ["light.bowl", "light.ceiling"] - assert ["light.bowl", "light.ceiling"] == sorted( + assert sorted( group.expand_entity_ids(hass, ["light.bowl", test_group.entity_id]) - ) + ) == ["light.bowl", "light.ceiling"] async def test_expand_entity_ids_recursive(hass: HomeAssistant) -> None: @@ -439,7 +439,7 @@ async def test_expand_entity_ids_recursive(hass: HomeAssistant) -> None: async def test_expand_entity_ids_ignores_non_strings(hass: HomeAssistant) -> None: """Test that non string elements in lists are ignored.""" - assert [] == group.expand_entity_ids(hass, [5, True]) + assert group.expand_entity_ids(hass, [5, True]) == [] async def test_get_entity_ids(hass: HomeAssistant) -> None: @@ -460,9 +460,10 @@ async def test_get_entity_ids(hass: HomeAssistant) -> None: order=None, ) - assert ["light.bowl", "light.ceiling"] == sorted( - group.get_entity_ids(hass, test_group.entity_id) - ) + assert sorted(group.get_entity_ids(hass, test_group.entity_id)) == [ + "light.bowl", + "light.ceiling", + ] async def test_get_entity_ids_with_domain_filter(hass: HomeAssistant) -> None: @@ -482,19 +483,19 @@ async def test_get_entity_ids_with_domain_filter(hass: HomeAssistant) -> None: order=None, ) - assert ["switch.ac"] == group.get_entity_ids( + assert group.get_entity_ids( hass, mixed_group.entity_id, domain_filter="switch" - ) + ) == ["switch.ac"] async def test_get_entity_ids_with_non_existing_group_name(hass: HomeAssistant) -> None: """Test get_entity_ids with a non existing group.""" - assert [] == group.get_entity_ids(hass, "non_existing") + assert group.get_entity_ids(hass, "non_existing") == [] async def test_get_entity_ids_with_non_group_state(hass: HomeAssistant) -> None: """Test get_entity_ids with a non group state.""" - assert [] == group.get_entity_ids(hass, "switch.AC") + assert group.get_entity_ids(hass, "switch.AC") == [] async def test_group_being_init_before_first_tracked_state_is_set_to_on( @@ -620,12 +621,12 @@ async def test_expand_entity_ids_expands_nested_groups(hass: HomeAssistant) -> N order=None, ) - assert [ + assert sorted(group.expand_entity_ids(hass, ["group.group_of_groups"])) == [ "light.test_1", "light.test_2", "switch.test_1", "switch.test_2", - ] == sorted(group.expand_entity_ids(hass, ["group.group_of_groups"])) + ] async def test_set_assumed_state_based_on_tracked(hass: HomeAssistant) -> None: diff --git a/tests/components/mqtt/test_climate.py b/tests/components/mqtt/test_climate.py index c41a6366dfe..168fed6164e 100644 --- a/tests/components/mqtt/test_climate.py +++ b/tests/components/mqtt/test_climate.py @@ -179,14 +179,14 @@ async def test_get_hvac_modes( state = hass.states.get(ENTITY_CLIMATE) modes = state.attributes.get("hvac_modes") - assert [ + assert modes == [ HVACMode.AUTO, HVACMode.OFF, HVACMode.COOL, HVACMode.HEAT, HVACMode.DRY, HVACMode.FAN_ONLY, - ] == modes + ] @pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) diff --git a/tests/components/mqtt/test_water_heater.py b/tests/components/mqtt/test_water_heater.py index 849a1ac8785..86f8b227bd5 100644 --- a/tests/components/mqtt/test_water_heater.py +++ b/tests/components/mqtt/test_water_heater.py @@ -141,7 +141,7 @@ async def test_get_operation_modes( await mqtt_mock_entry() state = hass.states.get(ENTITY_WATER_HEATER) - assert [ + assert state.attributes.get("operation_list") == [ STATE_ECO, STATE_ELECTRIC, STATE_GAS, @@ -149,7 +149,7 @@ async def test_get_operation_modes( STATE_HIGH_DEMAND, STATE_PERFORMANCE, STATE_OFF, - ] == state.attributes.get("operation_list") + ] @pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) diff --git a/tests/components/universal/test_media_player.py b/tests/components/universal/test_media_player.py index 814fa34a125..527675a2208 100644 --- a/tests/components/universal/test_media_player.py +++ b/tests/components/universal/test_media_player.py @@ -325,10 +325,10 @@ async def test_config_bad_children(hass: HomeAssistant) -> None: config_bad_children = {"name": "test", "children": {}, "platform": "universal"} config_no_children = validate_config(config_no_children) - assert [] == config_no_children["children"] + assert config_no_children["children"] == [] config_bad_children = validate_config(config_bad_children) - assert [] == config_bad_children["children"] + assert config_bad_children["children"] == [] async def test_config_bad_commands(hass: HomeAssistant) -> None: @@ -336,7 +336,7 @@ async def test_config_bad_commands(hass: HomeAssistant) -> None: config = {"name": "test", "platform": "universal"} config = validate_config(config) - assert {} == config["commands"] + assert config["commands"] == {} async def test_config_bad_attributes(hass: HomeAssistant) -> None: @@ -344,7 +344,7 @@ async def test_config_bad_attributes(hass: HomeAssistant) -> None: config = {"name": "test", "platform": "universal"} config = validate_config(config) - assert {} == config["attributes"] + assert config["attributes"] == {} async def test_config_bad_key(hass: HomeAssistant) -> None: diff --git a/tests/helpers/test_config_validation.py b/tests/helpers/test_config_validation.py index 6df29eefaff..514eff94250 100644 --- a/tests/helpers/test_config_validation.py +++ b/tests/helpers/test_config_validation.py @@ -193,12 +193,12 @@ def test_platform_config() -> None: def test_ensure_list() -> None: """Test ensure_list.""" schema = vol.Schema(cv.ensure_list) - assert [] == schema(None) - assert [1] == schema(1) - assert [1] == schema([1]) - assert ["1"] == schema("1") - assert ["1"] == schema(["1"]) - assert [{"1": "2"}] == schema({"1": "2"}) + assert schema(None) == [] + assert schema(1) == [1] + assert schema([1]) == [1] + assert schema("1") == ["1"] + assert schema(["1"]) == ["1"] + assert schema({"1": "2"}) == [{"1": "2"}] def test_entity_id() -> None: @@ -965,7 +965,7 @@ def test_deprecated_with_replacement_key( assert ( "The 'mars' option is deprecated, please replace it with 'jupiter'" ) in caplog.text - assert {"jupiter": True} == output + assert output == {"jupiter": True} caplog.clear() assert len(caplog.records) == 0 @@ -1036,7 +1036,7 @@ def test_deprecated_with_replacement_key_and_default( assert ( "The 'mars' option is deprecated, please replace it with 'jupiter'" ) in caplog.text - assert {"jupiter": True} == output + assert output == {"jupiter": True} caplog.clear() assert len(caplog.records) == 0 @@ -1049,7 +1049,7 @@ def test_deprecated_with_replacement_key_and_default( test_data = {"venus": True} output = deprecated_schema(test_data.copy()) assert len(caplog.records) == 0 - assert {"venus": True, "jupiter": False} == output + assert output == {"venus": True, "jupiter": False} deprecated_schema_with_default = vol.All( vol.Schema( @@ -1068,7 +1068,7 @@ def test_deprecated_with_replacement_key_and_default( assert ( "The 'mars' option is deprecated, please replace it with 'jupiter'" ) in caplog.text - assert {"jupiter": True} == output + assert output == {"jupiter": True} def test_deprecated_cant_find_module() -> None: diff --git a/tests/helpers/test_entity_component.py b/tests/helpers/test_entity_component.py index 32ce740edb2..3f34305b39d 100644 --- a/tests/helpers/test_entity_component.py +++ b/tests/helpers/test_entity_component.py @@ -117,7 +117,7 @@ async def test_setup_does_discovery( await hass.async_block_till_done() assert mock_setup.called - assert ("platform_test", {}, {"msg": "discovery_info"}) == mock_setup.call_args[0] + assert mock_setup.call_args[0] == ("platform_test", {}, {"msg": "discovery_info"}) async def test_set_scan_interval_via_config(hass: HomeAssistant) -> None: @@ -191,9 +191,9 @@ async def test_extract_from_service_available_device(hass: HomeAssistant) -> Non call_1 = ServiceCall("test", "service", data={"entity_id": ENTITY_MATCH_ALL}) - assert ["test_domain.test_1", "test_domain.test_3"] == sorted( + assert sorted( ent.entity_id for ent in (await component.async_extract_from_service(call_1)) - ) + ) == ["test_domain.test_1", "test_domain.test_3"] call_2 = ServiceCall( "test", @@ -201,9 +201,9 @@ async def test_extract_from_service_available_device(hass: HomeAssistant) -> Non data={"entity_id": ["test_domain.test_3", "test_domain.test_4"]}, ) - assert ["test_domain.test_3"] == sorted( + assert sorted( ent.entity_id for ent in (await component.async_extract_from_service(call_2)) - ) + ) == ["test_domain.test_3"] async def test_platform_not_ready(hass: HomeAssistant) -> None: @@ -288,9 +288,9 @@ async def test_extract_from_service_filter_out_non_existing_entities( {"entity_id": ["test_domain.test_2", "test_domain.non_exist"]}, ) - assert ["test_domain.test_2"] == [ + assert [ ent.entity_id for ent in await component.async_extract_from_service(call) - ] + ] == ["test_domain.test_2"] async def test_extract_from_service_no_group_expand(hass: HomeAssistant) -> None: @@ -467,8 +467,11 @@ async def test_extract_all_omit_entity_id( call = ServiceCall("test", "service") - assert [] == sorted( - ent.entity_id for ent in await component.async_extract_from_service(call) + assert ( + sorted( + ent.entity_id for ent in await component.async_extract_from_service(call) + ) + == [] ) @@ -484,9 +487,9 @@ async def test_extract_all_use_match_all( call = ServiceCall("test", "service", {"entity_id": "all"}) - assert ["test_domain.test_1", "test_domain.test_2"] == sorted( + assert sorted( ent.entity_id for ent in await component.async_extract_from_service(call) - ) + ) == ["test_domain.test_1", "test_domain.test_2"] assert ( "Not passing an entity ID to a service to target all entities is deprecated" ) not in caplog.text diff --git a/tests/helpers/test_service.py b/tests/helpers/test_service.py index 9c5cda67725..b05cdf9c3ae 100644 --- a/tests/helpers/test_service.py +++ b/tests/helpers/test_service.py @@ -547,7 +547,7 @@ async def test_split_entity_string(hass: HomeAssistant) -> None: }, ) await hass.async_block_till_done() - assert ["hello.world", "sensor.beer"] == calls[-1].data.get("entity_id") + assert calls[-1].data.get("entity_id") == ["hello.world", "sensor.beer"] async def test_not_mutate_input(hass: HomeAssistant) -> None: @@ -1792,10 +1792,10 @@ async def test_extract_from_service_available_device(hass: HomeAssistant) -> Non call_1 = ServiceCall("test", "service", data={"entity_id": ENTITY_MATCH_ALL}) - assert ["test_domain.test_1", "test_domain.test_3"] == [ + assert [ ent.entity_id for ent in (await service.async_extract_entities(hass, entities, call_1)) - ] + ] == ["test_domain.test_1", "test_domain.test_3"] call_2 = ServiceCall( "test", @@ -1803,10 +1803,10 @@ async def test_extract_from_service_available_device(hass: HomeAssistant) -> Non data={"entity_id": ["test_domain.test_3", "test_domain.test_4"]}, ) - assert ["test_domain.test_3"] == [ + assert [ ent.entity_id for ent in (await service.async_extract_entities(hass, entities, call_2)) - ] + ] == ["test_domain.test_3"] assert ( await service.async_extract_entities( @@ -1830,10 +1830,10 @@ async def test_extract_from_service_empty_if_no_entity_id(hass: HomeAssistant) - ] call = ServiceCall("test", "service") - assert [] == [ + assert [ ent.entity_id for ent in (await service.async_extract_entities(hass, entities, call)) - ] + ] == [] async def test_extract_from_service_filter_out_non_existing_entities( @@ -1851,10 +1851,10 @@ async def test_extract_from_service_filter_out_non_existing_entities( {"entity_id": ["test_domain.test_2", "test_domain.non_exist"]}, ) - assert ["test_domain.test_2"] == [ + assert [ ent.entity_id for ent in (await service.async_extract_entities(hass, entities, call)) - ] + ] == ["test_domain.test_2"] async def test_extract_from_service_area_id( diff --git a/tests/test_config.py b/tests/test_config.py index 7f94317afea..748255fb205 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -490,9 +490,10 @@ def test_load_yaml_config_preserves_key_order() -> None: fp.write("hello: 2\n") fp.write("world: 1\n") - assert [("hello", 2), ("world", 1)] == list( - config_util.load_yaml_config_file(YAML_PATH).items() - ) + assert list(config_util.load_yaml_config_file(YAML_PATH).items()) == [ + ("hello", 2), + ("world", 1), + ] async def test_create_default_config_returns_none_if_write_error( diff --git a/tests/util/test_color.py b/tests/util/test_color.py index 53c243a1e4f..c8a5e0c8587 100644 --- a/tests/util/test_color.py +++ b/tests/util/test_color.py @@ -200,17 +200,17 @@ def test_color_hs_to_xy() -> None: def test_rgb_hex_to_rgb_list() -> None: """Test rgb_hex_to_rgb_list.""" - assert [255, 255, 255] == color_util.rgb_hex_to_rgb_list("ffffff") + assert color_util.rgb_hex_to_rgb_list("ffffff") == [255, 255, 255] - assert [0, 0, 0] == color_util.rgb_hex_to_rgb_list("000000") + assert color_util.rgb_hex_to_rgb_list("000000") == [0, 0, 0] - assert [255, 255, 255, 255] == color_util.rgb_hex_to_rgb_list("ffffffff") + assert color_util.rgb_hex_to_rgb_list("ffffffff") == [255, 255, 255, 255] - assert [0, 0, 0, 0] == color_util.rgb_hex_to_rgb_list("00000000") + assert color_util.rgb_hex_to_rgb_list("00000000") == [0, 0, 0, 0] - assert [51, 153, 255] == color_util.rgb_hex_to_rgb_list("3399ff") + assert color_util.rgb_hex_to_rgb_list("3399ff") == [51, 153, 255] - assert [51, 153, 255, 0] == color_util.rgb_hex_to_rgb_list("3399ff00") + assert color_util.rgb_hex_to_rgb_list("3399ff00") == [51, 153, 255, 0] def test_color_name_to_rgb_valid_name() -> None: diff --git a/tests/util/test_dt.py b/tests/util/test_dt.py index 6caca092517..0e8432bbb83 100644 --- a/tests/util/test_dt.py +++ b/tests/util/test_dt.py @@ -294,12 +294,12 @@ def test_parse_time_expression() -> None: assert list(range(0, 60, 5)) == dt_util.parse_time_expression("/5", 0, 59) - assert [1, 2, 3] == dt_util.parse_time_expression([2, 1, 3], 0, 59) + assert dt_util.parse_time_expression([2, 1, 3], 0, 59) == [1, 2, 3] assert list(range(24)) == dt_util.parse_time_expression("*", 0, 23) - assert [42] == dt_util.parse_time_expression(42, 0, 59) - assert [42] == dt_util.parse_time_expression("42", 0, 59) + assert dt_util.parse_time_expression(42, 0, 59) == [42] + assert dt_util.parse_time_expression("42", 0, 59) == [42] with pytest.raises(ValueError): dt_util.parse_time_expression(61, 0, 60)