Use set literals in tests (#33669)
This commit is contained in:
parent
d267d674b9
commit
03dd92d51b
9 changed files with 24 additions and 28 deletions
|
@ -167,7 +167,7 @@ def assert_endpoint_capabilities(endpoint, *interfaces):
|
|||
them.
|
||||
"""
|
||||
capabilities = endpoint["capabilities"]
|
||||
supported = set(feature["interface"] for feature in capabilities)
|
||||
supported = {feature["interface"] for feature in capabilities}
|
||||
|
||||
assert supported == set(interfaces)
|
||||
return capabilities
|
||||
|
|
|
@ -181,7 +181,7 @@ async def test_discover_lights(hue_client):
|
|||
|
||||
result_json = await result.json()
|
||||
|
||||
devices = set(val["uniqueid"] for val in result_json.values())
|
||||
devices = {val["uniqueid"] for val in result_json.values()}
|
||||
|
||||
# Make sure the lights we added to the config are there
|
||||
assert "00:2f:d2:31:ce:c5:55:cc-ee" in devices # light.ceiling_lights
|
||||
|
|
|
@ -295,7 +295,7 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
|
||||
group_state = self.hass.states.get(f"{group.DOMAIN}.second_group")
|
||||
assert STATE_ON == group_state.state
|
||||
assert set((test_group.entity_id, "light.bowl")) == set(
|
||||
assert {test_group.entity_id, "light.bowl"} == set(
|
||||
group_state.attributes["entity_id"]
|
||||
)
|
||||
assert group_state.attributes.get(group.ATTR_AUTO) is None
|
||||
|
@ -304,7 +304,7 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
|
||||
group_state = self.hass.states.get(f"{group.DOMAIN}.test_group")
|
||||
assert STATE_UNKNOWN == group_state.state
|
||||
assert set(("sensor.happy", "hello.world")) == set(
|
||||
assert {"sensor.happy", "hello.world"} == set(
|
||||
group_state.attributes["entity_id"]
|
||||
)
|
||||
assert group_state.attributes.get(group.ATTR_AUTO) is None
|
||||
|
|
|
@ -23,8 +23,8 @@ async def test_bridge_setup(hass):
|
|||
|
||||
assert hue_bridge.api is api
|
||||
assert len(mock_forward.mock_calls) == 3
|
||||
forward_entries = set(c[1][1] for c in mock_forward.mock_calls)
|
||||
assert forward_entries == set(["light", "binary_sensor", "sensor"])
|
||||
forward_entries = {c[1][1] for c in mock_forward.mock_calls}
|
||||
assert forward_entries == {"light", "binary_sensor", "sensor"}
|
||||
|
||||
|
||||
async def test_bridge_setup_invalid_username(hass):
|
||||
|
|
|
@ -43,7 +43,7 @@ async def test_new_message(hass, mock_device_tracker_conf):
|
|||
topic = "/location/paulus"
|
||||
location = "work"
|
||||
|
||||
hass.config.components = set(["mqtt", "zone"])
|
||||
hass.config.components = {"mqtt", "zone"}
|
||||
assert await async_setup_component(
|
||||
hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "mqtt", "devices": {dev_id: topic}}}
|
||||
)
|
||||
|
@ -60,7 +60,7 @@ async def test_single_level_wildcard_topic(hass, mock_device_tracker_conf):
|
|||
topic = "/location/room/paulus"
|
||||
location = "work"
|
||||
|
||||
hass.config.components = set(["mqtt", "zone"])
|
||||
hass.config.components = {"mqtt", "zone"}
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
|
@ -79,7 +79,7 @@ async def test_multi_level_wildcard_topic(hass, mock_device_tracker_conf):
|
|||
topic = "/location/room/paulus"
|
||||
location = "work"
|
||||
|
||||
hass.config.components = set(["mqtt", "zone"])
|
||||
hass.config.components = {"mqtt", "zone"}
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
|
@ -98,7 +98,7 @@ async def test_single_level_wildcard_topic_not_matching(hass, mock_device_tracke
|
|||
topic = "/location/paulus"
|
||||
location = "work"
|
||||
|
||||
hass.config.components = set(["mqtt", "zone"])
|
||||
hass.config.components = {"mqtt", "zone"}
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
|
@ -117,7 +117,7 @@ async def test_multi_level_wildcard_topic_not_matching(hass, mock_device_tracker
|
|||
topic = "/somewhere/room/paulus"
|
||||
location = "work"
|
||||
|
||||
hass.config.components = set(["mqtt", "zone"])
|
||||
hass.config.components = {"mqtt", "zone"}
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
|
@ -138,7 +138,7 @@ async def test_matching_custom_payload_for_home_and_not_home(
|
|||
payload_home = "present"
|
||||
payload_not_home = "not present"
|
||||
|
||||
hass.config.components = set(["mqtt", "zone"])
|
||||
hass.config.components = {"mqtt", "zone"}
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
|
@ -171,7 +171,7 @@ async def test_not_matching_custom_payload_for_home_and_not_home(
|
|||
payload_not_home = "not present"
|
||||
payload_not_matching = "test"
|
||||
|
||||
hass.config.components = set(["mqtt", "zone"])
|
||||
hass.config.components = {"mqtt", "zone"}
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
|
@ -198,7 +198,7 @@ async def test_matching_source_type(hass, mock_device_tracker_conf):
|
|||
source_type = SOURCE_TYPE_BLUETOOTH
|
||||
location = "work"
|
||||
|
||||
hass.config.components = set(["mqtt", "zone"])
|
||||
hass.config.components = {"mqtt", "zone"}
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
DOMAIN,
|
||||
|
|
|
@ -115,13 +115,9 @@ async def test_devices(
|
|||
}
|
||||
|
||||
entity_map = device["entity_map"]
|
||||
assert zha_entity_ids == set(
|
||||
[
|
||||
e["entity_id"]
|
||||
for e in entity_map.values()
|
||||
if not e.get("default_match", False)
|
||||
]
|
||||
)
|
||||
assert zha_entity_ids == {
|
||||
e["entity_id"] for e in entity_map.values() if not e.get("default_match", False)
|
||||
}
|
||||
assert event_channels == set(device["event_channels"])
|
||||
|
||||
for call in _dispatch.call_args_list:
|
||||
|
@ -133,7 +129,7 @@ async def test_devices(
|
|||
assert entity_id is not None
|
||||
no_tail_id = NO_TAIL_ID.sub("", entity_map[key]["entity_id"])
|
||||
assert entity_id.startswith(no_tail_id)
|
||||
assert set([ch.name for ch in channels]) == set(entity_map[key]["channels"])
|
||||
assert {ch.name for ch in channels} == set(entity_map[key]["channels"])
|
||||
assert entity_cls.__name__ == entity_map[key]["entity_class"]
|
||||
|
||||
|
||||
|
@ -281,7 +277,7 @@ async def test_discover_endpoint(device_info, channels_mock, hass):
|
|||
map_id = (comp, unique_id)
|
||||
assert map_id in device_info["entity_map"]
|
||||
entity_info = device_info["entity_map"][map_id]
|
||||
assert set([ch.name for ch in channels]) == set(entity_info["channels"])
|
||||
assert {ch.name for ch in channels} == set(entity_info["channels"])
|
||||
assert ent_cls.__name__ == entity_info["entity_class"]
|
||||
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ def test_match_rule_claim_channels_color(channel):
|
|||
|
||||
rule = registries.MatchRule(channel_names="on_off", aux_channels={"color", "level"})
|
||||
claimed = rule.claim_channels([ch_color, ch_level, ch_onoff])
|
||||
assert {"color", "level", "on_off"} == set([ch.name for ch in claimed])
|
||||
assert {"color", "level", "on_off"} == {ch.name for ch in claimed}
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
@ -253,7 +253,7 @@ def test_match_rule_claim_channels(rule, match, channel, channels):
|
|||
channels.append(ch_power)
|
||||
|
||||
claimed = rule.claim_channels(channels)
|
||||
assert match == set([ch.name for ch in claimed])
|
||||
assert match == {ch.name for ch in claimed}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
@ -15,7 +15,7 @@ def test_extract_domain_configs():
|
|||
"zone 100": None,
|
||||
}
|
||||
|
||||
assert set(["zone", "zone Hallo", "zone 100"]) == set(
|
||||
assert {"zone", "zone Hallo", "zone 100"} == set(
|
||||
helpers.extract_domain_configs(config, "zone")
|
||||
)
|
||||
|
||||
|
|
|
@ -920,7 +920,7 @@ class TestConfig(unittest.TestCase):
|
|||
with TemporaryDirectory() as tmp_dir:
|
||||
# The created dir is in /tmp. This is a symlink on OS X
|
||||
# causing this test to fail unless we resolve path first.
|
||||
self.config.whitelist_external_dirs = set((os.path.realpath(tmp_dir),))
|
||||
self.config.whitelist_external_dirs = {os.path.realpath(tmp_dir)}
|
||||
|
||||
test_file = os.path.join(tmp_dir, "test.jpg")
|
||||
with open(test_file, "w") as tmp_file:
|
||||
|
@ -930,7 +930,7 @@ class TestConfig(unittest.TestCase):
|
|||
for path in valid:
|
||||
assert self.config.is_allowed_path(path)
|
||||
|
||||
self.config.whitelist_external_dirs = set(("/home", "/var"))
|
||||
self.config.whitelist_external_dirs = {"/home", "/var"}
|
||||
|
||||
unvalid = [
|
||||
"/hass/config/secure",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue