Commits

stoneleaf committed 0c66e1a

turned subclassing on for testing purposes

Comments (0)

Files changed (2)

             if issubclass(base, Enum):
                 obj_type = base.__mro__[1]  # (IntEnum, int, Enum, object)
                 # check for existing enumeration items in base
-                if base._enums:
-                    raise EnumError("cannot subclass an implemented Enum class")
+                #if base._enums:
+                #    raise EnumError("cannot subclass an implemented Enum class")
                 break
             obj_type = base
             break
         return result
 
     def __contains__(cls, enum_item):
+        "this needs a better method"
         if type(enum_item) is cls:
             return True
         return False
         '''Return the enum item matching `name`'''
         if name[:2] == name[-2:] == '__':
             raise AttributeError()
-        try:
-            return cls._enum_map[name]
-        except KeyError:
-            raise EnumError("%s is not a valid %s" % (name, cls.__name__))
+        for base in cls.__mro__:
+            if hasattr(base, '_enum_map') and name in base._enum_map:
+                return base._enum_map[name]
+        raise EnumError("%s is not a valid %s" % (name, cls.__name__))
 
     def __getitem__(cls, value):
         if value in cls._enums:
 from pickle import dumps, loads
 import unittest
 from ref435 import Enum, IntEnum, EnumError
+import sys
+
+print('Using Python', sys.version)
 
 # for pickle tests
 try:
             red = 1
             green = 2
             blue = 3
-        with self.assertRaises(EnumError):
-            class MoreColor(Color):
-                pass
+        #with self.assertRaises(EnumError):
+        class MoreColor(Color):
+            cyan = 4
+            magenta = 5
+            yellow = 6
+        self.assertTrue(MoreColor.red is Color.red)
+        self.assertTrue(MoreColor.yellow is MoreColor.yellow)
 
     def test_exclude_methods(self):
         class whatever(Enum):