示例#1
0
def test_preprocessor_flow_statement_no_expression(patch, magic, tree):
    """
    Ensures flow_statement ignores statements without inline expressions
    """
    patch.object(Preprocessor, 'replace_in_entity')
    statement = magic()
    statement.child.return_value = None
    statement.node.return_value = None
    tree.find_data.return_value = [statement]
    Preprocessor.flow_statement('statement', tree)
    assert Preprocessor.replace_in_entity.call_count == 0
示例#2
0
def test_preprocessor_flow_statement_rhs(patch, magic, tree):
    """
    Ensures flow_statement replaces inline expressions on the right hand-side
    of statements
    """
    patch.object(Preprocessor, 'replace_in_entity')
    statement = magic()
    statement.node.return_value = None
    tree.find_data.return_value = [statement]
    Preprocessor.flow_statement('statement', tree)
    args = (tree, statement, statement.child())
    Preprocessor.replace_in_entity.assert_called_with(*args)
示例#3
0
def test_preprocessor_flow_statement(patch, magic, tree):
    """
    Ensures flow_statement replaces inline expressions inside if statements
    """
    patch.object(Preprocessor, 'replace_in_entity')
    statement = magic()
    statement.child.return_value = None
    tree.find_data.return_value = [statement]
    Preprocessor.flow_statement('statement', tree)
    tree.find_data.assert_called_with('statement')
    statement.node.assert_called_with('entity.path.inline_expression')
    args = (tree, statement, statement.entity)
    Preprocessor.replace_in_entity.assert_called_with(*args)