Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion graphene/types/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
def eq_enum(self, other):
if isinstance(other, self.__class__):
return self is other
return self.value is other
if isinstance(other, PyEnum):
return NotImplemented
return self.value == other


def hash_enum(self):
Expand Down
12 changes: 12 additions & 0 deletions graphene/types/tests/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,3 +613,15 @@ def resolve_color(_, info):
results = schema.execute("query { color }")
assert not results.errors
assert results.data["color"] == RGB.description.name


def test_enum_value_equality():
class Kind(Enum):
FAVORABLE = "favorable"
UNFAVORABLE = "unfavorable"

# non-interned string to avoid identity matching
val = "".join(["favor", "able"])
assert Kind.FAVORABLE == val
assert Kind.FAVORABLE == "favorable"
assert Kind.FAVORABLE != "unfavorable"