Esempio 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)
Esempio 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)
Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio n. 8
0
def test_make_child_required_missing():
    parent = fromstring('<Root></Root>')
    tag = 'Child'

    with raises(ValueError):
        child = make_child(parent, tag)
Esempio 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
Esempio n. 10
0
def test_make_child_required_missing():
    parent = fromstring("<Root></Root>")
    tag = "Child"

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