mirror of
https://github.com/python/cpython.git
synced 2025-12-09 10:37:17 +00:00
gh-125710: [Enum] fix hashable<->nonhashable comparisons for member values (GH-125735)
This commit is contained in:
parent
079875e395
commit
aaed91cabc
3 changed files with 28 additions and 6 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue