示例#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
    )
示例#2
0
def test_exec_as_module_caches():
    assert (
        source_exec_as_module(DEFINE_FOO_FUNCTION) is
        source_exec_as_module(DEFINE_FOO_FUNCTION)
    )
示例#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
示例#4
0
def test_can_call_self_recursively():
    source_exec_as_module(RECURSIVE).test_recurse()
示例#5
0
def test_exec_as_module_execs():
    m = source_exec_as_module(DEFINE_FOO_FUNCTION)
    assert m.foo(1) == 1
示例#6
0
def test_can_eval_as_source():
    assert source_exec_as_module('foo=1').foo == 1
示例#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
示例#10
0
def test_exec_as_module_execs():
    m = source_exec_as_module(DEFINE_FOO_FUNCTION)
    assert m.foo(1) == 1
示例#11
0
def test_does_not_put_eval_directory_on_path():
    source_exec_as_module("hello = 'world'")
    assert eval_directory() not in sys.path
示例#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