Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_enum.py @ 85717:54ddd1124df8
Close #18989: enum members will no longer overwrite other attributes, nor be overwritten by them.
| author | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| date | Sun, 15 Sep 2013 12:34:36 -0700 |
| parents | 24aa6f98fe25 |
| children | 353ced6ae182 |
line wrap: on
line diff
--- a/Lib/test/test_enum.py Sun Sep 15 09:37:27 2013 -0700 +++ b/Lib/test/test_enum.py Sun Sep 15 12:34:36 2013 -0700 @@ -228,6 +228,32 @@ ['FALL', 'ANOTHER_SPRING'], ) + def test_duplicate_name(self): + with self.assertRaises(TypeError): + class Color(Enum): + red = 1 + green = 2 + blue = 3 + red = 4 + + with self.assertRaises(TypeError): + class Color(Enum): + red = 1 + green = 2 + blue = 3 + def red(self): + return 'red' + + with self.assertRaises(TypeError): + class Color(Enum): + @property + def red(self): + return 'redder' + red = 1 + green = 2 + blue = 3 + + def test_enum_with_value_name(self): class Huh(Enum): name = 1 @@ -618,17 +644,6 @@ self.assertIsNot(type(whatever.really), whatever) self.assertEqual(whatever.this.really(), 'no, not that') - def test_overwrite_enums(self): - class Why(Enum): - question = 1 - answer = 2 - propisition = 3 - def question(self): - print(42) - self.assertIsNot(type(Why.question), Why) - self.assertNotIn(Why.question, Why._member_names_) - self.assertNotIn(Why.question, Why) - def test_wrong_inheritance_order(self): with self.assertRaises(TypeError): class Wrong(Enum, str):
