diff options
author | Brennan D Baraban <34765317+bdbaraban@users.noreply.github.com> | 2019-03-03 22:09:11 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-03-03 22:09:11 (GMT) |
commit | 8b914d2767acba3a9e78f1dacdc2d61dbfd7e304 (patch) | |
tree | a06002f1635e1b5d312451509075fb3ea9cb03aa /Lib/test | |
parent | 8b50400fbe607ef558d6c0033efa697c99417507 (diff) | |
download | cpython-8b914d2767acba3a9e78f1dacdc2d61dbfd7e304.zip cpython-8b914d2767acba3a9e78f1dacdc2d61dbfd7e304.tar.gz cpython-8b914d2767acba3a9e78f1dacdc2d61dbfd7e304.tar.bz2 |
bpo-35899: Fix Enum handling of empty and weird strings (GH-11891)
Co-authored-by: Maxwell <maxwellpxt@gmail.com>
Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
https://bugs.python.org/issue35899
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_enum.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py index 99fc850..770decf 100644 --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -2730,6 +2730,23 @@ class TestIntFlag(unittest.TestCase): self.assertEqual(256, len(seen), 'too many composite members created') +class TestEmptyAndNonLatinStrings(unittest.TestCase): + + def test_empty_string(self): + with self.assertRaises(ValueError): + empty_abc = Enum('empty_abc', ('', 'B', 'C')) + + def test_non_latin_character_string(self): + greek_abc = Enum('greek_abc', ('\u03B1', 'B', 'C')) + item = getattr(greek_abc, '\u03B1') + self.assertEqual(item.value, 1) + + def test_non_latin_number_string(self): + hebrew_123 = Enum('hebrew_123', ('\u05D0', '2', '3')) + item = getattr(hebrew_123, '\u05D0') + self.assertEqual(item.value, 1) + + class TestUnique(unittest.TestCase): def test_unique_clean(self): |