Removal of extraneous parenthesis in tests (#33670)

* Removal of extraneous parenthesis

* Process review suggestions

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Franck Nijhof 2020-04-05 03:50:30 +02:00 committed by GitHub
parent 61b4d1e8de
commit 528c7f4871
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 25 deletions

View file

@ -23,7 +23,7 @@ class TestFileSensor(unittest.TestCase):
def setup_method(self, method): def setup_method(self, method):
"""Set up things to be run when tests are started.""" """Set up things to be run when tests are started."""
self.hass = get_test_home_assistant() 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): def teardown_method(self, method):
"""Stop everything that was started.""" """Stop everything that was started."""

View file

@ -28,7 +28,7 @@ class TestFolderSensor(unittest.TestCase):
self.hass = get_test_home_assistant() self.hass = get_test_home_assistant()
if not os.path.isdir(TEST_DIR): if not os.path.isdir(TEST_DIR):
os.mkdir(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): def teardown_method(self, method):
"""Stop everything that was started.""" """Stop everything that was started."""

View file

@ -20,7 +20,7 @@ async def test_invalid_path_setup(hass):
async def test_valid_path_setup(hass): async def test_valid_path_setup(hass):
"""Test that a valid path is setup.""" """Test that a valid path is setup."""
cwd = os.path.join(os.path.dirname(__file__)) 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"): with patch.object(folder_watcher, "Watcher"):
assert await async_setup_component( assert await async_setup_component(
hass, hass,

View file

@ -100,11 +100,9 @@ def test_valid_pairing_codes(pairing_code):
def get_flow_context(hass, result): def get_flow_context(hass, result):
"""Get the flow context from the result of async_init or async_configure.""" """Get the flow context from the result of async_init or async_configure."""
flow = next( flow = next(
( flow
flow for flow in hass.config_entries.flow.async_progress()
for flow in hass.config_entries.flow.async_progress() if flow["flow_id"] == result["flow_id"]
if flow["flow_id"] == result["flow_id"]
)
) )
return flow["context"] return flow["context"]

View file

@ -35,11 +35,9 @@ async def test_flow_works(hass, simple_mock_home):
assert result["errors"] == {"base": "press_the_button"} assert result["errors"] == {"base": "press_the_button"}
flow = next( flow = next(
( flow
flow for flow in hass.config_entries.flow.async_progress()
for flow in hass.config_entries.flow.async_progress() if flow["flow_id"] == result["flow_id"]
if flow["flow_id"] == result["flow_id"]
)
) )
assert flow["context"]["unique_id"] == "ABC123" assert flow["context"]["unique_id"] == "ABC123"

View file

@ -62,11 +62,9 @@ async def test_flow_works(hass):
assert result["step_id"] == "link" assert result["step_id"] == "link"
flow = next( flow = next(
( flow
flow for flow in hass.config_entries.flow.async_progress()
for flow in hass.config_entries.flow.async_progress() if flow["flow_id"] == result["flow_id"]
if flow["flow_id"] == result["flow_id"]
)
) )
assert flow["context"]["unique_id"] == "aabbccddeeff" 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["type"] == "form"
assert result["step_id"] == "link" assert result["step_id"] == "link"
flow = next( flow = next(
( flow
flow for flow in hass.config_entries.flow.async_progress()
for flow in hass.config_entries.flow.async_progress() if flow["flow_id"] == result["flow_id"]
if flow["flow_id"] == result["flow_id"]
)
) )
assert flow["context"]["unique_id"] == "beer" assert flow["context"]["unique_id"] == "beer"

View file

@ -54,13 +54,13 @@ def test_async_track_states(hass):
def test_call_to_component(hass): def test_call_to_component(hass):
"""Test calls to components state reproduction functions.""" """Test calls to components state reproduction functions."""
with patch( with patch(
("homeassistant.components.media_player.reproduce_state.async_reproduce_states") "homeassistant.components.media_player.reproduce_state.async_reproduce_states"
) as media_player_fun: ) as media_player_fun:
media_player_fun.return_value = asyncio.Future() media_player_fun.return_value = asyncio.Future()
media_player_fun.return_value.set_result(None) media_player_fun.return_value.set_result(None)
with patch( with patch(
("homeassistant.components.climate.reproduce_state.async_reproduce_states") "homeassistant.components.climate.reproduce_state.async_reproduce_states"
) as climate_fun: ) as climate_fun:
climate_fun.return_value = asyncio.Future() climate_fun.return_value = asyncio.Future()
climate_fun.return_value.set_result(None) climate_fun.return_value.set_result(None)