summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbwarsaw2007-03-21 21:31:59 +0000
committerbwarsaw2007-03-21 21:31:59 +0000
commitdaeb5dbf03fde77265e42392cae0913765423f94 (patch)
treef696e3eaaaca084c978b7b21df53e00738629ac3
parentcdefb7ba2792083a520f8dc40993a0f946ad3434 (diff)
downloadmailman-daeb5dbf03fde77265e42392cae0913765423f94.tar.gz
mailman-daeb5dbf03fde77265e42392cae0913765423f94.tar.zst
mailman-daeb5dbf03fde77265e42392cae0913765423f94.zip
-rw-r--r--Mailman/enum.py2
-rw-r--r--Mailman/testing/test_enum.py9
2 files changed, 9 insertions, 2 deletions
diff --git a/Mailman/enum.py b/Mailman/enum.py
index a42799f37..893e988ba 100644
--- a/Mailman/enum.py
+++ b/Mailman/enum.py
@@ -76,7 +76,7 @@ class EnumMetaclass(type):
def __iter__(cls):
for i in sorted(cls._enums):
- yield cls._enums[i]
+ yield getattr(cls, cls._enums[i])
def __getitem__(cls, i):
# i can be an integer or a string
diff --git a/Mailman/testing/test_enum.py b/Mailman/testing/test_enum.py
index 6f198df67..de6877afc 100644
--- a/Mailman/testing/test_enum.py
+++ b/Mailman/testing/test_enum.py
@@ -94,7 +94,6 @@ class TestEnum(unittest.TestCase):
eq(int(MoreColors.red), 1)
eq(int(OtherColors.blue), 2)
-
def test_enum_duplicates(self):
try:
class Bad(Enum):
@@ -109,6 +108,14 @@ class TestEnum(unittest.TestCase):
got_error = False
self.failUnless(got_error)
+ def test_enum_iteration(self):
+ eq = self.assertEqual
+ # Iteration sorts on the int value of the enum
+ values = [str(v) for v in MoreColors]
+ eq(values, ['red', 'green', 'blue', 'pink', 'cyan'])
+ values = [int(v) for v in MoreColors]
+ eq(values, [1, 2, 3, 4, 5])
+
def test_suite():