def make_mocked_method(cls):
    txt = (
        """class {}:
        def mocked_method(self):
            print(type(self))
            print(self.__dict__)
            print(self.__hidden)
    """
        .format(cls.__name__))
ns = {}
exec(txt, ns)
return ns[cls.__name__].mocked_method
Access private variables in injected method - python