Exemplo n.º 1
0
def test_get_top_node(node):
    """Test that the root node can be retrieved from any node."""
    references.add_parent_references(node)
    references.add_sibling_references(node)

    assert references.get_top_node(node) is node
    assert references.get_top_node(node.targets[0]) is node
Exemplo n.º 2
0
def test_sibling_references(node):
    """Test that sibling references are added to child nodes."""
    references.add_sibling_references(node)

    assert node.targets[0].previous is None
    assert node.targets[0].next is node.value
    assert node.value.previous is node.targets[0]
Exemplo n.º 3
0
def test_sibling_references(node):

    references.add_sibling_references(node)

    assert node.targets[0].previous is None
    assert node.targets[0].next is node.value
    assert node.value.previous is node.targets[0]
Exemplo n.º 4
0
def test_get_top_node(node):
    """Test that the root node can be retrieved from any node."""
    references.add_parent_references(node)
    references.add_sibling_references(node)

    assert references.get_top_node(node) is node
    assert references.get_top_node(node.targets[0]) is node
Exemplo n.º 5
0
def test_sibling_references(node):
    """Test that sibling references are added to child nodes."""
    references.add_sibling_references(node)

    assert node.targets[0].previous is None
    assert node.targets[0].next is node.value
    assert node.value.previous is node.targets[0]
Exemplo n.º 6
0
def test_copy_location(node):
    """Test that references are preserved by the custom copy_location."""
    references.add_parent_references(node)
    references.add_sibling_references(node)

    original = node.targets[0]
    dupe = references.copy_location(
        ast.Name(id='y', ctx=ast.Store()),
        original,
    )

    assert dupe.parent is original.parent
    assert dupe.previous is original.previous
    assert dupe.next is original.next
Exemplo n.º 7
0
def test_copy_location(node):

    references.add_parent_references(node)
    references.add_sibling_references(node)

    original = node.targets[0]
    dupe = references.copy_location(
        ast.Name(id='y', ctx=ast.Store()),
        original,
    )

    assert dupe.parent is original.parent
    assert dupe.previous is original.previous
    assert dupe.next is original.next
Exemplo n.º 8
0
def test_copy_location(node):
    """Test that references are preserved by the custom copy_location."""
    references.add_parent_references(node)
    references.add_sibling_references(node)

    original = node.targets[0]
    dupe = references.copy_location(
        ast.Name(id='y', ctx=ast.Store()),
        original,
    )

    assert dupe.parent is original.parent
    assert dupe.previous is original.previous
    assert dupe.next is original.next