mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue26748: Enum classes should evaluate as True
This commit is contained in:
parent
b9869dfe35
commit
5de67b106a
2 changed files with 19 additions and 0 deletions
|
@ -257,6 +257,19 @@ class TestEnum(unittest.TestCase):
|
|||
with self.assertRaises(AttributeError):
|
||||
del Season.SPRING.name
|
||||
|
||||
def test_bool_of_class(self):
|
||||
class Empty(Enum):
|
||||
pass
|
||||
self.assertTrue(bool(Empty))
|
||||
|
||||
def test_bool_of_member(self):
|
||||
class Count(Enum):
|
||||
zero = 0
|
||||
one = 1
|
||||
two = 2
|
||||
for member in Count:
|
||||
self.assertTrue(bool(member))
|
||||
|
||||
def test_invalid_names(self):
|
||||
with self.assertRaises(ValueError):
|
||||
class Wrong(Enum):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue