Ñò
‘à"Ic           @   s  d  d k  Z  d  d k 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 h  Z d e d <d e d <d e d <d e d <d e d <d e d <d e d <d e d <d d d „ Z d  „  Z d! „  Z e d" j o e ƒ  n d S(#   iÿÿÿÿN(   t   test_supports\   
<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(   sš   
    Import sanity.

    >>> from xml.etree import ElementTree
    >>> from xml.etree import ElementInclude
    >>> from xml.etree import ElementPath
    N(    (    (    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.pyt   sanity   s    c         C   s   t  |  ƒ p |  Gd GHn d  S(   Ns   not callable(   t   callable(   t   method(    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.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(    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.pyt	   serialize+   s    c         C   s   |  i  S(   N(   t   tag(   R
   (    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.pyt	   summarize5   s    c         C   s   t  t |  ƒ S(   N(   t   mapR   (   t   seq(    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.pyt   summarize_list8   s    c           C   s   d S(   s¼  
    Test element tree interface.

    >>> from xml.etree import ElementTree as ET

    >>> 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(    (    (    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.pyt	   interface;   s    c           C   s   d S(   s\  
    Test find methods (including xpath syntax).

    >>> from xml.etree import ElementTree as ET

    >>> 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(    (    (    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.pyt   findl   s    c           C   s   d S(   sñ  

    >>> from xml.etree import ElementTree as ET

    >>> 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(    (    (    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.pyt   parseliteral±   s    c         C   s   |  i  d | ƒ d S(   s   
    >>> from xml.etree import ElementTree as ET

    >>> check_encoding(ET, "ascii")
    >>> check_encoding(ET, "us-ascii")
    >>> check_encoding(ET, "iso-8859-1")
    >>> check_encoding(ET, "iso-8859-15")
    >>> check_encoding(ET, "cp437")
    >>> check_encoding(ET, "mac-roman")
    s*   <?xml version='1.0' encoding='%s'?><xml />N(   t   XML(   R	   R   (    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.pyt   check_encodingÌ   s    s´   <?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>120 Mz is adequate for an average home user.</p>
  <xi:include href="disclaimer.xml"/>
</document>
s   C1.xmlsÐ   <?xml version='1.0'?>
<disclaimer>
  <p>The opinions represented herein represent those of the individual
  and should not be interpreted as official policy endorsed by this
  organization.</p>
</disclaimer>
s   disclaimer.xmls¶   <?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>This document has been accessed
  <xi:include href="count.txt" parse="text"/> times.</p>
</document>
s   C2.xmlt   324387s	   count.txtsÙ   <?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source of the "data.xml" resource:</p>
  <example><xi:include href="data.xml" parse="text"/></example>
</document>
s   C3.xmlsQ   <?xml version='1.0'?>
<data>
  <item><![CDATA[Brooks & Shields]]></item>
</data>
s   data.xmlsW  <?xml version='1.0'?>
<div xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="example.txt" parse="text">
    <xi:fallback>
      <xi:include href="fallback-example.txt" parse="text">
        <xi:fallback><a href="mailto:bob@example.org">Report error</a></xi:fallback>
      </xi:include>
    </xi:fallback>
  </xi:include>
</div>
s   C5.xmls”   <?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>Example.</p>
  <xi:include href="samples/simple.xml"/>
</document>
s   default.xmlt   xmlc         C   s\   y t  |  } Wn t j
 o t d ƒ ‚ n X| d j o d d k l } | | ƒ S| S(   Ns   resource not foundR   iÿÿÿÿ(   R   (   t   XINCLUDEt   KeyErrort   IOErrort   xml.etree.ElementTreeR   (   t   hreft   parseR   t   dataR   (    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.pyt   xinclude_loader  s    c           C   s   d S(   sn  
    Basic inclusion example (XInclude C.1)

    >>> from xml.etree import ElementTree as ET
    >>> from xml.etree import ElementInclude

    >>> document = xinclude_loader("C1.xml")
    >>> ElementInclude.include(document, xinclude_loader)
    >>> print serialize(ET, document) # C1
    <document>
      <p>120 Mz is adequate for an average home user.</p>
      <disclaimer>
      <p>The opinions represented herein represent those of the individual
      and should not be interpreted as official policy endorsed by this
      organization.</p>
    </disclaimer>
    </document>

    Textual inclusion example (XInclude C.2)

    >>> document = xinclude_loader("C2.xml")
    >>> ElementInclude.include(document, xinclude_loader)
    >>> print serialize(ET, document) # C2
    <document>
      <p>This document has been accessed
      324387 times.</p>
    </document>

    Textual inclusion of XML example (XInclude C.3)

    >>> document = xinclude_loader("C3.xml")
    >>> ElementInclude.include(document, xinclude_loader)
    >>> print serialize(ET, document) # C3
    <document>
      <p>The following is the source of the "data.xml" resource:</p>
      <example>&lt;?xml version='1.0'?&gt;
    &lt;data&gt;
      &lt;item&gt;&lt;![CDATA[Brooks &amp; Shields]]&gt;&lt;/item&gt;
    &lt;/data&gt;
    </example>
    </document>

    Fallback example (XInclude C.5)
    Note! Fallback support is not yet implemented

    >>> document = xinclude_loader("C5.xml")
    >>> ElementInclude.include(document, xinclude_loader)
    Traceback (most recent call last):
    IOError: resource not found
    >>> # print serialize(ET, document) # C5

    N(    (    (    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.pyt   xinclude(  s    c          C   s'   d d k  l }  t i |  d t ƒd  S(   Niÿÿÿÿ(   t   test_xml_etreet	   verbosity(   t   testR$   R    t   run_doctestt   True(   R$   (    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.pyt	   test_main^  s    t   __main__(   t   doctestt   sysR&   R    t
   SAMPLE_XMLt   SAMPLE_XML_NSR   R   t   NoneR   R   R   R   R   R   R   R   R"   R#   R)   t   __name__(    (    (    s0   /mit/python/lib/python2.6/test/test_xml_etree.pyt   <module>   s6   

			
			1	E		
	







	6	