#NEWLINE# def test_namespace_manager( self ) : #NEWLINE# #INDENT# xml = '<?xml version="1.0" encoding="UTF-8"?>\n            <a:foo\n                xmlns:a="http://example/test" xmlns:b="http://example2/test2">\n                <a:cat />\n                <b:dog />\n                <a:mouse><a:bat /></a:mouse>\n            </a:foo>\n        ' #NEWLINE# root = parse_xml_from_string ( xml ) #NEWLINE# manager = XmlNamespaceManager ( ) #NEWLINE# manager . add_namespace ( 'http://example/test' ) #NEWLINE# tags = [ ] #NEWLINE# for element in manager . iterate_children ( root ) : #NEWLINE# #INDENT# tags . append ( element . tag ) #NEWLINE# #UNINDENT# expected_tags = [ '{http://example/test}cat' , '{http://example/test}mouse' ] #NEWLINE# self . assertEqual ( tags , expected_tags ) #NEWLINE# manager . add_namespace ( 'http://example2/test2' ) #NEWLINE# tags = [ ] #NEWLINE# for element in manager . iterate_children ( root ) : #NEWLINE# #INDENT# tags . append ( element . tag ) #NEWLINE# #UNINDENT# expected_tags = [ '{http://example/test}cat' , '{http://example2/test2}dog' , '{http://example/test}mouse' ] #NEWLINE# self . assertEqual ( tags , expected_tags ) #NEWLINE# manager = XmlNamespaceManager ( ) #NEWLINE# manager . add_namespace ( 'http://example2/test2' ) #NEWLINE# tags = [ ] #NEWLINE# for element in manager . iterate_children ( root ) : #NEWLINE# #INDENT# tags . append ( element . tag ) #NEWLINE# #UNINDENT# expected_tags = [ '{http://example2/test2}dog' ] #NEWLINE# self . assertEqual ( tags , tags )