Exemple #1
0
def test_divide():
    cursor = SampleCursor("""
        <root><item>prefix <cursor/> suffix</item></root>
    """)

    cursor.divide()

    assert cursor.root == semantic("""
        <root>
            <item>prefix </item> <item><cursor/> suffix</item>
        </root>
    """)
    assert cursor.node.tag == "cursor"
Exemple #2
0
def test_remove():
    cursor = SampleCursor("<root><a/><cursor/><c/></root>")
    cursor.remove()
    assert cursor.node.tag == "c"
Exemple #3
0
def test_stop():
    assert SampleCursor("<root/>").stop().node is None
Exemple #4
0
def test_bool_with_none():
    assert not SampleCursor("<root/>").next()
Exemple #5
0
def test_skip_to_ancestors_next():
    cursor = SampleCursor("""
        <root><a><cursor><c/></cursor></a><target/></root>
    """)
    assert cursor.skip().node.tag == "target"
Exemple #6
0
def test_rewind_to_parent():
    cursor = SampleCursor("""
        <root><a><target><cursor/></target></a></root>
    """)
    assert cursor.rewind().node.tag == "target"
Exemple #7
0
def test_skip_to_siblings():
    cursor = SampleCursor("""
        <root><cursor><b/></cursor><target/></root>
    """)
    assert cursor.skip().node.tag == "target"
Exemple #8
0
def test_next_to_ancestors_next():
    cursor = SampleCursor("""
        <root><a><b><cursor/></b></a><target/></root>
    """)
    assert cursor.next().node.tag == "target"
Exemple #9
0
def test_rewind_to_previous():
    cursor = SampleCursor("""
        <root><a/><target/><cursor/><d/></root>
    """)
    assert cursor.rewind().node.tag == "target"
Exemple #10
0
def test_next_to_siblings():
    cursor = SampleCursor("<root><cursor/><target/></root>")
    assert cursor.next().node.tag == "target"
Exemple #11
0
def test_next_to_children():
    cursor = SampleCursor("<root><target/></root>")
    assert cursor.next().node.tag == "target"
Exemple #12
0
def test_move_to():
    cursor = SampleCursor("<root><a/></root>")
    target = etree.SubElement(cursor.root, "target")
    assert cursor.move_to(target).node == target
Exemple #13
0
def test_root():
    cursor = SampleCursor("<root><a/></root>")
    cursor.next()
    assert cursor.root.tag == "root"
Exemple #14
0
def test_bool_with_node():
    assert SampleCursor("<root/>")