def test_append_to_element_appends_list_elements_to_tree():
    tree = etree.Element('root')
    data = ['John', 'Jane']
    result = append_to_element(tree, data, item_tag='user')
    assert b'<root><user>John</user><user>Jane</user></root>' == etree.tostring(
        result)
def test_append_to_element_appends_dictionary_elements_to_tree():
    tree = etree.Element('root')
    data = dict(name='John', age=7320)
    result = append_to_element(tree, data)
    assert b'<root><name>John</name><age>7320</age></root>' == etree.tostring(
        result)
def test_append_to_element_sets_text_given_doc_is_string():
    tree = etree.Element('root')
    result = append_to_element(tree, 'Hello Bilbo')
    assert 'Hello Bilbo' == result.text
def test_append_to_element_sets_text_converted_to_str_given_doc_is_int():
    tree = etree.Element('root')
    result = append_to_element(tree, 23)
    assert '23' == result.text
def test_append_to_element_returns_same_tree_object():
    tree = etree.Element('root')
    result = append_to_element(tree, 'Str')
    assert tree is result