Esempio 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
Esempio n. 2
0
def test_parent_references(node):
    """Test that parent references are added to child nodes."""
    references.add_parent_references(node)

    assert node.targets[0].parent is node
    assert node.value.parent is node
    assert node.parent is None
Esempio n. 3
0
def test_parent_references(node):

    references.add_parent_references(node)

    assert node.targets[0].parent is node
    assert node.value.parent is node
    assert node.parent is None
Esempio 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
Esempio n. 5
0
def test_parent_references(node):
    """Test that parent references are added to child nodes."""
    references.add_parent_references(node)

    assert node.targets[0].parent is node
    assert node.value.parent is node
    assert node.parent is None
Esempio 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
Esempio 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
Esempio 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