Skip to content

Commit

Permalink
Fix ruff issues in tests
Browse files Browse the repository at this point in the history
CI filters out tests because there were quite a few issues.
Of the 25 issues from ruff check, 20 were automatically fixable, so
the workload to clear them all up was not great.
  • Loading branch information
make-all committed Mar 1, 2024
1 parent d3ed3c5 commit f77da84
Show file tree
Hide file tree
Showing 15 changed files with 13 additions and 26 deletions.
2 changes: 1 addition & 1 deletion tests/devices/test_arlec_fan_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DIRECTION_REVERSE,
FanEntityFeature,
)
from homeassistant.components.light import ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ColorMode
from homeassistant.components.light import ColorMode

from ..const import ARLEC_FAN_LIGHT_PAYLOAD
from ..helpers import assert_device_properties_set
Expand Down
4 changes: 2 additions & 2 deletions tests/devices/test_beok_tr9b_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ def test_hvac_modes(self):
async def test_set_target_temperature_fails_outside_valid_range(self):
with self.assertRaisesRegex(
ValueError,
f"temperature \\(4.5\\) must be between 5.0 and 1000.0",
"temperature \\(4.5\\) must be between 5.0 and 1000.0",
):
await self.subject.async_set_target_temperature(4.5)
with self.assertRaisesRegex(
ValueError,
f"temperature \\(1001\\) must be between 5.0 and 1000.0",
"temperature \\(1001\\) must be between 5.0 and 1000.0",
):
await self.subject.async_set_target_temperature(1001)

Expand Down
1 change: 0 additions & 1 deletion tests/devices/test_inkbird_itc308_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from homeassistant.const import UnitOfTemperature, UnitOfTime

from ..const import INKBIRD_ITC308_THERMOSTAT_PAYLOAD
from ..helpers import assert_device_properties_set
from ..mixins.binary_sensor import MultiBinarySensorTests
from ..mixins.climate import TargetTemperatureTests
from ..mixins.number import MultiNumberTests
Expand Down
1 change: 0 additions & 1 deletion tests/devices/test_ir_remote_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from homeassistant.const import PERCENTAGE, UnitOfTemperature

from ..const import IR_REMOTE_SENSORS_PAYLOAD
from ..helpers import assert_device_properties_set
from ..mixins.sensor import MultiSensorTests
from .base_device_tests import TuyaDeviceTestCase

Expand Down
5 changes: 2 additions & 3 deletions tests/devices/test_jiahong_et72w_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from homeassistant.const import UnitOfEnergy, UnitOfTemperature

from ..const import JIAHONG_ET72W_PAYLOAD
from ..helpers import assert_device_properties_set
from ..mixins.climate import TargetTemperatureTests
from ..mixins.lock import BasicLockTests
from ..mixins.number import BasicNumberTests
Expand Down Expand Up @@ -202,12 +201,12 @@ def test_hvac_modes(self):
async def test_set_target_temperature_fails_outside_valid_range(self):
with self.assertRaisesRegex(
ValueError,
f"temperature \\(4.5\\) must be between 5.0 and 40.0",
"temperature \\(4.5\\) must be between 5.0 and 40.0",
):
await self.subject.async_set_target_temperature(4.5)
with self.assertRaisesRegex(
ValueError,
f"temperature \\(41\\) must be between 5.0 and 40.0",
"temperature \\(41\\) must be between 5.0 and 40.0",
):
await self.subject.async_set_target_temperature(41)

Expand Down
1 change: 0 additions & 1 deletion tests/devices/test_kyvol_e30_vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorDeviceClass
from homeassistant.components.vacuum import (
STATE_CLEANING,
STATE_DOCKED,
STATE_ERROR,
STATE_IDLE,
STATE_PAUSED,
Expand Down
1 change: 0 additions & 1 deletion tests/devices/test_lefant_m213_vacuum.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorDeviceClass
from homeassistant.components.vacuum import (
STATE_CLEANING,
STATE_DOCKED,
STATE_ERROR,
STATE_IDLE,
STATE_PAUSED,
Expand Down
1 change: 0 additions & 1 deletion tests/devices/test_simple_switch_with_timer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Tests for a simple switch with timer"""

from homeassistant.components.switch import SwitchDeviceClass
from homeassistant.const import UnitOfTime

from ..const import TIMED_SOCKET_PAYLOAD
Expand Down
1 change: 0 additions & 1 deletion tests/devices/test_simple_switch_with_timerv2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Tests for a simple switch with timer"""

from homeassistant.components.switch import SwitchDeviceClass
from homeassistant.const import UnitOfTime

from ..const import TIMED_SOCKETV2_PAYLOAD
Expand Down
1 change: 0 additions & 1 deletion tests/devices/test_tompd63lw_breaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfPower,
UnitOfTime,
)

from ..const import TOMPD63LW_SOCKET_PAYLOAD
Expand Down
2 changes: 0 additions & 2 deletions tests/devices/test_zx_g30_alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
AlarmControlPanelEntityFeature as Feature,
)
from homeassistant.const import (
STATE_ALARM_ARMED_AWAY,
STATE_ALARM_ARMED_HOME,
STATE_ALARM_DISARMED,
)

Expand Down
8 changes: 4 additions & 4 deletions tests/mixins/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ def setUpMultiLights(self, lights):
self.multiLightDps = {}
self.multiLightOn = {}
self.multiLightOff = {}
for l in lights:
name = l["name"]
for light in lights:
name = light["name"]
subject = self.entities.get(name)
testdata = l.get("testdata", (True, False))
testdata = light.get("testdata", (True, False))
if subject is None:
raise AttributeError(f"No light for {name} found.")
self.multiLight[name] = subject
self.multiLightDps[name] = l.get("dps")
self.multiLightDps[name] = light.get("dps")
self.multiLightOn[name] = testdata[0]
self.multiLightOff[name] = testdata[1]

Expand Down
1 change: 0 additions & 1 deletion tests/mixins/lock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Mixins for testing locks
from homeassistant.components.lock import STATE_LOCKED, STATE_UNLOCKED

from ..helpers import assert_device_properties_set

Expand Down
2 changes: 0 additions & 2 deletions tests/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from homeassistant.const import EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP

from custom_components.tuya_local.device import TuyaLocalDevice
from custom_components.tuya_local.helpers.device_config import TuyaEntityConfig
from custom_components.tuya_local.switch import TuyaLocalSwitch

from .const import EUROM_600_HEATER_PAYLOAD

Expand Down
8 changes: 4 additions & 4 deletions tests/test_device_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def test_can_find_config_files(self):
self.assertTrue(found)

def dp_match(self, condition, accounted, unaccounted, known, required=False):
if type(condition) is str:
if isinstance(condition, str):
known.add(condition)
if condition in unaccounted:
unaccounted.remove(condition)
Expand Down Expand Up @@ -340,18 +340,18 @@ def xor_match(self, conditions, accounted, unaccounted, known, required):

if prior_match:
for c in conditions:
if type(c) is str:
if isinstance(c, str):
accounted.add(c)
elif "and" in c:
for c2 in c["and"]:
if type(c2) is str:
if isinstance(c2, str):
accounted.add(c2)

return prior_match or not required

def rule_broken_msg(self, rule):
msg = ""
if type(rule) is str:
if isinstance(rule, str):
return f"{msg} {rule}"
elif "and" in rule:
msg = f"{msg} all of ["
Expand Down

0 comments on commit f77da84

Please sign in to comment.