Remove unused OrderedEnum (#60392)

This commit is contained in:
Erik Montnemery 2021-11-26 11:10:39 +01:00 committed by GitHub
parent 249cac2901
commit 88068fa97f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 69 deletions

View File

@ -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.

View File

@ -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 = []