コード例 #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_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]
コード例 #3
0
ファイル: test_references.py プロジェクト: rougeth/pycc
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]
コード例 #4
0
ファイル: test_references.py プロジェクト: kevinconway/pycc
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
ファイル: test_references.py プロジェクト: kevinconway/pycc
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]
コード例 #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
ファイル: test_references.py プロジェクト: rougeth/pycc
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
ファイル: test_references.py プロジェクト: kevinconway/pycc
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