Ejemplo n.º 1
0
def test_make_child_empty_with_values():
    parent = fromstring("<Root></Root>")
    tag = "Child"
    text = "Fail!"

    with raises(ValueError):
        make_child(parent, tag, text, empty=True)
Ejemplo n.º 2
0
def test_make_child_empty_with_values():
    parent = fromstring('<Root></Root>')
    tag = 'Child'
    text = 'Fail!'

    with raises(ValueError):
        child = make_child(parent, tag, text, empty=True)
Ejemplo n.º 3
0
def test_make_child_empty():
    parent = fromstring('<Root></Root>')
    tag = 'Child'
    text = 'Fail!'

    child = make_child(parent, tag, empty=True)
    assert child is not None
Ejemplo n.º 4
0
def test_make_child_none():
    parent = fromstring('<Root></Root>')
    tag = 'Child'

    child = make_child(parent, tag, required=False)

    assert child is None
Ejemplo n.º 5
0
def test_make_child_none():
    parent = fromstring("<Root></Root>")
    tag = "Child"

    child = make_child(parent, tag, required=False)

    assert child is None
Ejemplo n.º 6
0
def test_make_child():
    parent = fromstring('<Root></Root>')
    tag = 'Child'
    text = 'Papa!'
    attributes = {'id': '123', 'color': 'yellow'}

    child = make_child(parent, tag, text, attributes)

    assert child.tag == tag
    assert child.attrib == attributes
    assert child.text == text
Ejemplo n.º 7
0
def test_make_child():
    parent = fromstring("<Root></Root>")
    tag = "Child"
    text = "Papa!"
    attributes = {"id": "123", "color": "yellow"}

    child = make_child(parent, tag, text, attributes)

    assert child.tag == tag
    assert child.attrib == attributes
    assert child.text == text
Ejemplo n.º 8
0
def test_make_child_required_missing():
    parent = fromstring('<Root></Root>')
    tag = 'Child'

    with raises(ValueError):
        child = make_child(parent, tag)
Ejemplo n.º 9
0
def test_make_child_empty():
    parent = fromstring("<Root></Root>")
    tag = "Child"

    child = make_child(parent, tag, empty=True)
    assert child is not None
Ejemplo n.º 10
0
def test_make_child_required_missing():
    parent = fromstring("<Root></Root>")
    tag = "Child"

    with raises(ValueError):
        make_child(parent, tag)