summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_enum.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2020-12-10 20:20:06 (GMT)
committerGitHub <noreply@github.com>2020-12-10 20:20:06 (GMT)
commitefb13be72cbf49edf591936fafb120fe1b7d59f7 (patch)
treeb35ffdea85d002cac1789a48c99287e5ca75a358 /Lib/test/test_enum.py
parent9fc571359af9320fddbe4aa2710a767f168c1707 (diff)
downloadcpython-efb13be72cbf49edf591936fafb120fe1b7d59f7.zip
cpython-efb13be72cbf49edf591936fafb120fe1b7d59f7.tar.gz
cpython-efb13be72cbf49edf591936fafb120fe1b7d59f7.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_enum.py')
-rw-r--r--Lib/test/test_enum.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index 7ca54e9..f245eb6 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -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):