mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
[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:
parent
e52095a0c1
commit
5bb0538f6e
3 changed files with 28 additions and 6 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue