# Path: infi/pyutils/method_map.py
# class MethodMap(object):
#     def __init__(self, decorator=Identity):
#         super(MethodMap, self).__init__()
#         self._map = {}
#         self._decorate = decorator
#     def registering(self, key):
#         return functools.partial(self.register, key)
#     def register(self, key, value):
#         self._map[key] = self._decorate(value)
#         return value
#     def __get__(self, instance, owner):
#         return Binder(self._map, instance)


import platform
from .test_utils import TestCase
from infi.pyutils.method_map import MethodMap
        class MyObj(object):
            METHODS = MethodMap()

            @METHODS.registering('a')
            def func_a(self):
                return 'a'
            @METHODS.registering('b')
            def func_b(self):
                return 'b'
            @METHODS.registering('c')
            @classmethod
            def func_c(cls):
                return 'c'
            @METHODS.registering('d')
            @staticmethod
            def func_d():
                return 'd'
        m = MyObj()
        self.assertEquals(m.METHODS.get('a')(), 'a')
        self.assertEquals(m.METHODS['a'](), 'a')
        self.assertEquals(m.METHODS.get('b')(), 'b')
        self.assertEquals(m.METHODS.get('bla', 2), 2)
        self.assertIsNone(m.METHODS.get('bfd', None))
        self.assertIsNone(m.METHODS.get('bfd'))
        self.assertEquals(m.METHODS['c'](), 'c')
        self.assertEquals(m.METHODS['d'](), 'd')
        with self.assertRaises(LookupError):
            m.METHODS['bbb']
    def test__method_map_old_style_class(self):
        class MyObj:

# Path: infi/pyutils/method_map.py
# class MethodMap(object):
#     def __init__(self, decorator=Identity):
#         super(MethodMap, self).__init__()
#         self._map = {}
#         self._decorate = decorator
#     def registering(self, key):
#         return functools.partial(self.register, key)
#     def register(self, key, value):
#         self._map[key] = self._decorate(value)
#         return value
#     def __get__(self, instance, owner):
#         return Binder(self._map, instance)


# Path: tests/test__method_map.py
import platform
from .test_utils import TestCase
from infi.pyutils.method_map import MethodMap

        class MyObj(object):
            METHODS = MethodMap()

            @METHODS.registering('a')
            def func_a(self):
                return 'a'
            @METHODS.registering('b')
            def func_b(self):
                return 'b'
            @METHODS.registering('c')
            @classmethod
            def func_c(cls):
                return 'c'
            @METHODS.registering('d')
            @staticmethod
            def func_d():
                return 'd'
        m = MyObj()
        self.assertEquals(m.METHODS.get('a')(), 'a')
        self.assertEquals(m.METHODS['a'](), 'a')
        self.assertEquals(m.METHODS.get('b')(), 'b')
        self.assertEquals(m.METHODS.get('bla', 2), 2)
        self.assertIsNone(m.METHODS.get('bfd', None))
        self.assertIsNone(m.METHODS.get('bfd'))
        self.assertEquals(m.METHODS['c'](), 'c')
        self.assertEquals(m.METHODS['d'](), 'd')
        with self.assertRaises(LookupError):
            m.METHODS['bbb']
    def test__method_map_old_style_class(self):
        class MyObj:

            METHODS = MethodMap()