[prev in list] [next in list] [prev in thread] [next in thread]
List: mailman-cvs
Subject: [Mailman-checkins] SF.net SVN: mailman: [8173] trunk/mailman/Mailman
From: bwarsaw () users ! sourceforge ! net
Date: 2007-03-21 21:32:00
Message-ID: E1HU8PY-0008A0-RH () sc8-pr-svn1 ! sourceforge ! net
[Download RAW message or body]
Revision: 8173
http://svn.sourceforge.net/mailman/?rev=8173&view=rev
Author: bwarsaw
Date: 2007-03-21 14:31:59 -0700 (Wed, 21 Mar 2007)
Log Message:
-----------
Added a test case for the code that Tokio fixed for enums in r8164.
However, I also changed the semantics a bit to be closer to what I
wanted, namely that iteration returns the EnumValue objects, not the
string names of the attributes.
Modified Paths:
--------------
trunk/mailman/Mailman/enum.py
trunk/mailman/Mailman/testing/test_enum.py
Modified: trunk/mailman/Mailman/enum.py
===================================================================
--- trunk/mailman/Mailman/enum.py 2007-03-21 21:16:56 UTC (rev 8172)
+++ trunk/mailman/Mailman/enum.py 2007-03-21 21:31:59 UTC (rev 8173)
@@ -76,7 +76,7 @@
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
Modified: trunk/mailman/Mailman/testing/test_enum.py
===================================================================
--- trunk/mailman/Mailman/testing/test_enum.py 2007-03-21 21:16:56 UTC (rev 8172)
+++ trunk/mailman/Mailman/testing/test_enum.py 2007-03-21 21:31:59 UTC (rev 8173)
@@ -94,7 +94,6 @@
eq(int(MoreColors.red), 1)
eq(int(OtherColors.blue), 2)
-
def test_enum_duplicates(self):
try:
class Bad(Enum):
@@ -109,7 +108,15 @@
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():
suite = unittest.TestSuite()
This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site. _______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/mailman-cvs%40progressive-comp.com
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic