Skip to content

Commit

Permalink
Test graceful enumeration identity persitence
Browse files Browse the repository at this point in the history
  • Loading branch information
priitlatt committed Aug 30, 2024
1 parent c583c80 commit b00caae
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/models/enums/test_resource_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,12 @@ def test_context_manager(is_graceful_before):
with pytest.raises(ValueError):
MockEnum("invalid value")
assert ResourceEnumMeta.graceful_fallback is is_graceful_before


def test_graceful_fallback_identity():
ResourceEnumMeta.graceful_fallback = True
e1 = MockEnum("undefined-value")
e2 = MockEnum("undefined-value")
assert e1 is e2 # Enumerations with the same value should persist identity
assert e1 == e2 # Enumerations with the same value should be equal
assert e1.value == e2.value # And of course their values should also be equal

0 comments on commit b00caae

Please sign in to comment.