コード例 #1
0
def test_local_and_global_extraction():
    def a_closure():
        pass
    def fun():
        global_gets_called()
        a_closure()
    assert extract_functions(fun) == [a_closure, global_gets_called]
コード例 #2
0
def test_multiple_local_extraction():
    def local1():
        pass
    def local2():
        pass
    def fun():
        local1()
        local2()
    assert extract_functions(fun) == [local1, local2]
コード例 #3
0
def test_multiple_local_global_extraction():
    def local1():
        pass
    def local2():
        pass
    def fun():
        local1()
        local2()
        another_global()
        global_gets_called()
    assert extract_functions(fun) == [local1, local2, global_gets_called, another_global]
コード例 #4
0
def test_multiple_global_extraction():
    def fun():
        global_gets_called()
        another_global()
    assert extract_functions(fun) == [another_global, global_gets_called]
コード例 #5
0
def test_closure_fun_extraction():
    def closure_is_called():
        pass
    def fun():
       closure_is_called()
    assert extract_functions(fun) == [closure_is_called]
コード例 #6
0
def test_global_fun_extraction():
    def fun():
        global_gets_called()
    assert extract_functions(fun) == [global_gets_called]
コード例 #7
0
def test_builtin_fun_extraction():
    def fun():
        len([1, 2, 3])

    assert extract_functions(fun) == [len]