gh-125710: [Enum] fix hashable<->nonhashable comparisons for member values (GH-125735)

This commit is contained in:
Ethan Furman 2024-10-22 11:04:00 -07:00 committed by GitHub
parent 079875e395
commit aaed91cabc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 6 deletions

View file

@ -3460,6 +3460,13 @@ class TestSpecial(unittest.TestCase):
self.assertRaisesRegex(TypeError, '.int. object is not iterable', Enum, 'bad_enum', names=0)
self.assertRaisesRegex(TypeError, '.int. object is not iterable', Enum, 'bad_enum', 0, type=int)
def test_nonhashable_matches_hashable(self): # issue 125710
class Directions(Enum):
DOWN_ONLY = frozenset({"sc"})
UP_ONLY = frozenset({"cs"})
UNRESTRICTED = frozenset({"sc", "cs"})
self.assertIs(Directions({"sc"}), Directions.DOWN_ONLY)
class TestOrder(unittest.TestCase):
"test usage of the `_order_` attribute"