mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Remove unused OrderedEnum (#60392)
This commit is contained in:
parent
249cac2901
commit
88068fa97f
@ -162,34 +162,6 @@ def get_random_string(length: int = 10) -> str:
|
||||
return "".join(generator.choice(source_chars) for _ in range(length))
|
||||
|
||||
|
||||
class OrderedEnum(enum.Enum):
|
||||
"""Taken from Python 3.4.0 docs."""
|
||||
|
||||
def __ge__(self, other: ENUM_T) -> bool:
|
||||
"""Return the greater than element."""
|
||||
if self.__class__ is other.__class__:
|
||||
return bool(self.value >= other.value)
|
||||
return NotImplemented
|
||||
|
||||
def __gt__(self, other: ENUM_T) -> bool:
|
||||
"""Return the greater element."""
|
||||
if self.__class__ is other.__class__:
|
||||
return bool(self.value > other.value)
|
||||
return NotImplemented
|
||||
|
||||
def __le__(self, other: ENUM_T) -> bool:
|
||||
"""Return the lower than element."""
|
||||
if self.__class__ is other.__class__:
|
||||
return bool(self.value <= other.value)
|
||||
return NotImplemented
|
||||
|
||||
def __lt__(self, other: ENUM_T) -> bool:
|
||||
"""Return the lower element."""
|
||||
if self.__class__ is other.__class__:
|
||||
return bool(self.value < other.value)
|
||||
return NotImplemented
|
||||
|
||||
|
||||
class Throttle:
|
||||
"""A class for throttling the execution of tasks.
|
||||
|
||||
|
@ -120,47 +120,6 @@ def test_ensure_unique_string():
|
||||
assert util.ensure_unique_string("Beer", ["Wine", "Soda"]) == "Beer"
|
||||
|
||||
|
||||
def test_ordered_enum():
|
||||
"""Test the ordered enum class."""
|
||||
|
||||
class TestEnum(util.OrderedEnum):
|
||||
"""Test enum that can be ordered."""
|
||||
|
||||
FIRST = 1
|
||||
SECOND = 2
|
||||
THIRD = 3
|
||||
|
||||
assert TestEnum.SECOND >= TestEnum.FIRST
|
||||
assert TestEnum.SECOND >= TestEnum.SECOND
|
||||
assert TestEnum.SECOND < TestEnum.THIRD
|
||||
|
||||
assert TestEnum.SECOND > TestEnum.FIRST
|
||||
assert TestEnum.SECOND <= TestEnum.SECOND
|
||||
assert TestEnum.SECOND <= TestEnum.THIRD
|
||||
|
||||
assert TestEnum.SECOND > TestEnum.FIRST
|
||||
assert TestEnum.SECOND <= TestEnum.SECOND
|
||||
assert TestEnum.SECOND <= TestEnum.THIRD
|
||||
|
||||
assert TestEnum.SECOND >= TestEnum.FIRST
|
||||
assert TestEnum.SECOND >= TestEnum.SECOND
|
||||
assert TestEnum.SECOND < TestEnum.THIRD
|
||||
|
||||
# Python will raise a TypeError if the <, <=, >, >= methods
|
||||
# raise a NotImplemented error.
|
||||
with pytest.raises(TypeError):
|
||||
TestEnum.FIRST < 1
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
TestEnum.FIRST <= 1
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
TestEnum.FIRST > 1
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
TestEnum.FIRST >= 1
|
||||
|
||||
|
||||
def test_throttle():
|
||||
"""Test the add cooldown decorator."""
|
||||
calls1 = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user