Пример #1
0
def test_call_macro_ast_eval_statement():
    def f(x: ("ast", "eval")):
        return x

    try:
        call_macro(f, ["x = 5"], {}, None)
        assert False
    except SyntaxError:
        # It doesn't make sense to pass a statement to
        # something that expects to be evaled
        assert True
    else:
        assert False
Пример #2
0
def test_call_macro_ast_eval_statement():
    def f(x: ("ast", "eval")):
        return x

    try:
        rtn = call_macro(f, ["x = 5"], {}, None)
        assert False
    except SyntaxError:
        # It doesn't make sense to pass a statement to
        # something that expects to be evaled
        assert True
    else:
        assert False
Пример #3
0
def test_call_macro_raw_kwarg(arg):
    def f(x: str):
        return x

    rtn = call_macro(f, ['*', 'x=' + arg], {'x': 42, 'y': 0}, None)
    assert rtn == 42
Пример #4
0
def test_call_macro_raw_kwarg(arg):
    def f(x: str):
        return x

    rtn = call_macro(f, ["*", "x=" + arg], {"x": 42, "y": 0}, None)
    assert rtn == 42
Пример #5
0
def test_call_macro_eval(arg):
    def f(x: eval):
        return x

    rtn = call_macro(f, [arg], {"x": 42, "y": 0}, None)
    assert rtn == 42
Пример #6
0
def test_call_macro_ast(arg):
    def f(x: AST):
        return x

    rtn = call_macro(f, [arg], {}, None)
    assert isinstance(rtn, AST)
Пример #7
0
def test_call_macro_ast_exec_statement():
    def f(x: ("ast", "exec")):
        return x

    rtn = call_macro(f, ["x = 5"], {}, None)
    assert isinstance(rtn, Module)
Пример #8
0
def test_call_macro_str(arg):
    def f(x : str):
        return x
    rtn = call_macro(f, [arg], None, None)
    assert rtn is arg
Пример #9
0
def test_call_macro_ast(arg):
    def f(x : AST):
        return x
    rtn = call_macro(f, [arg], {}, None)
    assert isinstance(rtn, AST)
Пример #10
0
def test_call_macro_raw_kwarg(arg):
    def f(x: str):
        return x

    rtn = call_macro(f, ["*", "x=" + arg], {"x": 42, "y": 0}, None)
    assert rtn == 42
Пример #11
0
def test_call_macro_raw_kwargs(arg):
    def f(x: str):
        return x

    rtn = call_macro(f, ["*", '**{"x" :' + arg + "}"], {"x": 42, "y": 0}, None)
    assert rtn == 42
Пример #12
0
def test_call_macro_eval(arg):
    def f(x: eval):
        return x

    rtn = call_macro(f, [arg], {"x": 42, "y": 0}, None)
    assert rtn == 42
Пример #13
0
def test_call_macro_ast_exec_statement():
    def f(x: ("ast", "exec")):
        return x

    rtn = call_macro(f, ["x = 5"], {}, None)
    assert isinstance(rtn, Module)
Пример #14
0
def test_call_macro_ast_single_statement():
    def f(x: ("ast", "single")):
        return x

    rtn = call_macro(f, ["x = 5"], {}, None)
    assert isinstance(rtn, Interactive)
Пример #15
0
def test_call_macro_raw_kwargs(arg):
    def f(x: str):
        return x

    rtn = call_macro(f, ['*', '**{"x" :' + arg + '}'], {'x': 42, 'y': 0}, None)
    assert rtn == 42
Пример #16
0
def test_call_macro_code(arg):
    def f(x : compile):
        return x
    rtn = call_macro(f, [arg], {}, None)
    assert isinstance(rtn, types.CodeType)
Пример #17
0
def test_call_macro_ast_eval_expr():
    def f(x: ("ast", "eval")):
        return x

    rtn = call_macro(f, ["x == 5"], {}, None)
    assert isinstance(rtn, Expression)
Пример #18
0
def test_call_macro_eval(arg):
    def f(x : eval):
        return x
    rtn = call_macro(f, [arg], {'x': 42, 'y': 0}, None)
    assert rtn == 42
Пример #19
0
def test_call_macro_ast_single_statement():
    def f(x: ("ast", "single")):
        return x

    rtn = call_macro(f, ["x = 5"], {}, None)
    assert isinstance(rtn, Interactive)
Пример #20
0
def test_call_macro_exec(arg):
    def f(x : exec):
        return x
    rtn = call_macro(f, [arg], {'x': 42, 'y': 0}, None)
    assert rtn is None
Пример #21
0
def test_call_macro_str(arg):
    def f(x: str):
        return x

    rtn = call_macro(f, [arg], None, None)
    assert rtn is arg
Пример #22
0
def test_call_macro_raw_kwarg(arg):
    def f(x : str):
        return x
    rtn = call_macro(f, ['*', 'x=' + arg], {'x': 42, 'y': 0}, None)
    assert rtn == 42
Пример #23
0
def test_call_macro_code(arg):
    def f(x: compile):
        return x

    rtn = call_macro(f, [arg], {}, None)
    assert isinstance(rtn, types.CodeType)
Пример #24
0
def test_call_macro_raw_kwargs(arg):
    def f(x : str):
        return x
    rtn = call_macro(f, ['*', '**{"x" :' + arg + '}'], {'x': 42, 'y': 0}, None)
    assert rtn == 42
Пример #25
0
def test_call_macro_exec(arg):
    def f(x: exec):
        return x

    rtn = call_macro(f, [arg], {"x": 42, "y": 0}, None)
    assert rtn is None
Пример #26
0
def test_call_macro_eval(arg):
    def f(x: eval):
        return x

    rtn = call_macro(f, [arg], {'x': 42, 'y': 0}, None)
    assert rtn == 42
Пример #27
0
def test_call_macro_raw_kwargs(arg):
    def f(x: str):
        return x

    rtn = call_macro(f, ["*", '**{"x" :' + arg + "}"], {"x": 42, "y": 0}, None)
    assert rtn == 42
Пример #28
0
def test_call_macro_ast_eval_expr():
    def f(x: ("ast", "eval")):
        return x

    rtn = call_macro(f, ["x == 5"], {}, None)
    assert isinstance(rtn, Expression)