Exemple #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)
Exemple #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)
Exemple #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
Exemple #4
0
def test_make_child_none():
    parent = fromstring('<Root></Root>')
    tag = 'Child'

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

    assert child is None
Exemple #5
0
def test_make_child_none():
    parent = fromstring("<Root></Root>")
    tag = "Child"

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

    assert child is None
Exemple #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
Exemple #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
Exemple #8
0
def test_make_child_required_missing():
    parent = fromstring('<Root></Root>')
    tag = 'Child'

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

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