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

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

    assert child is None
Пример #5
0
def test_make_child_none():
    parent = fromstring("<Root></Root>")
    tag = "Child"

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

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

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

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