<s> import atom <EOL> from lxml import etree <EOL> def test_element ( ) : <EOL> e = atom . Element ( name = "<STR_LIT:name>" , text = "<STR_LIT>" ) <EOL> tree = etree . fromstring ( str ( e ) ) <EOL> assert tree . attrib == { } <EOL> assert tree . tag == "<STR_LIT:name>" <EOL> assert tree . text == "<STR_LIT>" <EOL> assert ( not tree . getchildren ( ) ) <EOL> def test_element_with_attributes ( ) : <EOL> e = atom . Element ( name = "<STR_LIT:name>" , text = "<STR_LIT>" , age = <NUM_LIT> , sex = "<STR_LIT>" ) <EOL> tree = etree . fromstring ( str ( e ) ) <EOL> assert tree . attrib == { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> assert tree . text == "<STR_LIT>" <EOL> assert ( not tree . getchildren ( ) ) <EOL> def test_element_with_children ( ) : <EOL> child = atom . Element ( name = "<STR_LIT:name>" , text = "<STR_LIT>" ) <EOL> parent = atom . Element ( name = "<STR_LIT>" ) <EOL> parent . append_children ( child ) <EOL> tree = etree . fromstring ( str ( parent ) ) <EOL> assert tree . attrib == { } <EOL> assert tree . tag == "<STR_LIT>" <EOL> assert tree . text . strip ( ) == "<STR_LIT>" <EOL> assert len ( tree . getchildren ( ) ) == <NUM_LIT:1> <EOL> child_tree = tree . getchildren ( ) [ <NUM_LIT:0> ] <EOL> assert child_tree . attrib == { } <EOL> assert child_tree . tag == "<STR_LIT:name>" <EOL> assert child_tree . text . strip ( ) == "<STR_LIT>" <EOL> assert ( not child_tree . getchildren ( ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_element ( ) <EOL> test_element_with_attributes ( ) <EOL> test_element_with_children ( ) </s>
