Example #1
0
def test_source(obj):
    _obj = source._wrap(obj)
    assert _obj(1.57) == obj(1.57)
    src = source.importable(obj, alias='_f')
    exec src in globals(), locals()
    assert _f(1.57) == obj(1.57)
    name = source.getname(obj)
    assert name == obj.__name__ or src.split("=", 1)[0].strip()
Example #2
0
def test_source(obj):
    _obj = source._wrap(obj)
    assert _obj(1.57) == obj(1.57)
    src = source.importable(obj, alias='_f')
    exec src in globals(), locals()
    assert _f(1.57) == obj(1.57)
    name = source.getname(obj)
    assert name == obj.__name__ or src.split("=",1)[0].strip()
Example #3
0
def run_source(obj):
    _obj = source._wrap(obj)
    assert _obj(1.57) == obj(1.57)
    src = source.importable(obj, alias='_f')
    # LEEK: for 3.x, locals may not be modified
    # (see https://docs.python.org/3.6/library/functions.html#locals)
    #
    my_locals = locals()
    exec(src, globals(), my_locals)
    assert my_locals["_f"](1.57) == obj(1.57)
    name = source.getname(obj)
    assert name == obj.__name__ or src.split("=", 1)[0].strip()
Example #4
0
def run_source(obj):
    _obj = source._wrap(obj)
    assert _obj(1.57) == obj(1.57)
    src = source.importable(obj, alias='_f')
    # LEEK: for 3.x, locals may not be modified
    # (see https://docs.python.org/3.6/library/functions.html#locals)
    #
    my_locals = locals()
    exec(src, globals(), my_locals)
    assert my_locals["_f"](1.57) == obj(1.57)
    name = source.getname(obj)
    assert name == obj.__name__ or src.split("=",1)[0].strip()
Example #5
0
 def __get_source(self, func):
     """Fetches source of the function"""
     hashf = hash(func)
     if hashf not in self.__sourcesHM:
         self.__sourcesHM[hashf] = importable(func)
     return self.__sourcesHM[hashf]
Example #6
0
File: pp.py Project: bsipocz/ppft
 def __get_source(self, func):
     """Fetches source of the function"""
     hashf = hash(func)
     if hashf not in self.__sourcesHM:
         self.__sourcesHM[hashf] = importable(func)
     return self.__sourcesHM[hashf]