diff --git a/homeassistant/util/__init__.py b/homeassistant/util/__init__.py index 81f1389b47c..b71fd8fa5e4 100644 --- a/homeassistant/util/__init__.py +++ b/homeassistant/util/__init__.py @@ -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. diff --git a/tests/util/test_init.py b/tests/util/test_init.py index 0634f3cb6cf..b2ede0c881b 100644 --- a/tests/util/test_init.py +++ b/tests/util/test_init.py @@ -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 = []