
Y]c           @   sg  d  d l  m Z m Z m Z m Z m Z m Z y e   Wn e k
 rX e d   n Xd  d l m	 Z	 m
 Z
 m Z m Z m Z m Z d  d l m Z d  d l m Z d  d l m Z m Z m Z d  d l m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l j Z  d  d	 l m! Z! m" Z" m# Z# d  d l$ Z$ e! d
 d d Z% e! d d d Z& e' Z( e j) j( ry e  j* j+ e  j,  Wn  e- e. e/ f k
 re0 Z( n Xn  e$ j1 e( d  Z2 d Z3 d e$ j4 f d     YZ5 e6 d  Z7 e8 d  Z9 e8 d  Z: d e$ j4 f d     YZ; d e$ j4 f d     YZ< d e$ j4 f d     YZ= d e$ j4 f d     YZ> d Z? d f  d     YZ@ d  e@ e$ j4 f d!     YZA d" e@ e$ j4 f d#     YZB d$ e@ e$ j4 f d%     YZC d& e$ j4 f d'     YZD eE e&  jF   ZG d( e5 f d)     YZH d* e$ j4 f d+     YZI d, e5 f d-     YZJ d.   ZK eL d/ k rceK   n  d S(0   i(   t   make_parsert   ContentHandlert   SAXExceptiont   SAXReaderNotAvailablet   SAXParseExceptiont   saxutilss   no XML parsers available(   t   XMLGeneratort   escapet   unescapet	   quoteattrt   XMLFilterBaset   prepare_input_source(   t   create_parser(   t   feature_namespaces(   t   InputSourcet   AttributesImplt   AttributesNSImpl(   t   StringION(   t   findfilet   run_unittestt   TESTFNs   test.xmlt   subdirt   xmltestdatas   test.xml.outs"   Requires unicode filenames supports%   http://www.python.org/xml-ns/saxtest/t   XmlTestBasec           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   sW  |  j  t | j d  |  j  t | j d  |  j  t | j d  |  j  t | j d  |  j  t | j d  |  j | j   d  |  j | j	   g   |  j | j
   g   |  j t |  d  |  j | j d   |  j | j   g   |  j | j d  d   |  j | j d d  d  |  j | j   g   |  j | j   g   d  S(   Nt   attri    t   attrsi   (   t   assertRaisest   KeyErrort   getValuet   getValueByQNamet   getNameByQNamet   getQNameByNamet   __getitem__t   assertEqualt	   getLengtht   getNamest	   getQNamest   lent   assertFalset   has_keyt   keyst   gett   Nonet   itemst   values(   t   selfR   (    (    s   lib/python2.7/test/test_sax.pyt   verify_empty_attrs,   s    c         C   s{  |  j  t | j t d f  |  j  t | j d  |  j  t | j d  |  j  t | j t d f  |  j  t | j t d f  |  j | j	   d  |  j | j
   g   |  j | j   g   |  j t |  d  |  j | j t d f   |  j | j   g   |  j | j t d f  d   |  j | j t d f d  d  |  j | j   g   |  j | j   g   d  S(   NR   s   ns:attri    i   (   R   R   R   t   ns_uriR   R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   R*   R+   R,   (   R-   R   (    (    s   lib/python2.7/test/test_sax.pyt   verify_empty_nsattrs=   s    "c         C   sp  |  j  | j   d  |  j  | j   d g  |  j  | j   d g  |  j  t |  d  |  j | j d   |  j  | j   d g  |  j  | j d  d  |  j  | j d d  d  |  j  | j	   d g  |  j  | j
   d g  |  j  | j d  d  |  j  | j d  d  |  j  | j d  d  |  j  | d d  |  j  | j d  d  d  S(   Ni   R   t   vali   (   R   R1   (   R!   R"   R#   R$   R%   t
   assertTrueR'   R(   R)   R+   R,   R   R   R   R   (   R-   R   (    (    s   lib/python2.7/test/test_sax.pyt   verify_attrs_wattrN   s    (   t   __name__t
   __module__R.   R0   R3   (    (    (    s   lib/python2.7/test/test_sax.pyR   +   s   		c         C   s   | d  k r |  Sd | |  f S(   Nu&   <?xml version="1.0" encoding="%s"?>
%s(   R*   (   t   doct   encoding(    (    s   lib/python2.7/test/test_sax.pyt   xml_unicode`   s    c         C   s.   | t  k r | } n  t |  |  j | d  S(   Nt   xmlcharrefreplace(   t   EllipsisR8   t   encode(   R6   R7   t   decl_encoding(    (    s   lib/python2.7/test/test_sax.pyt	   xml_bytese   s    	c         C   sV   | t  k r | } n  t j t d d | d d  } | j t |  |   Wd  QXd  S(   Nt   wR7   t   errorsR9   (   R:   t   iot   openR   t   writeR8   (   R6   R7   R<   t   f(    (    s   lib/python2.7/test/test_sax.pyt   make_xml_filej   s    	!t	   ParseTestc           B   sV   e  Z e j d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z RS(   sB   <money value="$\xa3\u20ac\U0001017b">$\xa3\u20ac\U0001017b</money>c         C   s   t  j t  d  S(   N(   t   supportt   unlinkR   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   tearDownu   s    c         C   sU   d d l  m } t   } | | t | d   |  j | j   t |  j d   d  S(   Ni(   t   parses   utf-8(   t   xml.saxRI   R   R   R!   t   getvalueR=   t   data(   R-   RC   RI   t   result(    (    s   lib/python2.7/test/test_sax.pyt   check_parsex   s    	c         C   s  d	 } x | D] } |  j  t j t |  j |    t |  j |  |  j  t  t j t d   } |  j  |  Wd  QX|  j  t j t |  j | d     t |  j | d   |  j  t  t j t d   } |  j  |  Wd  QXq W|  j  t j t |  j d d    t |  j d d  |  j  t  t j t d   } |  j  |  Wd  QX|  j  t j t |  j d d     t |  j d d   |  j  t  t j t d   } |  j  |  Wd  QX|  j  t j t |  j d    t |  j d  |  j  t  t j t d   } |  j  |  Wd  QX|  j	 t
  * |  j  t j t |  j d d     Wd  QXt |  j d d   |  j	 t
   |  j  t  Wd  QXt j t d  * } |  j	 t
   |  j  |  Wd  QXWd  QXd  S(
   Ns   us-asciis   utf-8s   utf-16s   utf-16les   utf-16bet   rbs	   utf-8-sigs
   iso-8859-1(   s   us-asciis   utf-8s   utf-16s   utf-16les   utf-16be(   RN   R@   t   BytesIOR=   RL   RD   R   RA   R*   R   R   (   R-   t	   encodingsR7   RC   (    (    s   lib/python2.7/test/test_sax.pyt   test_parse_bytes~   sF    "%%%"+c         C   sb   t  |  j d d   t j t d  7 } t   } | j |  | j d  |  j	 |  Wd  QXd  S(   Ns
   iso-8859-1RO   (
   RD   RL   R*   R@   RA   R   R   t   setByteStreamt   setEncodingRN   (   R-   RC   t   input(    (    s   lib/python2.7/test/test_sax.pyt   test_parse_InputSource   s    	c      
      s   t    i d  d 6    f d   } t j t d |  O t |  j d d   |  j t   |  j	 t
  Wd  QX|  j  d j  Wd  QXd  S(   Nt   fileobjc             s     |    } |  d <| S(   NRW   (    (   t   argsRW   (   t   builtin_opent	   non_local(    s   lib/python2.7/test/test_sax.pyt	   mock_open   s    
RA   s
   iso-8859-1(   RA   R*   RF   t	   swap_attrR   RD   RL   R   R   RN   R   R2   t   closed(   R-   R[   (    (   RY   RZ   s   lib/python2.7/test/test_sax.pyt   test_parse_close_source   s    c         C   sU   d d l  m } t   } | | t | d   |  j | j   t |  j d   d  S(   Ni(   t   parseStrings   utf-8(   RJ   R_   R   R   R!   RK   R=   RL   (   R-   t   sR_   RM   (    (    s   lib/python2.7/test/test_sax.pyt   check_parseString   s    	c      	   C   s   d } xC | D]; } |  j  t |  j |   |  j  t |  j | d    q W|  j  t |  j d d   |  j  t |  j d d    |  j  t |  j d   |  j t  ! |  j  t |  j d d    Wd  QXd  S(	   Ns   us-asciis   utf-8s   utf-16s   utf-16les   utf-16bes	   utf-8-sigs
   iso-8859-1(   s   us-asciis   utf-8s   utf-16s   utf-16les   utf-16be(   Ra   R=   RL   R*   R   R   (   R-   RQ   R7   (    (    s   lib/python2.7/test/test_sax.pyt   test_parseString_bytes   s     (   R4   R5   RF   t   uRL   RH   RN   RR   RV   R^   Ra   Rb   (    (    (    s   lib/python2.7/test/test_sax.pyRE   q   s   			*				t   MakeParserTestc           B   s   e  Z d    Z RS(   c         C   s   d d l  m } |   } d d l  m } |   } d d l  m } |   } d d l  m } |   } d d l  m } |   } d d l  m } |   } d  S(   Ni(   R    (   RJ   R    (   R-   R    t   p(    (    s   lib/python2.7/test/test_sax.pyt   test_make_parser2   s    					(   R4   R5   Rf   (    (    (    s   lib/python2.7/test/test_sax.pyRd      s   t   SaxutilsTestc           B   st   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z RS(   c         C   s   |  j  t d  d  d  S(   Ns   Donald Duck & Cos   Donald Duck &amp; Co(   R!   R   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_escape_basic   s    c         C   s   |  j  t d  d  d  S(   Ns   <Donald Duck & Co>s   &lt;Donald Duck &amp; Co&gt;(   R!   R   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_escape_all   s    c         C   s$   |  j  t d i d d 6 d  d  S(   Ns   Hei på degs   &aring;s   ås   Hei p&aring; deg(   R!   R   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_escape_extra   s    c         C   s   |  j  t d  d  d  S(   Ns   Donald Duck &amp; Cos   Donald Duck & Co(   R!   R   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_unescape_basic   s    c         C   s   |  j  t d  d  d  S(   Ns   &lt;Donald Duck &amp; Co&gt;s   <Donald Duck & Co>(   R!   R   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_unescape_all  s    c         C   s$   |  j  t d i d d 6 d  d  S(   Ns   Hei på degs   &aring;s   ås   Hei p&aring; deg(   R!   R   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_unescape_extra  s    c         C   s$   |  j  t d i d d 6 d  d  S(   Ns	   &amp;foo;t   splats   &foo;(   R!   R   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_unescape_amp_extra	  s    c         C   s   |  j  t d  d  d  S(   Ns   Donald Duck & Cos   "Donald Duck &amp; Co"(   R!   R	   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_quoteattr_basic  s    c         C   s   |  j  t d  d  d  S(   Ns   Includes "double" quotess   'Includes "double" quotes'(   R!   R	   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_single_quoteattr  s    c         C   s   |  j  t d  d  d  S(   Ns   Includes 'single' quotess   "Includes 'single' quotes"(   R!   R	   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_double_quoteattr  s    c         C   s   |  j  t d  d  d  S(   Ns%   Includes 'single' and "double" quotess1   "Includes 'single' and &quot;double&quot; quotes"(   R!   R	   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_single_double_quoteattr  s    c         C   s   t  d g  } d  S(   Ns   xml.parsers.no_such_parser(   R    (   R-   Re   (    (    s   lib/python2.7/test/test_sax.pyt   test_make_parser  s    (   R4   R5   Rh   Ri   Rj   Rk   Rl   Rm   Ro   Rp   Rq   Rr   Rs   Rt   (    (    (    s   lib/python2.7/test/test_sax.pyRg      s   											t   PrepareInputSourceTestc           B   sP   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   c         C   s8   t  j |  _ t |  j d   } | j d  Wd  QXd  S(   NR>   s   This was read from a file.(   RF   R   t   fileRA   RB   (   R-   t   tmp(    (    s   lib/python2.7/test/test_sax.pyt   setUp&  s    c         C   s   t  j |  j  d  S(   N(   RF   RG   Rv   (   R-   (    (    s   lib/python2.7/test/test_sax.pyRH   +  s    c         C   s   t  j d  S(   Ns   This is a byte stream.(   R@   RP   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   make_byte_stream.  s    c         C   s1   |  j  |  |  j | j   |  | j   d  S(   N(   t   assertIsNotNoneR!   t   readt   close(   R-   t   streamt   content(    (    s   lib/python2.7/test/test_sax.pyt   checkContent1  s    c         C   s[   t  |  j  } | j |  j    t |  } |  j | j    |  j | j   d  d  S(   Ns   This is a byte stream.(	   R   Rv   RS   Ry   R   t   assertIsNonet   getCharacterStreamR   t   getByteStream(   R-   t   srct   prep(    (    s   lib/python2.7/test/test_sax.pyt   test_byte_stream7  s    c         C   sH   t  |  j  } t |  } |  j | j    |  j | j   d  d  S(   Ns   This was read from a file.(   R   Rv   R   R   R   R   R   (   R-   R   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_system_idA  s
    c         C   s<   t  |  j  } |  j | j    |  j | j   d  d  S(   Ns   This was read from a file.(   R   Rv   R   R   R   R   (   R-   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_stringJ  s    c         C   s?   t  |  j    } |  j | j    |  j | j   d  d  S(   Ns   This is a byte stream.(   R   Ry   R   R   R   R   (   R-   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_binary_fileQ  s    (
   R4   R5   Rx   RH   Ry   R   R   R   R   R   (    (    (    s   lib/python2.7/test/test_sax.pyRu   $  s   					
			s,   <?xml version="1.0" encoding="iso-8859-1"?>
t
   XmlgenTestc           B   s   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   sg   |  j    } t |  } | j   | j d i   | j d  | j   |  j | j   t d  d  S(   NR6   s   <doc></doc>(	   t   ioclassR   t   startDocumentt   startElementt
   endElementt   endDocumentR!   RK   t   start(   R-   RM   t   gen(    (    s   lib/python2.7/test/test_sax.pyt   test_xmlgen_basic_  s    

c         C   st   |  j    } t |  } | j   | j d i   | j d  | j d  | j   |  j | j   t	 d  d  S(   NR6   t   huheis   <doc>huhei</doc>(
   R   R   R   R   t
   charactersR   R   R!   RK   R   (   R-   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_xmlgen_contenti  s    

c         C   sw   |  j    } t |  } | j   | j d d  | j d i   | j d  | j   |  j | j   t	 d  d  S(   Nt   testRL   R6   s   <?test data?><doc></doc>(
   R   R   R   t   processingInstructionR   R   R   R!   RK   R   (   R-   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_xmlgen_piu  s    

c         C   st   |  j    } t |  } | j   | j d i   | j d  | j d  | j   |  j | j   t	 d  d  S(   NR6   s   <huhei&s   <doc>&lt;huhei&amp;</doc>(
   R   R   R   R   R   R   R   R!   RK   R   (   R-   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_xmlgen_content_escape  s    

c         C   s   |  j    } t |  } | j   | j d i d d 6 | j d i d d 6 | j d  | j d i d d 6 | j d  | j d i d d 6 | j d  | j d  | j   |  j | j   t d  d  S(	   NR6   t   "t   at   et   's   '"s   
	sK   <doc a='"'><e a="'"></e><e a="'&quot;"></e><e a="&#10;&#13;&#9;"></e></doc>(	   R   R   R   R   R   R   R!   RK   R   (   R-   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_xmlgen_attr_escape  s    

c         C   s   d } x | D] } |  j    } t | d | } | j   | j d i d	 d
 6 | j d	  | j d  | j   |  j | j   d | j	 | d   q Wd  S(   Ns   iso-8859-15s   utf-8s   utf-16bes   utf-16les   utf-32bes   utf-32leR7   R6   u   €R   u:   <?xml version="1.0" encoding="%s"?>
<doc a="€">€</doc>R9   (   s   iso-8859-15s   utf-8s   utf-16bes   utf-16les   utf-32bes   utf-32le(
   R   R   R   R   R   R   R   R!   RK   R;   (   R-   RQ   R7   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_xmlgen_encoding  s      

c         C   s}   |  j    } t | d d } | j   | j d i d d 6 | j d  | j d  | j   |  j | j   d  d  S(   NR7   t   asciiR6   u   €R   sE   <?xml version="1.0" encoding="ascii"?>
<doc a="&#8364;">&#8364;</doc>(	   R   R   R   R   R   R   R   R!   RK   (   R-   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_xmlgen_unencodable  s    

c         C   st   |  j    } t |  } | j   | j d i   | j d  | j d  | j   |  j | j   t	 d  d  S(   NR6   t    s   <doc> </doc>(
   R   R   R   R   t   ignorableWhitespaceR   R   R!   RK   R   (   R-   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_xmlgen_ignorable  s    

c         C   s   d } x | D] } |  j    } t | d | } | j   | j d i d	 d
 6 | j d	 j |   | j d j |   | j d  | j   |  j	 | j
   d | j | d   q Wd  S(   Ns   iso-8859-15s   utf-8s   utf-16bes   utf-16les   utf-32bes   utf-32leR7   R6   u   €R   R   u;   <?xml version="1.0" encoding="%s"?>
<doc a="€">€ </doc>R9   (   s   iso-8859-15s   utf-8s   utf-16bes   utf-16les   utf-32bes   utf-32le(   R   R   R   R   R   R;   R   R   R   R!   RK   (   R-   RQ   R7   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_xmlgen_encoding_bytes  s       

c         C   s   |  j    } t |  } | j   | j d t  | j t d f d i   | j d d  i   | j d d   | j t d f d  | j d  | j	   |  j
 | j   t d t  d  S(   Nt   ns1R6   s   ns1:doct   udocs/   <ns1:doc xmlns:ns1="%s"><udoc></udoc></ns1:doc>(   NR   (   NR   (   R   R   R   t   startPrefixMappingR/   t   startElementNSR*   t   endElementNSt   endPrefixMappingR   R!   RK   R   (   R-   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_xmlgen_ns  s    

c         C   st   |  j    } t |  } | j   | j d d i d d 6 | j d d  | j   |  j | j   t	 d  d  S(   NR   t   ct   bs   <a b="c"></a>(   NR   (   NR   (   NR   (
   R   R   R   R   R*   R   R   R!   RK   R   (   R-   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_1463026_1  s    

c         C   s   |  j    } t |  } | j   | j d  d  | j d d i   | j d d  | j d   | j   |  j	 | j
   t d  d  S(   Nt   quxR   s   <a xmlns="qux"></a>(   R   R   (   R   R   (   R   R   R   R   R*   R   R   R   R   R!   RK   R   (   R-   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_1463026_2   s    

c         C   s   |  j    } t |  } | j   | j d d  | j d d i d d 6 | j d	 d  | j d  | j   |  j	 | j
   t d  d  S(
   Nt   myR   R   R   R   s"   <my:a xmlns:my="qux" b="c"></my:a>(   R   R   (   NR   (   R   R   (   R   R   R   R   R   R*   R   R   R   R!   RK   R   (   R-   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_1463026_3  s    

c         C   su   t  d  } t   } | j t t  |  j   } t |  } | j |  | j |  |  j	 | j
   t d  d  S(   Nsb   <?xml version="1.0"?><a:g1 xmlns:a="http://example.com/ns"><a:g2 xml:lang="en">Hello</a:g2></a:g1>sM   <a:g1 xmlns:a="http://example.com/ns"><a:g2 xml:lang="en">Hello</a:g2></a:g1>(   R   R    t
   setFeatureR   t   TrueR   R   t   setContentHandlerRI   R!   RK   R   (   R-   t   test_xmlt   parserRM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_5027_1  s    		c         C   s   |  j    } t |  } | j   | j d d  | j d
 d i   i d d 6} | j d d |  | j d  | j d d  | j d d  | j d  | j   |  j	 | j
   t d	  d  S(   NR   s   http://example.com/nst   g1t   ens$   http://www.w3.org/XML/1998/namespacet   langt   g2t   HellosM   <a:g1 xmlns:a="http://example.com/ns"><a:g2 xml:lang="en">Hello</a:g2></a:g1>(   s   http://example.com/nsR   (   s$   http://www.w3.org/XML/1998/namespaceR   (   s   http://example.com/nsR   (   s   http://example.com/nsR   (   s   http://example.com/nsR   (   R   R   R   R   R   R   R   R   R   R!   RK   R   (   R-   RM   R   t	   lang_attr(    (    s   lib/python2.7/test/test_sax.pyt   test_5027_25  s    

c         C   s3   |  j    } d   } | |  |  j | j  d  S(   Nc         S   s*   t  |   } | j   | j d i   d  S(   NR6   (   R   R   R   (   t   outR   (    (    s   lib/python2.7/test/test_sax.pyt   funcS  s    
(   R   R&   R]   (   R-   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_no_close_fileQ  s    	
c         C   s   |  j    } t |  } | j d i d d 6 | j d  | j d  | j d i d d 6 | j d  |  j | j   d  d  S(	   Nt   foos   1.0R   R   t   bars   2.0R   s+   <foo a="1.0">Hello</foo><bar b="2.0"></bar>(   R   R   R   R   R   R!   RK   (   R-   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_xmlgen_fragmentZ  s    (   R4   R5   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s   lib/python2.7/test/test_sax.pyR   ^  s"   	
																t   StringXmlgenTestc           B   s   e  Z e Z RS(    (   R4   R5   R   R   (    (    (    s   lib/python2.7/test/test_sax.pyR   i  s   t   BytesIOXmlgenTestc           B   s   e  Z e j Z RS(    (   R4   R5   R@   RP   R   (    (    (    s   lib/python2.7/test/test_sax.pyR   l  s   t   WriterXmlgenTestc           B   s   e  Z d  e f d     YZ RS(   R   c           B   s    e  Z e j Z e Z d    Z RS(   c         C   s   d j  |   S(   Nt    (   t   join(   R-   (    (    s   lib/python2.7/test/test_sax.pyRK   t  s    (   R4   R5   t   listt   appendRB   t   FalseR]   RK   (    (    (    s   lib/python2.7/test/test_sax.pyR   p  s   	(   R4   R5   R   R   (    (    (    s   lib/python2.7/test/test_sax.pyR   o  s   t   XMLFilterBaseTestc           B   s   e  Z d    Z RS(   c         C   s   t    } t |  } t   } | j |  | j   | j d i   | j d  | j d  | j d  | j	   |  j
 | j   t d  d  S(   NR6   R~   R   s   <doc>content </doc>(   R   R   R
   R   R   R   R   R   R   R   R!   RK   R   (   R-   RM   R   t   filter(    (    s   lib/python2.7/test/test_sax.pyt   test_filter_basicy  s    		

(   R4   R5   R   (    (    (    s   lib/python2.7/test/test_sax.pyR   x  s   t   ExpatReaderTestc           B   s   e  Z d    Z e d    Z d d d     YZ d   Z d d d     YZ d   Z d e	 f d	     YZ
 d
   Z d   Z d   Z d   Z d   Z d   Z e d    Z d   Z d   Z d   Z d   Z d   Z e d    Z RS(   c         C   sX   t    } t   } t |  } | j |  | j t t   |  j | j   t	  d  S(   N(
   R   R   R   R   RI   RA   t   TEST_XMLFILER!   RK   t   xml_test_out(   R-   R   RM   t   xmlgen(    (    s   lib/python2.7/test/test_sax.pyt   test_expat_binary_file  s    		c         C   s   t  j } t j t |  |  j t  j |  t   } t   } t	 |  } | j
 |  | j t |   |  j | j   t  d  S(   N(   RF   t   TESTFN_UNICODEt   shutilt   copyfileR   t
   addCleanupRG   R   R   R   R   RI   RA   R!   RK   R   (   R-   t   fnameR   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_file_unicode  s    			t   TestDTDHandlerc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   g  |  _  g  |  _ d  S(   N(   t
   _notationst	   _entities(   R-   (    (    s   lib/python2.7/test/test_sax.pyt   __init__  s    	c         C   s   |  j  j | | | f  d  S(   N(   R   R   (   R-   t   namet   publicIdt   systemId(    (    s   lib/python2.7/test/test_sax.pyt   notationDecl  s    c         C   s    |  j  j | | | | f  d  S(   N(   R   R   (   R-   R   R   R   t   ndata(    (    s   lib/python2.7/test/test_sax.pyt   unparsedEntityDecl  s    (   R4   R5   R   R   R   (    (    (    s   lib/python2.7/test/test_sax.pyR     s   		c         C   s   t    } |  j   } | j |  | j d  | j d  | j d  | j d  | j d  | j   |  j | j d
 g  |  j | j d g  d  S(   Ns   <!DOCTYPE doc [
s-     <!ENTITY img SYSTEM "expat.gif" NDATA GIF>
sW     <!NOTATION GIF PUBLIC "-//CompuServe//NOTATION Graphics Interchange Format 89a//EN">
s   ]>
s   <doc></doc>t   GIFs;   -//CompuServe//NOTATION Graphics Interchange Format 89a//ENt   imgs	   expat.gif(   R   s;   -//CompuServe//NOTATION Graphics Interchange Format 89a//ENN(   R   Ns	   expat.gifR   (	   R   R   t   setDTDHandlert   feedR|   R!   R   R*   R   (   R-   R   t   handler(    (    s   lib/python2.7/test/test_sax.pyt   test_expat_dtdhandler  s    	

t   TestEntityResolverc           B   s   e  Z d    Z RS(   c         C   s    t    } | j t d   | S(   Ns	   <entity/>(   R   RS   R   (   R-   R   R   t   inpsrc(    (    s   lib/python2.7/test/test_sax.pyt   resolveEntity  s    	(   R4   R5   R   (    (    (    s   lib/python2.7/test/test_sax.pyR     s   c         C   s   t    } | j |  j    t   } | j t |   | j d  | j d  | j d  | j d  | j   |  j | j	   t
 d  d  S(   Ns   <!DOCTYPE doc [
s#     <!ENTITY test SYSTEM "whatever">
s   ]>
s   <doc>&test;</doc>s   <doc><entity></entity></doc>(   R   t   setEntityResolverR   R   R   R   R   R|   R!   RK   R   (   R-   R   RM   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_entityresolver  s    		
t   AttrGathererc           B   s   e  Z d    Z d   Z RS(   c         C   s   | |  _  d  S(   N(   t   _attrs(   R-   R   R   (    (    s   lib/python2.7/test/test_sax.pyR     s    c         C   s   | |  _  d  S(   N(   R   (   R-   R   t   qnameR   (    (    s   lib/python2.7/test/test_sax.pyR     s    (   R4   R5   R   R   (    (    (    s   lib/python2.7/test/test_sax.pyR     s   	c         C   sM   t    } |  j   } | j |  | j d  | j   |  j | j  d  S(   Ns   <doc/>(   R   R   R   R   R|   R.   R   (   R-   R   t   gather(    (    s   lib/python2.7/test/test_sax.pyt   test_expat_attrs_empty  s    	
c         C   sM   t    } |  j   } | j |  | j d  | j   |  j | j  d  S(   Ns   <doc attr='val'/>(   R   R   R   R   R|   R3   R   (   R-   R   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_attrs_wattr  s    	
c         C   sP   t  d  } |  j   } | j |  | j d  | j   |  j | j  d  S(   Ni   s   <doc/>(   R   R   R   R   R|   R0   R   (   R-   R   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_nsattrs_empty  s    
c         C   s  t  d  } |  j   } | j |  | j d t  | j   | j } |  j | j   d  |  j | j	   t d f g  |  j
 | j   g  k p | j   d g k  |  j t |  d  |  j
 | j t d f   |  j | j t d f  d  |  j | j t d f d  d  |  j | j   t d f d f g  |  j | j   d g  |  j | j t d f  d  |  j | t d f d  d  S(   Ni   s"   <doc xmlns:ns='%s' ns:attr='val'/>R   s   ns:attrR1   i   (   R   R   R   R   R/   R|   R   R!   R"   R#   R2   R$   R%   R'   R)   R+   R,   R   (   R-   R   R   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_nsattrs_wattr  s$    
	"%c         C   sR   t    } t   } t |  } | j |  | j t  |  j | j   t  d  S(   N(	   R   R   R   R   RI   R   R!   RK   R   (   R-   R   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_inpsource_filename$  s    		c         C   sX   t    } t   } t |  } | j |  | j t t   |  j | j   t	  d  S(   N(
   R   R   R   R   RI   R   R   R!   RK   R   (   R-   R   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_inpsource_sysid.  s    		c         C   s   t  j } t j t |  |  j t  j |  t   } t   } t	 |  } | j
 |  | j t |   |  j | j   t  d  S(   N(   RF   R   R   R   R   R   RG   R   R   R   R   RI   R   R!   RK   R   (   R-   R   R   RM   R   (    (    s   lib/python2.7/test/test_sax.pyt"   test_expat_inpsource_sysid_unicode8  s    			c         C   sn   t    } t   } t |  } | j |  t   } | j t t   | j |  |  j	 | j
   t  d  S(   N(   R   R   R   R   R   RS   RA   R   RI   R!   RK   R   (   R-   R   RM   R   R   (    (    s   lib/python2.7/test/test_sax.pyt    test_expat_inpsource_byte_streamG  s    			c         C   sm   t    } t |  } t   } | j |  | j d  | j d  | j   |  j | j   t d  d  S(   Ns   <doc>s   </doc>s   <doc></doc>(	   R   R   R   R   R   R|   R!   RK   R   (   R-   RM   R   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_incrementalU  s    		
c         C   s   t    } t |  } t   } | j |  | j d  | j d  t    } t |  } | j |  | j   | j d  | j d  | j d  | j   |  j | j   t	 d  d  S(   Ns   <doc>t   texts   </doc>s   <doc>text</doc>(
   R   R   R   R   R   t   resetR|   R!   RK   R   (   R-   RM   R   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_incremental_reseta  s    			

c         C   s   t    } t |  } t   } | j |  | j d  | j d  | j   |  j | j   d   |  j | j	   d   |  j | j
   d  d  S(   Ns   <doc>s   </doc>i   (   R   R   R   R   R   R|   R!   t   getSystemIdR*   t   getPublicIdt   getLineNumber(   R-   RM   R   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_locator_noinfox  s    		
c         C   sh   t    } t |  } t   } | j |  | j t  |  j | j   t  |  j | j   d   d  S(   N(
   R   R   R   R   RI   R   R!   R  R  R*   (   R-   RM   R   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_locator_withinfo  s    		c         C   s   t  j } t j t |  |  j t  j |  t   } t |  } t	   } | j
 |  | j |  |  j | j   |  |  j | j   d   d  S(   N(   RF   R   R   R   R   R   RG   R   R   R   R   RI   R!   R  R  R*   (   R-   R   RM   R   R   (    (    s   lib/python2.7/test/test_sax.pyt#   test_expat_locator_withinfo_unicode  s    			(    (    (   R4   R5   R   t   requires_unicode_filenamesR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R  (    (    (    s   lib/python2.7/test/test_sax.pyR     s(   	
			
	
	
		
	
					
t   ErrorReportingTestc           B   s6   e  Z d    Z d   Z d   Z d d d     YZ RS(   c         C   s   t    } | j t    t   } | j t d   d } | j |  y | j |  |  j   Wn) t	 k
 r } |  j
 | j   |  n Xd  S(   Ns   <foo bar foobar>s   a file name(   R   R   R   R   RS   R   t   setSystemIdRI   t   failR   R!   R  (   R-   R   t   sourceR   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_inpsource_location  s    		c         C   se   t    } | j t    |  j t | j t d   |  j | j   d  |  j | j	   d  d  S(   Ns   <foo>i   i   (
   R   R   R   R   R   RI   R   R!   t   getColumnNumberR  (   R-   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_expat_incomplete  s
    	c         C   s   t  t d d  |  j d d    t  t d d  |  j d  d    t  t d d  |  j d d     t  t d d  |  j d  d     d  S(   Nt   messagei   (   t   strR   R*   t   DummyLocator(   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_sax_parse_exception_str  s    R  c           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   t   _linenot   _colno(   R-   t   linenot   colno(    (    s   lib/python2.7/test/test_sax.pyR     s    	c         C   s   d S(   Nt   pubid(    (   R-   (    (    s   lib/python2.7/test/test_sax.pyR    s    c         C   s   d S(   Nt   sysid(    (   R-   (    (    s   lib/python2.7/test/test_sax.pyR    s    c         C   s   |  j  S(   N(   R  (   R-   (    (    s   lib/python2.7/test/test_sax.pyR    s    c         C   s   |  j  S(   N(   R  (   R-   (    (    s   lib/python2.7/test/test_sax.pyR    s    (   R4   R5   R   R  R  R  R  (    (    (    s   lib/python2.7/test/test_sax.pyR    s
   				(    (   R4   R5   R  R  R  R  (    (    (    s   lib/python2.7/test/test_sax.pyR    s   			t   XmlReaderTestc           B   s>   e  Z d    Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s   |  j  t i    d  S(   N(   R.   R   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_attrs_empty  s    c         C   s   |  j  t i d d 6  d  S(   NR1   R   (   R3   R   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_attrs_wattr  s    c         C   s   |  j  t i  i    d  S(   N(   R0   R   (   R-   (    (    s   lib/python2.7/test/test_sax.pyt   test_nsattrs_empty  s    c         C   s  t  i d t d f 6i d t d f 6 } |  j | j   d  |  j | j   t d f g  |  j | j   d g  |  j t |  d  |  j | j t d f   |  j | j	   t d f g  |  j | j
 t d f  d  |  j | j
 t d f d  d  |  j | j   t d f d f g  |  j | j   d g  |  j | j t d f  d  |  j | j d  d  |  j | j d  t d f  |  j | t d f d  |  j | j t d f  d  d  S(   NR1   R   s   ns:attri   i   (   R   R/   R!   R"   R#   R$   R%   R2   R'   R(   R)   R+   R,   R   R   R   R   (   R-   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_nsattrs_wattr  s"    "%c         C   s   d d  l  } | j j   } x3 | j j   D]" } | j d  r+ | j | =q+ q+ Wz/ d d  l } | j j } |  j | j	 d  Wd  | j j
 |  Xd  S(   Nis   xml.s   xml.sax.expatreader(   t   syst   modulest   copyR(   t
   startswitht   xml.sax.expatreadert   saxt   expatreaderR!   R4   t   update(   R-   R  t   old_modulest   modnamet   xmlt   module(    (    s   lib/python2.7/test/test_sax.pyt   test_sf_1511497  s    c         C   s?   t  d  } t   } d d l m } |  j | | j |  d  S(   Nt   invalidi(   R   (   R   R    RJ   R   R   RI   (   R-   t   sioR   R   (    (    s   lib/python2.7/test/test_sax.pyt   test_sf_1513611*  s    	(   R4   R5   R  R  R  R  R*  R-  (    (    (    s   lib/python2.7/test/test_sax.pyR    s   				,	c           C   s)   t  t t t t t t t t t	 t
 
 d  S(   N(   R   Rd   RE   Rg   Ru   R   R   R   R   R  R  (    (    (    s   lib/python2.7/test/test_sax.pyt	   test_main2  s    t   __main__(M   RJ   R    R   R   R   R   R   t   ImportErrort   xml.sax.saxutilsR   R   R   R	   R
   R   R"  R   t   xml.sax.handlerR   t   xml.sax.xmlreaderR   R   R   t	   cStringIOR   R@   t   gct   os.patht   osR   t   test.test_supportt   test_supportRF   R   R   R   t   unittestR   t   TEST_XMLFILE_OUTR   t   supports_unicode_filenamest   pathR   R;   t   TESTFN_ENCODINGt   AttributeErrort   UnicodeErrort	   TypeErrorR   t
   skipUnlessR  R/   t   TestCaseR   R*   R8   R:   R=   RD   RE   Rd   Rg   Ru   R   R   R   R   R   R   RA   R{   R   R   R  R  R.  R4   (    (    (    s   lib/python2.7/test/test_sax.pyt   <module>   sf   ..	5f48 	 >N	