diff options
author | Ethan Furman <ethan@stoneleaf.us> | 2013-09-22 23:18:19 (GMT) |
---|---|---|
committer | Ethan Furman <ethan@stoneleaf.us> | 2013-09-22 23:18:19 (GMT) |
commit | 64a9972b40b8258a6e37498da6279f4e40a88e2d (patch) | |
tree | d87e479ab1d2dc8b8ea6f9603e614ce5d849fb98 /Lib/test/test_enum.py | |
parent | 0c47f34385e4b8f2136b372abd1d1994f6521473 (diff) | |
download | cpython-64a9972b40b8258a6e37498da6279f4e40a88e2d.zip cpython-64a9972b40b8258a6e37498da6279f4e40a88e2d.tar.gz cpython-64a9972b40b8258a6e37498da6279f4e40a88e2d.tar.bz2 |
Close #19025: Better error message when trying to delete an Enum member.
Also slight code reorg for PEP 8 guidelines.
Diffstat (limited to 'Lib/test/test_enum.py')
-rw-r--r-- | Lib/test/test_enum.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py index 65d0de7..d59c5e3 100644 --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -172,6 +172,27 @@ class TestEnum(unittest.TestCase): with self.assertRaises(AttributeError): Season.WINTER = 'really cold' + def test_attribute_deletion(self): + class Season(Enum): + SPRING = 1 + SUMMER = 2 + AUTUMN = 3 + WINTER = 4 + + def spam(cls): + pass + + self.assertTrue(hasattr(Season, 'spam')) + del Season.spam + self.assertFalse(hasattr(Season, 'spam')) + + with self.assertRaises(AttributeError): + del Season.SPRING + with self.assertRaises(AttributeError): + del Season.DRY + with self.assertRaises(AttributeError): + del Season.SPRING.name + def test_invalid_names(self): with self.assertRaises(ValueError): class Wrong(Enum): |