mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
bpo-42385: [Enum] add _generate_next_value_
to StrEnum (GH-23735)
The default for auto() is to return an integer, which doesn't work for `StrEnum`. The new `_generate_next_value_` for `StrEnum` returns the member name, lower cased.
This commit is contained in:
parent
9fc571359a
commit
efb13be72c
4 changed files with 17 additions and 2 deletions
|
@ -2179,6 +2179,12 @@ class TestEnum(unittest.TestCase):
|
|||
self.assertEqual(Private._Private__corporal, 'Radar')
|
||||
self.assertEqual(Private._Private__major_, 'Hoolihan')
|
||||
|
||||
def test_strenum_auto(self):
|
||||
class Strings(StrEnum):
|
||||
ONE = auto()
|
||||
TWO = auto()
|
||||
self.assertEqual([Strings.ONE, Strings.TWO], ['one', 'two'])
|
||||
|
||||
|
||||
class TestOrder(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue