mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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:
parent
a42ca74fa3
commit
d9a43e20fa
5 changed files with 21 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue