diff --git a/setup.cfg b/setup.cfg index 93b0187a015..c05470737f9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,7 +5,7 @@ universal = 1 testpaths = tests [flake8] -exclude = .venv,.git,.tox,docs,www_static,tests,venv,bin,lib +exclude = .venv,.git,.tox,docs,www_static,venv,bin,lib [pep257] ignore = D203,D105 diff --git a/tests/components/automation/test_numeric_state.py b/tests/components/automation/test_numeric_state.py index 5d6a2c6596e..ebfc30f2c14 100644 --- a/tests/components/automation/test_numeric_state.py +++ b/tests/components/automation/test_numeric_state.py @@ -365,7 +365,7 @@ class TestAutomationNumericState(unittest.TestCase): self.hass.pool.block_till_done() self.assertEqual(0, len(self.calls)) - def test_if_fires_on_attribute_change_with_attribute_below_multiple_attributes(self): + def test_fires_on_attr_change_with_attribute_below_and_multiple_attr(self): self.assertTrue(automation.setup(self.hass, { automation.DOMAIN: { 'trigger': { @@ -380,7 +380,8 @@ class TestAutomationNumericState(unittest.TestCase): } })) # 9 is not below 10 - self.hass.states.set('test.entity', 'entity', {'test_attribute': 9, 'not_test_attribute': 11}) + self.hass.states.set('test.entity', 'entity', + {'test_attribute': 9, 'not_test_attribute': 11}) self.hass.pool.block_till_done() self.assertEqual(1, len(self.calls)) @@ -390,7 +391,8 @@ class TestAutomationNumericState(unittest.TestCase): 'trigger': { 'platform': 'numeric_state', 'entity_id': 'test.entity', - 'value_template': '{{ state.attributes.test_attribute[2] }}', + 'value_template': + '{{ state.attributes.test_attribute[2] }}', 'below': 10, }, 'action': { @@ -399,7 +401,8 @@ class TestAutomationNumericState(unittest.TestCase): } })) # 3 is below 10 - self.hass.states.set('test.entity', 'entity', {'test_attribute': [11, 15, 3]}) + self.hass.states.set('test.entity', 'entity', + {'test_attribute': [11, 15, 3]}) self.hass.pool.block_till_done() self.assertEqual(1, len(self.calls)) @@ -409,7 +412,8 @@ class TestAutomationNumericState(unittest.TestCase): 'trigger': { 'platform': 'numeric_state', 'entity_id': 'test.entity', - 'value_template': '{{ state.attributes.test_attribute | multiply(10) }}', + 'value_template': + '{{ state.attributes.test_attribute | multiply(10) }}', 'below': 10, }, 'action': { @@ -418,11 +422,12 @@ class TestAutomationNumericState(unittest.TestCase): } })) # 9 is below 10 - self.hass.states.set('test.entity', 'entity', {'test_attribute': '0.9'}) + self.hass.states.set('test.entity', 'entity', + {'test_attribute': '0.9'}) self.hass.pool.block_till_done() self.assertEqual(1, len(self.calls)) - def test_if_not_fires_on_attribute_change_with_attribute_not_below_multiple_attributes(self): + def test_not_fires_on_attr_change_with_attr_not_below_multiple_attr(self): self.assertTrue(automation.setup(self.hass, { automation.DOMAIN: { 'trigger': { @@ -437,7 +442,8 @@ class TestAutomationNumericState(unittest.TestCase): } })) # 11 is not below 10 - self.hass.states.set('test.entity', 'entity', {'test_attribute': 11, 'not_test_attribute': 9}) + self.hass.states.set('test.entity', 'entity', + {'test_attribute': 11, 'not_test_attribute': 9}) self.hass.pool.block_till_done() self.assertEqual(0, len(self.calls)) diff --git a/tests/components/automation/test_template.py b/tests/components/automation/test_template.py index 3ccd523af7b..09ec85cbf36 100644 --- a/tests/components/automation/test_template.py +++ b/tests/components/automation/test_template.py @@ -256,7 +256,8 @@ class TestAutomationTemplate(unittest.TestCase): automation.DOMAIN: { 'trigger': { 'platform': 'template', - 'value_template': '{{ not is_state("test.entity", "world") }}', + 'value_template': + '{{ not is_state("test.entity", "world") }}', }, 'action': { 'service': 'test.automation' diff --git a/tests/components/media_player/test_demo.py b/tests/components/media_player/test_demo.py index c67d5d47623..6565d49dd4e 100644 --- a/tests/components/media_player/test_demo.py +++ b/tests/components/media_player/test_demo.py @@ -114,7 +114,8 @@ class TestDemoMediaPlayer(unittest.TestCase): assert 0 < (mp.SUPPORT_PREVIOUS_TRACK & state.attributes.get('supported_media_commands')) - @patch('homeassistant.components.media_player.demo.DemoYoutubePlayer.media_seek') + @patch('homeassistant.components.media_player.demo.DemoYoutubePlayer.' + 'media_seek') def test_play_media(self, mock_seek): assert mp.setup(self.hass, {'media_player': {'platform': 'demo'}}) ent_id = 'media_player.living_room' diff --git a/tests/components/sensor/test_template.py b/tests/components/sensor/test_template.py index 26eb2c4b1a7..88c4e766aef 100644 --- a/tests/components/sensor/test_template.py +++ b/tests/components/sensor/test_template.py @@ -64,7 +64,7 @@ class TestTemplateSensor: 'sensors': { 'test_template_sensor': { 'value_template': - "It {{ states.sensor.test_state.attributes.missing }}." + "It {{ states.sensor.test_state.attributes.missing }}." } } } diff --git a/tests/components/test_proximity.py b/tests/components/test_proximity.py index c66b34a0acf..d75f131d2de 100644 --- a/tests/components/test_proximity.py +++ b/tests/components/test_proximity.py @@ -162,7 +162,8 @@ class TestProximity: self.hass.pool.block_till_done() state = self.hass.states.get('proximity.home') assert state.state == '0' - assert (state.attributes.get('nearest') == 'test1, test2') or (state.attributes.get('nearest') == 'test2, test1') + assert ((state.attributes.get('nearest') == 'test1, test2') or + (state.attributes.get('nearest') == 'test2, test1')) assert state.attributes.get('dir_of_travel') == 'arrived' def test_device_tracker_test1_away(self): @@ -447,7 +448,7 @@ class TestProximity: assert state.attributes.get('nearest') == 'test1' assert state.attributes.get('dir_of_travel') == 'unknown' - def test_device_tracker_test1_awayfurther_than_test2_first_test1_than_test2_than_test1(self): + def test_device_tracker_test1_awayfurther_test2_first(self): self.hass.states.set( 'device_tracker.test1', 'not_home', { diff --git a/tests/components/thermostat/test_honeywell.py b/tests/components/thermostat/test_honeywell.py index e0e3f1bd758..f27a318b8da 100644 --- a/tests/components/thermostat/test_honeywell.py +++ b/tests/components/thermostat/test_honeywell.py @@ -131,7 +131,6 @@ class TestHoneywell(unittest.TestCase): devices = [x[0][1].deviceid for x in result] self.assertEqual([mock.sentinel.loc2dev1], devices) - @mock.patch('evohomeclient.EvohomeClient') @mock.patch('homeassistant.components.thermostat.honeywell.' 'RoundThermostat') diff --git a/tests/helpers/test_event.py b/tests/helpers/test_event.py index d69d0f198f5..3f97684984f 100644 --- a/tests/helpers/test_event.py +++ b/tests/helpers/test_event.py @@ -7,13 +7,22 @@ Tests event helpers. # pylint: disable=protected-access,too-many-public-methods # pylint: disable=too-few-public-methods import unittest -from datetime import datetime +from datetime import datetime, timedelta from astral import Astral import homeassistant.core as ha -from homeassistant.helpers.event import * +from homeassistant.helpers.event import ( + track_point_in_utc_time, + track_point_in_time, + track_utc_time_change, + track_time_change, + track_state_change, + track_sunrise, + track_sunset, +) from homeassistant.components import sun +import homeassistant.util.dt as dt_util class TestEventHelpers(unittest.TestCase): diff --git a/tests/helpers/test_state.py b/tests/helpers/test_state.py index e11426e2f95..a19968d21ae 100644 --- a/tests/helpers/test_state.py +++ b/tests/helpers/test_state.py @@ -14,8 +14,8 @@ from homeassistant.const import SERVICE_TURN_ON from homeassistant.util import dt as dt_util from homeassistant.helpers import state from homeassistant.const import ( - STATE_OFF, STATE_OPEN, STATE_CLOSED, - STATE_LOCKED, STATE_UNLOCKED, STATE_UNKNOWN, + STATE_OPEN, STATE_CLOSED, + STATE_LOCKED, STATE_UNLOCKED, STATE_ON, STATE_OFF) from homeassistant.components.sun import (STATE_ABOVE_HORIZON, STATE_BELOW_HORIZON) diff --git a/tests/util/test_template.py b/tests/util/test_template.py index 314f6b887b7..32189f899a7 100644 --- a/tests/util/test_template.py +++ b/tests/util/test_template.py @@ -45,7 +45,9 @@ class TestUtilTemplate(unittest.TestCase): 'open10', template.render( self.hass, - '{% for state in states.sensor %}{{ state.state }}{% endfor %}')) + """ +{% for state in states.sensor %}{{ state.state }}{% endfor %} + """)) def test_rounding_value(self): self.hass.states.set('sensor.temperature', 12.78) @@ -63,7 +65,8 @@ class TestUtilTemplate(unittest.TestCase): '128', template.render( self.hass, - '{{ states.sensor.temperature.state | multiply(10) | round }}')) + '{{ states.sensor.temperature.state | multiply(10) | round }}' + )) def test_passing_vars_as_keywords(self): self.assertEqual( @@ -91,7 +94,7 @@ class TestUtilTemplate(unittest.TestCase): template.render_with_possible_json_value( self.hass, '{{ value_json', 'hello')) - def test_render_with_possible_json_value_with_template_error_error_value(self): + def test_render_with_possible_json_value_with_template_error_value(self): self.assertEqual( '-', template.render_with_possible_json_value( @@ -107,7 +110,9 @@ class TestUtilTemplate(unittest.TestCase): 'exists', template.render( self.hass, - '{% if states.test.object %}exists{% else %}not exists{% endif %}')) + """ +{% if states.test.object %}exists{% else %}not exists{% endif %} + """)) def test_is_state(self): self.hass.states.set('test.object', 'available') @@ -115,7 +120,9 @@ class TestUtilTemplate(unittest.TestCase): 'yes', template.render( self.hass, - '{% if is_state("test.object", "available") %}yes{% else %}no{% endif %}')) + """ +{% if is_state("test.object", "available") %}yes{% else %}no{% endif %} + """)) def test_is_state_attr(self): self.hass.states.set('test.object', 'available', {'mode': 'on'}) @@ -123,7 +130,9 @@ class TestUtilTemplate(unittest.TestCase): 'yes', template.render( self.hass, - '{% if is_state_attr("test.object", "mode", "on") %}yes{% else %}no{% endif %}')) + """ +{% if is_state_attr("test.object", "mode", "on") %}yes{% else %}no{% endif %} + """)) def test_states_function(self): self.hass.states.set('test.object', 'available')