summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_enum.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2020-09-16 20:01:00 (GMT)
committerGitHub <noreply@github.com>2020-09-16 20:01:00 (GMT)
commit7219e27087baaa8a5693b5bef1b1357bddbffa53 (patch)
tree9235d51826e2a14c26220a63a536085615604d16 /Lib/test/test_enum.py
parentfc23a9483ef0d7c98bea9f82392377d0b6ef7b18 (diff)
downloadcpython-7219e27087baaa8a5693b5bef1b1357bddbffa53.zip
cpython-7219e27087baaa8a5693b5bef1b1357bddbffa53.tar.gz
cpython-7219e27087baaa8a5693b5bef1b1357bddbffa53.tar.bz2
Enum: make `Flag` and `IntFlag` members iterable (GH-22221)
Diffstat (limited to 'Lib/test/test_enum.py')
-rw-r--r--Lib/test/test_enum.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index ebf7604..59789fb 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -2350,6 +2350,12 @@ class TestFlag(unittest.TestCase):
self.assertFalse(W in RX)
self.assertFalse(X in RW)
+ def test_member_iter(self):
+ Color = self.Color
+ self.assertEqual(list(Color.PURPLE), [Color.BLUE, Color.RED])
+ self.assertEqual(list(Color.BLUE), [Color.BLUE])
+ self.assertEqual(list(Color.GREEN), [Color.GREEN])
+
def test_auto_number(self):
class Color(Flag):
red = auto()
@@ -2805,6 +2811,12 @@ class TestIntFlag(unittest.TestCase):
with self.assertRaises(TypeError):
self.assertFalse('test' in RW)
+ def test_member_iter(self):
+ Color = self.Color
+ self.assertEqual(list(Color.PURPLE), [Color.BLUE, Color.RED])
+ self.assertEqual(list(Color.BLUE), [Color.BLUE])
+ self.assertEqual(list(Color.GREEN), [Color.GREEN])
+
def test_bool(self):
Perm = self.Perm
for f in Perm: