mirror of
https://github.com/esphome/esphome.git
synced 2025-10-29 22:24:26 +00:00
Feature/fix unit tests (#1129)
This commit is contained in:
@@ -104,7 +104,7 @@ def alphanumeric(value):
|
||||
raise Invalid("string value is None")
|
||||
value = str(value)
|
||||
if not value.isalnum():
|
||||
raise Invalid("string value is not alphanumeric")
|
||||
raise Invalid(f"{value} is not alphanumeric")
|
||||
return value
|
||||
|
||||
|
||||
|
||||
@@ -24,15 +24,18 @@ class EsphomeError(Exception):
|
||||
|
||||
class HexInt(int):
|
||||
def __str__(self):
|
||||
if 0 <= self <= 255:
|
||||
return f"0x{self:02X}"
|
||||
return f"0x{self:X}"
|
||||
value = self
|
||||
sign = "-" if value < 0 else ""
|
||||
value = abs(value)
|
||||
if 0 <= value <= 255:
|
||||
return f"{sign}0x{value:02X}"
|
||||
return f"{sign}0x{value:X}"
|
||||
|
||||
|
||||
class IPAddress:
|
||||
def __init__(self, *args):
|
||||
if len(args) != 4:
|
||||
raise ValueError("IPAddress must consist up 4 items")
|
||||
raise ValueError("IPAddress must consist of 4 items")
|
||||
self.args = args
|
||||
|
||||
def __str__(self):
|
||||
|
||||
Reference in New Issue
Block a user