Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 6
0
def test_call_macro_ast(arg):
    def f(x: AST):
        return x

    rtn = call_macro(f, [arg], {}, None)
    assert isinstance(rtn, AST)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 9
0
def test_call_macro_ast(arg):
    def f(x : AST):
        return x
    rtn = call_macro(f, [arg], {}, None)
    assert isinstance(rtn, AST)
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)