mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-27 08:19:45 +03:00
improve enum compare function
This commit is contained in:
parent
d728b84e48
commit
b7c7096d6b
|
@ -12,7 +12,7 @@ from .unmountedtype import UnmountedType
|
|||
def eq_enum(self, other):
|
||||
if isinstance(other, self.__class__):
|
||||
return self is other
|
||||
return self.value is other
|
||||
return self.value == other
|
||||
|
||||
|
||||
EnumType = type(PyEnum)
|
||||
|
|
|
@ -184,14 +184,19 @@ def test_enum_value_as_unmounted_argument():
|
|||
|
||||
|
||||
def test_enum_can_be_compared():
|
||||
class RGB(Enum):
|
||||
class MyEnum(Enum):
|
||||
RED = 1
|
||||
GREEN = 2
|
||||
BLUE = 3
|
||||
BIG_VALUE = 99999999999999
|
||||
|
||||
assert RGB.RED == 1
|
||||
assert RGB.GREEN == 2
|
||||
assert RGB.BLUE == 3
|
||||
assert MyEnum.RED == 1
|
||||
assert MyEnum.GREEN == 2
|
||||
assert MyEnum.BLUE == 3
|
||||
|
||||
assert id(big_value) != id(MyEnum.BIG_VALUE.value)
|
||||
big_value = 99999999999999
|
||||
assert MyEnum.BIG_VALUE == big_value
|
||||
|
||||
|
||||
def test_enum_can_be_initialzied():
|
||||
|
|
Loading…
Reference in New Issue
Block a user