Example #1
0
def test_transformer_function_block_empty(patch, tree, magic):
    """
    Ensures that indented arguments are added back to the their original node
    """
    assert Transformer.function_block([]) == Tree('function_block', [])
    assert Transformer.function_block([0]) == Tree('function_block', [0])
    m = magic()
    m.data = 'some_block'
    assert Transformer.function_block([m]) == Tree('function_block', [m])
    assert Transformer.function_block([m, m]) == Tree('function_block', [m, m])
Example #2
0
def test_transformer_function_block(patch, tree, magic):
    """
    Ensures that indented arguments are added back to the their original node
    """
    function_block = magic()
    m = magic()
    block = magic()
    m.data = "indented_typed_arguments"
    m.find_data.return_value = [".indented.node."]
    r = Transformer.function_block([function_block, m, block])
    m.find_data.assert_called_with("typed_argument")
    function_block.children.append.assert_called_with(".indented.node.")
    assert r.data == "function_block"
    assert r.children == [function_block, Tree("nested_block", [block])]
Example #3
0
def test_transformer_function_block(patch, tree, magic):
    """
    Ensures that indented arguments are added back to the their original node
    """
    function_block = magic()
    m = magic()
    block = magic()
    m.data = 'indented_typed_arguments'
    m.find_data.return_value = ['.indented.node.']
    r = Transformer.function_block([function_block, m, block])
    m.find_data.assert_called_with('typed_argument')
    function_block.children.append.assert_called_with('.indented.node.')
    assert r.data == 'function_block'
    assert r.children == [function_block, Tree('nested_block', [block])]