bpo-30616: Functional API of enum allows to create empty enums. (#2304)

* bpo-30616: Functional API of enum allows to create empty enums.

* Update NEWS

move addition to avoid conflict
This commit is contained in:
Dong-hee Na 2017-06-22 01:52:32 +09:00 committed by ethanfurman
parent 5ff7132313
commit dcc8ce44c7
3 changed files with 24 additions and 1 deletions

View file

@ -2291,6 +2291,26 @@ class TestIntFlag(unittest.TestCase):
self.assertIs(type(e), Perm)
def test_programatic_function_from_empty_list(self):
Perm = enum.IntFlag('Perm', [])
lst = list(Perm)
self.assertEqual(len(lst), len(Perm))
self.assertEqual(len(Perm), 0, Perm)
Thing = enum.Enum('Thing', [])
lst = list(Thing)
self.assertEqual(len(lst), len(Thing))
self.assertEqual(len(Thing), 0, Thing)
def test_programatic_function_from_empty_tuple(self):
Perm = enum.IntFlag('Perm', ())
lst = list(Perm)
self.assertEqual(len(lst), len(Perm))
self.assertEqual(len(Perm), 0, Perm)
Thing = enum.Enum('Thing', ())
self.assertEqual(len(lst), len(Thing))
self.assertEqual(len(Thing), 0, Thing)
def test_containment(self):
Perm = self.Perm
R, W, X = Perm