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

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

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
This commit is contained in:
Miss Islington (bot) 2024-10-22 20:29:42 +02:00 committed by GitHub
parent e52095a0c1
commit 5bb0538f6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 6 deletions

View file

@ -3474,6 +3474,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"