From 528c7f4871d5d6367004e7af03860eef763cc84f Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 5 Apr 2020 03:50:30 +0200 Subject: [PATCH] Removal of extraneous parenthesis in tests (#33670) * Removal of extraneous parenthesis * Process review suggestions * Apply suggestions from code review Co-authored-by: Martin Hjelmare --- tests/components/filesize/test_sensor.py | 2 +- tests/components/folder/test_sensor.py | 2 +- tests/components/folder_watcher/test_init.py | 2 +- .../homekit_controller/test_config_flow.py | 8 +++----- .../homematicip_cloud/test_config_flow.py | 8 +++----- tests/components/hue/test_config_flow.py | 16 ++++++---------- tests/helpers/test_state.py | 4 ++-- 7 files changed, 17 insertions(+), 25 deletions(-) diff --git a/tests/components/filesize/test_sensor.py b/tests/components/filesize/test_sensor.py index 29bd6a7fb1f..b2552f58c6a 100644 --- a/tests/components/filesize/test_sensor.py +++ b/tests/components/filesize/test_sensor.py @@ -23,7 +23,7 @@ class TestFileSensor(unittest.TestCase): def setup_method(self, method): """Set up things to be run when tests are started.""" self.hass = get_test_home_assistant() - self.hass.config.whitelist_external_dirs = set((TEST_DIR)) + self.hass.config.whitelist_external_dirs = {TEST_DIR} def teardown_method(self, method): """Stop everything that was started.""" diff --git a/tests/components/folder/test_sensor.py b/tests/components/folder/test_sensor.py index fc7de1f59c0..1c465c6a864 100644 --- a/tests/components/folder/test_sensor.py +++ b/tests/components/folder/test_sensor.py @@ -28,7 +28,7 @@ class TestFolderSensor(unittest.TestCase): self.hass = get_test_home_assistant() if not os.path.isdir(TEST_DIR): os.mkdir(TEST_DIR) - self.hass.config.whitelist_external_dirs = set((TEST_DIR)) + self.hass.config.whitelist_external_dirs = {TEST_DIR} def teardown_method(self, method): """Stop everything that was started.""" diff --git a/tests/components/folder_watcher/test_init.py b/tests/components/folder_watcher/test_init.py index db8bad3ba09..0702e64b4f8 100644 --- a/tests/components/folder_watcher/test_init.py +++ b/tests/components/folder_watcher/test_init.py @@ -20,7 +20,7 @@ async def test_invalid_path_setup(hass): async def test_valid_path_setup(hass): """Test that a valid path is setup.""" cwd = os.path.join(os.path.dirname(__file__)) - hass.config.whitelist_external_dirs = set((cwd)) + hass.config.whitelist_external_dirs = {cwd} with patch.object(folder_watcher, "Watcher"): assert await async_setup_component( hass, diff --git a/tests/components/homekit_controller/test_config_flow.py b/tests/components/homekit_controller/test_config_flow.py index 760c5f30436..19113eddf89 100644 --- a/tests/components/homekit_controller/test_config_flow.py +++ b/tests/components/homekit_controller/test_config_flow.py @@ -100,11 +100,9 @@ def test_valid_pairing_codes(pairing_code): def get_flow_context(hass, result): """Get the flow context from the result of async_init or async_configure.""" flow = next( - ( - flow - for flow in hass.config_entries.flow.async_progress() - if flow["flow_id"] == result["flow_id"] - ) + flow + for flow in hass.config_entries.flow.async_progress() + if flow["flow_id"] == result["flow_id"] ) return flow["context"] diff --git a/tests/components/homematicip_cloud/test_config_flow.py b/tests/components/homematicip_cloud/test_config_flow.py index ec13fc79536..e6e145fefba 100644 --- a/tests/components/homematicip_cloud/test_config_flow.py +++ b/tests/components/homematicip_cloud/test_config_flow.py @@ -35,11 +35,9 @@ async def test_flow_works(hass, simple_mock_home): assert result["errors"] == {"base": "press_the_button"} flow = next( - ( - flow - for flow in hass.config_entries.flow.async_progress() - if flow["flow_id"] == result["flow_id"] - ) + flow + for flow in hass.config_entries.flow.async_progress() + if flow["flow_id"] == result["flow_id"] ) assert flow["context"]["unique_id"] == "ABC123" diff --git a/tests/components/hue/test_config_flow.py b/tests/components/hue/test_config_flow.py index 1ca2eca664e..87d4dc2b887 100644 --- a/tests/components/hue/test_config_flow.py +++ b/tests/components/hue/test_config_flow.py @@ -62,11 +62,9 @@ async def test_flow_works(hass): assert result["step_id"] == "link" flow = next( - ( - flow - for flow in hass.config_entries.flow.async_progress() - if flow["flow_id"] == result["flow_id"] - ) + flow + for flow in hass.config_entries.flow.async_progress() + if flow["flow_id"] == result["flow_id"] ) assert flow["context"]["unique_id"] == "aabbccddeeff" @@ -168,11 +166,9 @@ async def test_flow_two_bridges_discovered_one_new(hass, aioclient_mock): assert result["type"] == "form" assert result["step_id"] == "link" flow = next( - ( - flow - for flow in hass.config_entries.flow.async_progress() - if flow["flow_id"] == result["flow_id"] - ) + flow + for flow in hass.config_entries.flow.async_progress() + if flow["flow_id"] == result["flow_id"] ) assert flow["context"]["unique_id"] == "beer" diff --git a/tests/helpers/test_state.py b/tests/helpers/test_state.py index 567bac65f5b..c2b89406f24 100644 --- a/tests/helpers/test_state.py +++ b/tests/helpers/test_state.py @@ -54,13 +54,13 @@ def test_async_track_states(hass): def test_call_to_component(hass): """Test calls to components state reproduction functions.""" with patch( - ("homeassistant.components.media_player.reproduce_state.async_reproduce_states") + "homeassistant.components.media_player.reproduce_state.async_reproduce_states" ) as media_player_fun: media_player_fun.return_value = asyncio.Future() media_player_fun.return_value.set_result(None) with patch( - ("homeassistant.components.climate.reproduce_state.async_reproduce_states") + "homeassistant.components.climate.reproduce_state.async_reproduce_states" ) as climate_fun: climate_fun.return_value = asyncio.Future() climate_fun.return_value.set_result(None)