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

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