mirror of
https://github.com/python/cpython.git
synced 2025-07-15 15:25:29 +00:00
Close #18924: Block naive attempts to change an Enum member.
This commit is contained in:
parent
96d848ace4
commit
f203f2d51d
2 changed files with 18 additions and 0 deletions
|
@ -152,6 +152,11 @@ class TestEnum(unittest.TestCase):
|
|||
with self.assertRaises(AttributeError):
|
||||
Season.SPRING.value = 2
|
||||
|
||||
def test_changing_member(self):
|
||||
Season = self.Season
|
||||
with self.assertRaises(AttributeError):
|
||||
Season.WINTER = 'really cold'
|
||||
|
||||
def test_invalid_names(self):
|
||||
with self.assertRaises(ValueError):
|
||||
class Wrong(Enum):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue