summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_enum.py
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2017-06-24 16:12:20 (GMT)
committerethanfurman <ethan@stoneleaf.us>2017-06-24 16:12:20 (GMT)
commit504b95047a8ada06ab630abce55ac2f85566ca37 (patch)
tree125a8999ed6afd64b792a5cd390c5b793d5ae992 /Lib/test/test_enum.py
parent0e1f9e8d3ea82262cbb9a403b70a884da5e6a6ac (diff)
downloadcpython-504b95047a8ada06ab630abce55ac2f85566ca37.zip
cpython-504b95047a8ada06ab630abce55ac2f85566ca37.tar.gz
cpython-504b95047a8ada06ab630abce55ac2f85566ca37.tar.bz2
[3.6] bpo-30616: Functional API of enum allows to create empty enums. (#2304) (#2324)
Diffstat (limited to 'Lib/test/test_enum.py')
-rw-r--r--Lib/test/test_enum.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index 13a89fc..eaea8ee 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -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