Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #6
0
def test_call_macro_ast(arg):
    def f(x: AST):
        return x

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