# Path: m2core/common/int_enum.py
# class M2CoreIntEnum(IntEnum):
#     @classmethod
#     def get(cls, member_value: int or str):
#         """
#         Returns enum member from `int` ID. If no member found - returns `None`
# 
#         :param member_value:
# 
#         :return: enum member or `None`
#         """
#         if type(member_value) is int:
#             try:
#                 return cls(member_value)
#             except ValueError:
#                 return None
#         elif type(member_value) is str:
#             for m in cls.all():
#                 if m.name == member_value:
#                     return m
#             return None
#         else:
#             raise AttributeError('You can load enum members only by `str` name or `int` value')
# 
#     @classmethod
#     def all(cls):
#         return [_ for _ in cls]


import unittest
from m2core.common.int_enum import M2CoreIntEnum
            SIX = 6
            SEVEN = 7
            EIGHT = 8
            NINE = 9
            TEN = 10
        
        self.sample_enum = SampleEnum
    
    def test_get_by_int(self):
        self.assertEqual(self.sample_enum.ONE, self.sample_enum.get(1))
        self.assertEqual(self.sample_enum.TWO, self.sample_enum.get(2))
        self.assertEqual(self.sample_enum.THREE, self.sample_enum.get(3))
        self.assertEqual(self.sample_enum.FOUR, self.sample_enum.get(4))
        self.assertEqual(self.sample_enum.FIVE, self.sample_enum.get(5))
        self.assertEqual(self.sample_enum.SIX, self.sample_enum.get(6))
        self.assertEqual(self.sample_enum.SEVEN, self.sample_enum.get(7))
        self.assertEqual(self.sample_enum.EIGHT, self.sample_enum.get(8))
        self.assertEqual(self.sample_enum.NINE, self.sample_enum.get(9))
        self.assertEqual(self.sample_enum.TEN, self.sample_enum.get(10))
        self.assertTrue(self.sample_enum.get(11) is None)
        self.assertTrue(self.sample_enum.get(-1) is None)

    def test_get_raises(self):
        with self.assertRaises(Exception):
            self.sample_enum.get(1.0)
        with self.assertRaises(Exception):
            self.sample_enum.get(1.1)
        with self.assertRaises(Exception):
            self.sample_enum.get(True)
        with self.assertRaises(Exception):

# Path: m2core/common/int_enum.py
# class M2CoreIntEnum(IntEnum):
#     @classmethod
#     def get(cls, member_value: int or str):
#         """
#         Returns enum member from `int` ID. If no member found - returns `None`
# 
#         :param member_value:
# 
#         :return: enum member or `None`
#         """
#         if type(member_value) is int:
#             try:
#                 return cls(member_value)
#             except ValueError:
#                 return None
#         elif type(member_value) is str:
#             for m in cls.all():
#                 if m.name == member_value:
#                     return m
#             return None
#         else:
#             raise AttributeError('You can load enum members only by `str` name or `int` value')
# 
#     @classmethod
#     def all(cls):
#         return [_ for _ in cls]


# Path: example/tests/core/m2core_int_enum_tests.py
import unittest
from m2core.common.int_enum import M2CoreIntEnum

            SIX = 6
            SEVEN = 7
            EIGHT = 8
            NINE = 9
            TEN = 10
        
        self.sample_enum = SampleEnum
    
    def test_get_by_int(self):
        self.assertEqual(self.sample_enum.ONE, self.sample_enum.get(1))
        self.assertEqual(self.sample_enum.TWO, self.sample_enum.get(2))
        self.assertEqual(self.sample_enum.THREE, self.sample_enum.get(3))
        self.assertEqual(self.sample_enum.FOUR, self.sample_enum.get(4))
        self.assertEqual(self.sample_enum.FIVE, self.sample_enum.get(5))
        self.assertEqual(self.sample_enum.SIX, self.sample_enum.get(6))
        self.assertEqual(self.sample_enum.SEVEN, self.sample_enum.get(7))
        self.assertEqual(self.sample_enum.EIGHT, self.sample_enum.get(8))
        self.assertEqual(self.sample_enum.NINE, self.sample_enum.get(9))
        self.assertEqual(self.sample_enum.TEN, self.sample_enum.get(10))
        self.assertTrue(self.sample_enum.get(11) is None)
        self.assertTrue(self.sample_enum.get(-1) is None)

    def test_get_raises(self):
        with self.assertRaises(Exception):
            self.sample_enum.get(1.0)
        with self.assertRaises(Exception):
            self.sample_enum.get(1.1)
        with self.assertRaises(Exception):
            self.sample_enum.get(True)
        with self.assertRaises(Exception):

            self.sample_enum.get(object)