示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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
示例#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