Example #1
0
def test_can_get_source_of_functions_from_exec():
    assert 'foo(x)' in inspect.getsource(
        source_exec_as_module(DEFINE_FOO_FUNCTION).foo
    )
Example #2
0
def test_exec_as_module_caches():
    assert (
        source_exec_as_module(DEFINE_FOO_FUNCTION) is
        source_exec_as_module(DEFINE_FOO_FUNCTION)
    )
Example #3
0
def test_exec_leaves_sys_path_unchanged():
    old_path = deepcopy(sys.path)
    source_exec_as_module('hello_world = 42')
    assert sys.path == old_path
Example #4
0
def test_can_call_self_recursively():
    source_exec_as_module(RECURSIVE).test_recurse()
Example #5
0
def test_exec_as_module_execs():
    m = source_exec_as_module(DEFINE_FOO_FUNCTION)
    assert m.foo(1) == 1
Example #6
0
def test_can_eval_as_source():
    assert source_exec_as_module('foo=1').foo == 1
Example #7
0
def test_caches():
    x = source_exec_as_module('foo=2')
    y = source_exec_as_module('foo=2')
    assert x is y
def test_exec_as_module_caches():
    assert source_exec_as_module(DEFINE_FOO_FUNCTION) is source_exec_as_module(
        DEFINE_FOO_FUNCTION)
def test_exec_leaves_sys_path_unchanged():
    old_path = deepcopy(sys.path)
    source_exec_as_module("hello_world = 42")
    assert sys.path == old_path
def test_exec_as_module_execs():
    m = source_exec_as_module(DEFINE_FOO_FUNCTION)
    assert m.foo(1) == 1
Example #11
0
def test_does_not_put_eval_directory_on_path():
    source_exec_as_module("hello = 'world'")
    assert eval_directory() not in sys.path
Example #12
0
def test_can_get_source_of_functions_from_exec():
    assert u'foo(x)' in inspect.getsource(
        source_exec_as_module(DEFINE_FOO_FUNCTION).foo)
def test_caches():
    x = source_exec_as_module("foo=2")
    y = source_exec_as_module("foo=2")
    assert x is y
def test_does_not_put_eval_directory_on_path():
    source_exec_as_module("hello = 'world'")
    assert eval_directory() not in sys.path