Current Path : /compat/linux/proc/self/root/usr/local/lib/python2.5/test/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //compat/linux/proc/self/root/usr/local/lib/python2.5/test/test_xml_etree_c.pyc |
³ò h”Rc @ sÆ d d k Z d d k Z d d k l Z d d k l Z d Z d Z d „ Z d „ Z d d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z e d j o e ƒ n d S( iÿÿÿÿN( t test_support( t cElementTrees\ <body> <tag>text</tag> <tag /> <section> <tag>subtext</tag> </section> </body> sy <body xmlns="http://effbot.org/ns"> <tag>text</tag> <tag /> <section> <tag>subtext</tag> </section> </body> c C s d S( sD Import sanity. >>> from xml.etree import cElementTree N( ( ( ( s1 /usr/local/lib/python2.5/test/test_xml_etree_c.pyt sanity s c C s t | ƒ p | Gd GHn d S( Ns not callable( t callable( t method( ( s1 /usr/local/lib/python2.5/test/test_xml_etree_c.pyt check_method$ s c C sY d d k } | i ƒ } | i | ƒ } | o | i | | ƒ n | i | ƒ | i ƒ S( Niÿÿÿÿ( t StringIOt ElementTreet writet getvalue( t ETt elemt encodingR t filet tree( ( s1 /usr/local/lib/python2.5/test/test_xml_etree_c.pyt serialize( s c C s | i S( N( t tag( R ( ( s1 /usr/local/lib/python2.5/test/test_xml_etree_c.pyt summarize2 s c C s t t | ƒ S( N( t mapR ( t seq( ( s1 /usr/local/lib/python2.5/test/test_xml_etree_c.pyt summarize_list5 s c C s d S( s‹ Test element tree interface. >>> element = ET.Element("tag", key="value") >>> tree = ET.ElementTree(element) Make sure all standard element methods exist. >>> check_method(element.append) >>> check_method(element.insert) >>> check_method(element.remove) >>> check_method(element.getchildren) >>> check_method(element.find) >>> check_method(element.findall) >>> check_method(element.findtext) >>> check_method(element.clear) >>> check_method(element.get) >>> check_method(element.set) >>> check_method(element.keys) >>> check_method(element.items) >>> check_method(element.getiterator) Basic method sanity checks. >>> serialize(ET, element) # 1 '<tag key="value" />' >>> subelement = ET.Element("subtag") >>> element.append(subelement) >>> serialize(ET, element) # 2 '<tag key="value"><subtag /></tag>' >>> element.insert(0, subelement) >>> serialize(ET, element) # 3 '<tag key="value"><subtag /><subtag /></tag>' >>> element.remove(subelement) >>> serialize(ET, element) # 4 '<tag key="value"><subtag /></tag>' >>> element.remove(subelement) >>> serialize(ET, element) # 5 '<tag key="value" />' >>> element.remove(subelement) Traceback (most recent call last): ValueError: list.remove(x): x not in list >>> serialize(ET, element) # 6 '<tag key="value" />' N( ( ( ( s1 /usr/local/lib/python2.5/test/test_xml_etree_c.pyt interface8 s c C s d S( s+ Test find methods (including xpath syntax). >>> elem = ET.XML(SAMPLE_XML) >>> elem.find("tag").tag 'tag' >>> ET.ElementTree(elem).find("tag").tag 'tag' >>> elem.find("section/tag").tag 'tag' >>> ET.ElementTree(elem).find("section/tag").tag 'tag' >>> elem.findtext("tag") 'text' >>> elem.findtext("tog") >>> elem.findtext("tog", "default") 'default' >>> ET.ElementTree(elem).findtext("tag") 'text' >>> elem.findtext("section/tag") 'subtext' >>> ET.ElementTree(elem).findtext("section/tag") 'subtext' >>> summarize_list(elem.findall("tag")) ['tag', 'tag'] >>> summarize_list(elem.findall("*")) ['tag', 'tag', 'section'] >>> summarize_list(elem.findall(".//tag")) ['tag', 'tag', 'tag'] >>> summarize_list(elem.findall("section/tag")) ['tag'] >>> summarize_list(elem.findall("section//tag")) ['tag'] >>> summarize_list(elem.findall("section/*")) ['tag'] >>> summarize_list(elem.findall("section//*")) ['tag'] >>> summarize_list(elem.findall("section/.//*")) ['tag'] >>> summarize_list(elem.findall("*/*")) ['tag'] >>> summarize_list(elem.findall("*//*")) ['tag'] >>> summarize_list(elem.findall("*/tag")) ['tag'] >>> summarize_list(elem.findall("*/./tag")) ['tag'] >>> summarize_list(elem.findall("./tag")) ['tag', 'tag'] >>> summarize_list(elem.findall(".//tag")) ['tag', 'tag', 'tag'] >>> summarize_list(elem.findall("././tag")) ['tag', 'tag'] >>> summarize_list(ET.ElementTree(elem).findall("/tag")) ['tag', 'tag'] >>> summarize_list(ET.ElementTree(elem).findall("./tag")) ['tag', 'tag'] >>> elem = ET.XML(SAMPLE_XML_NS) >>> summarize_list(elem.findall("tag")) [] >>> summarize_list(elem.findall("{http://effbot.org/ns}tag")) ['{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag'] >>> summarize_list(elem.findall(".//{http://effbot.org/ns}tag")) ['{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag', '{http://effbot.org/ns}tag'] N( ( ( ( s1 /usr/local/lib/python2.5/test/test_xml_etree_c.pyt findg s c C s d S( sÀ >>> element = ET.XML("<html><body>text</body></html>") >>> ET.ElementTree(element).write(sys.stdout) <html><body>text</body></html> >>> element = ET.fromstring("<html><body>text</body></html>") >>> ET.ElementTree(element).write(sys.stdout) <html><body>text</body></html> >>> print ET.tostring(element) <html><body>text</body></html> >>> print ET.tostring(element, "ascii") <?xml version='1.0' encoding='ascii'?> <html><body>text</body></html> >>> _, ids = ET.XMLID("<html><body>text</body></html>") >>> len(ids) 0 >>> _, ids = ET.XMLID("<html><body id='body'>text</body></html>") >>> len(ids) 1 >>> ids["body"].tag 'body' N( ( ( ( s1 /usr/local/lib/python2.5/test/test_xml_etree_c.pyt parseliteralª s c C s t i d | ƒ d S( s× >>> check_encoding("ascii") >>> check_encoding("us-ascii") >>> check_encoding("iso-8859-1") >>> check_encoding("iso-8859-15") >>> check_encoding("cp437") >>> check_encoding("mac-roman") s* <?xml version='1.0' encoding='%s'?><xml />N( R t XML( R ( ( s1 /usr/local/lib/python2.5/test/test_xml_etree_c.pyt check_encoding s c C s d S( s¼ >>> bob = ET.TreeBuilder() >>> e = bob.data("data") >>> e = bob.start("tag", {}) >>> e = bob.end("tag") >>> e = bob.close() >>> serialize(ET, e) '<tag />' N( ( ( ( s1 /usr/local/lib/python2.5/test/test_xml_etree_c.pyt bug_1534630Ï s c C s' d d k l } t i | d t ƒd S( Niÿÿÿÿ( t test_xml_etree_ct verbosity( t testR R t run_doctestt True( R ( ( s1 /usr/local/lib/python2.5/test/test_xml_etree_c.pyt test_mainÚ s t __main__( t doctestt sysR R t xml.etreeR R t SAMPLE_XMLt SAMPLE_XML_NSR R t NoneR R R R R R R R R t __name__( ( ( s1 /usr/local/lib/python2.5/test/test_xml_etree_c.pys <module> s"