#
# adjust the sunders
_order_ = classdict.pop('_order_', None)
+ _gnv = classdict.get('_generate_next_value_')
+ if _gnv is not None and type(_gnv) is not staticmethod:
+ _gnv = staticmethod(_gnv)
# convert to normal dict
classdict = dict(classdict.items())
+ if _gnv is not None:
+ classdict['_generate_next_value_'] = _gnv
#
# data type of member and the controlling Enum class
member_type, first_enum = metacls._get_mixins_(cls, bases)
first = auto()
self.NewSubEnum = NewSubEnum
#
+ class LazyGNV(self.enum_type):
+ def _generate_next_value_(name, start, last, values):
+ pass
+ self.LazyGNV = LazyGNV
+ #
+ class BusyGNV(self.enum_type):
+ @staticmethod
+ def _generate_next_value_(name, start, last, values):
+ pass
+ self.BusyGNV = BusyGNV
+ #
self.is_flag = False
self.names = ['first', 'second', 'third']
if issubclass(MainEnum, StrEnum):
Main = self.MainEnum
self.assertIs(Main(Main.first), Main.first)
+ def test_gnv_is_static(self):
+ lazy = self.LazyGNV
+ busy = self.BusyGNV
+ self.assertTrue(type(lazy.__dict__['_generate_next_value_']) is staticmethod)
+ self.assertTrue(type(busy.__dict__['_generate_next_value_']) is staticmethod)
+
def test_hash(self):
MainEnum = self.MainEnum
mapping = {}