Beispiel #1
0
def test_convert_macro_arg_eval(kind):
    # literals
    raw_arg = "42"
    arg = convert_macro_arg(raw_arg, kind, {}, None)
    assert arg is int
    # exprs
    raw_arg = "x + 41"
    arg = convert_macro_arg(raw_arg, kind, {}, {"x": 1})
    assert arg is int
Beispiel #2
0
def test_convert_macro_arg_eval(kind):
    # literals
    raw_arg = "42"
    arg = convert_macro_arg(raw_arg, kind, {}, None)
    assert arg is int
    # exprs
    raw_arg = "x + 41"
    arg = convert_macro_arg(raw_arg, kind, {}, {"x": 1})
    assert arg is int
Beispiel #3
0
def test_convert_macro_arg_eval(kind):
    # literals
    raw_arg = '42'
    arg = convert_macro_arg(raw_arg, kind, {}, None)
    assert arg is int
    # exprs
    raw_arg = 'x + 41'
    arg = convert_macro_arg(raw_arg, kind, {}, {'x': 1})
    assert arg is int
Beispiel #4
0
def test_convert_macro_arg_eval(kind):
    # literals
    raw_arg = '42'
    arg = convert_macro_arg(raw_arg, kind, {}, None)
    assert arg is int
    # exprs
    raw_arg = 'x + 41'
    arg = convert_macro_arg(raw_arg, kind, {}, {'x': 1})
    assert arg is int
Beispiel #5
0
def test_convert_macro_arg_exec(kind):
    # at global scope
    raw_arg = "def f(x, y):\n    return x + y"
    glbs = {}
    arg = convert_macro_arg(raw_arg, kind, glbs, None)
    assert arg is None
    assert "f" in glbs
    assert glbs["f"](1, 41) == 42
    # at local scope
    raw_arg = "def g(z):\n    return x + z\ny += 42"
    glbs = {"x": 40}
    locs = {"y": 1}
    arg = convert_macro_arg(raw_arg, kind, glbs, locs)
    assert arg is None
    assert "g" in locs
    assert locs["g"](1) == 41
    assert "y" in locs
    assert locs["y"] == 43
Beispiel #6
0
def test_convert_macro_arg_exec(kind):
    # at global scope
    raw_arg = 'def f(x, y):\n    return x + y'
    glbs = {}
    arg = convert_macro_arg(raw_arg, kind, glbs, None)
    assert arg is None
    assert 'f' in glbs
    assert glbs['f'](1, 41) == 42
    # at local scope
    raw_arg = 'def g(z):\n    return x + z\ny += 42'
    glbs = {'x': 40}
    locs = {'y': 1}
    arg = convert_macro_arg(raw_arg, kind, glbs, locs)
    assert arg is None
    assert 'g' in locs
    assert locs['g'](1) == 41
    assert 'y' in locs
    assert locs['y'] == 43
Beispiel #7
0
def test_convert_macro_arg_exec(kind):
    # at global scope
    raw_arg = 'def f(x, y):\n    return x + y'
    glbs = {}
    arg = convert_macro_arg(raw_arg, kind, glbs, None)
    assert arg is None
    assert 'f' in glbs
    assert glbs['f'](1, 41) == 42
    # at local scope
    raw_arg = 'def g(z):\n    return x + z\ny += 42'
    glbs = {'x': 40}
    locs = {'y': 1}
    arg = convert_macro_arg(raw_arg, kind, glbs, locs)
    assert arg is None
    assert 'g' in locs
    assert locs['g'](1) == 41
    assert 'y' in locs
    assert locs['y'] == 43
Beispiel #8
0
def test_convert_macro_arg_exec(kind):
    # at global scope
    raw_arg = "def f(x, y):\n    return x + y"
    glbs = {}
    arg = convert_macro_arg(raw_arg, kind, glbs, None)
    assert arg is None
    assert "f" in glbs
    assert glbs["f"](1, 41) == 42
    # at local scope
    raw_arg = "def g(z):\n    return x + z\ny += 42"
    glbs = {"x": 40}
    locs = {"y": 1}
    arg = convert_macro_arg(raw_arg, kind, glbs, locs)
    assert arg is None
    assert "g" in locs
    assert locs["g"](1) == 41
    assert "y" in locs
    assert locs["y"] == 43
Beispiel #9
0
def test_convert_macro_arg_code(kind):
    raw_arg = "42"
    arg = convert_macro_arg(raw_arg, kind, {}, None)
    assert isinstance(arg, types.CodeType)
Beispiel #10
0
def test_convert_macro_arg_ast(kind):
    raw_arg = "42"
    arg = convert_macro_arg(raw_arg, kind, {}, None)
    assert isinstance(arg, AST)
Beispiel #11
0
def test_convert_macro_arg_str(kind):
    raw_arg = "value"
    arg = convert_macro_arg(raw_arg, kind, None, None)
    assert arg is raw_arg
Beispiel #12
0
def test_convert_macro_arg_code(kind):
    raw_arg = '42'
    arg = convert_macro_arg(raw_arg, kind, {}, None)
    assert isinstance(arg, types.CodeType)
Beispiel #13
0
def test_convert_macro_arg_ast(kind):
    raw_arg = '42'
    arg = convert_macro_arg(raw_arg, kind, {}, None)
    assert isinstance(arg, AST)
Beispiel #14
0
def test_convert_macro_arg_str(kind):
    raw_arg = 'value'
    arg = convert_macro_arg(raw_arg, kind, None, None)
    assert arg is raw_arg