bpo-40025: Require _generate_next_value_ to be defined before members (GH-19098)

require `_generate_next_value_` to be defined before members
This commit is contained in:
Ethan Onstott 2020-04-28 13:20:55 -04:00 committed by GitHub
parent a42ca74fa3
commit d9a43e20fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 0 deletions

View file

@ -1751,6 +1751,16 @@ class TestEnum(unittest.TestCase):
self.assertEqual(Color.blue.value, 2)
self.assertEqual(Color.green.value, 3)
def test_auto_order(self):
with self.assertRaises(TypeError):
class Color(Enum):
red = auto()
green = auto()
blue = auto()
def _generate_next_value_(name, start, count, last):
return name
def test_duplicate_auto(self):
class Dupes(Enum):
first = primero = auto()