ó
ŠwÛjc           @   s¥   d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m Z d  d l	 m	 Z	 d d
 d „  ƒ  YZ
 d e j f d „  ƒ  YZ d	 „  Z d S(   iÿÿÿÿN(   t   HTTPException(   t   test_support(   t   StringIOt   TestBasec           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 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   t    i   i    u   í»®c         C   s…   |  j  d  k r' t j |  j ƒ |  _  n  |  j  j |  _ |  j  j |  _ |  j  j |  _ |  j  j	 |  _
 |  j  j |  _ |  j  j |  _ d  S(   N(   t   codect   Nonet   codecst   lookupt   encodingt   encodet   decodet   streamreadert   readert   streamwritert   writert   incrementalencodert   incrementaldecoder(   t   self(    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   setUp   s    c         C   s˜   x‘ t  g  |  j D] } t | ƒ j ƒ  ^ q Œ  D]a \ } } |  j | ƒ d } |  j | | j d ƒ ƒ |  j r/ |  j | |  j | ƒ d ƒ q/ q/ Wd  S(   Ni    s   utf-8(   t   zipt   tstringR   t	   readlinesR   t   assertEqualt   roundtriptestR
   (   R   t   ft   nativet   utf8t   u(    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_chunkcoding#   s    	2	c      
   C   s  x|  j  D]\ } } } t | t ƒ r4 |  j } n	 |  j } | r| | | ƒ d } | |  j k r³ |  j t | ƒ t k t | ƒ ƒ |  j | | d | |  j	 | | | f ƒ q|  j t | ƒ t k t | ƒ ƒ |  j | | d | |  j	 | | | f ƒ q
 |  j
 t | | | ƒ q
 Wd  S(   Ni    s   %r.decode(%r, %r)=%r != %rs   %r.encode(%r, %r)=%r != %r(   t
   codectestst
   isinstancet   bytesR   R
   t
   assertTruet   typet   unicodeR   R	   t   assertRaisest   UnicodeError(   R   t   sourcet   schemet   expectedt   funct   result(    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_errorhandle+   s$    	""c         C   sC   |  j  r |  j d ƒ n  d } |  j |  j | d ƒ d d ƒ d  S(   Ns$   encoding contains full ISO 10646 mapu   à¬“à¬£à­  nd eggst   xmlcharrefreplacei    s   &#2835;&#2851;&#2912; nd eggs(   t   has_iso10646t   skipTestR   R
   (   R   t   s(    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_xmlcharrefreplaceB   s    	c            s“   |  j  r |  j d ƒ n  d d l m ‰  ‡  f d †  } t j d | ƒ |  j rc |  j \ } } n d } d } |  j |  j | d ƒ d | ƒ d  S(	   Ns$   encoding contains full ISO 10646 mapiÿÿÿÿ(   t   codepoint2namec            s¦   t  |  t ƒ s" t d |  ƒ ‚ n  g  } xe |  j |  j |  j !D]M } t | ƒ ˆ  k ru | j d ˆ  t | ƒ ƒ q? | j d t | ƒ ƒ q? Wd j | ƒ |  j f S(   Ns   don't know how to handle %ru   &%s;u   &#%d;u    (	   R   t   UnicodeEncodeErrort	   TypeErrort   objectt   startt   endt   ordt   appendt   join(   t   exct   lt   c(   R1   (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   xmlcharnamereplaceR   s    s   test.xmlcharnamereplaceu   Â«â„œÂ» = âŒ©áˆ´âŒªs*   &laquo;&real;&raquo; = &lang;&#4660;&rang;i    (	   R-   R.   t   htmlentitydefsR1   R   t   register_errort   xmlcharnametestR   R
   (   R   R=   t   sint   sout(    (   R1   s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_customreplace_encodeL   s    		c            sn   ‡  f d †  } t  j d | ƒ xH d d d g g  d  t ƒ  d d f D]" ‰  |  j t |  j |  j d ƒ qD Wd  S(   Nc            s   ˆ  |  j  f S(   N(   R6   (   R:   (   t   ret(    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt	   myreplaceh   s    s   test.cjktesti   i   i   t   stringR   (   R   R?   R   R4   R$   R3   R
   t   unmappedunicode(   R   RE   (    (   RD   s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_callback_wrong_objectsg   s
    +c         C   sy   d „  } t  j d | ƒ |  j |  j d |  j d d ƒ d ƒ d „  } t  j d | ƒ |  j t |  j |  j d ƒ d  S(	   Nc         S   s   d t  |  j ƒ f S(   Nu   x(   t   longR6   (   R:   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyRE   q   s    s   test.cjktestu   abcdu   efght	   abcdxefghi	   c         S   s   d t  j d f S(   Nu   xi   (   t   syst   maxint(   R:   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyRE   w   s    (   RJ   i	   (   R   R?   R   R
   RG   R$   t
   IndexError(   R   RE   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_callback_long_indexp   s    		c         C   s9   d „  } t  j d | ƒ |  j t |  j |  j d ƒ d  S(   Nc         S   s   d S(   Nu   x(   u   xN(   R   (   R:   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyRE   ~   s    s   test.cjktest(   R   R?   R$   R3   R
   RG   (   R   RE   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_callback_None_index}   s    	c            sS   ‡  f d †  ‰  d ˆ  _  t j d ˆ  ƒ |  j |  j d |  j d d ƒ d ƒ d  S(	   Nc            s3   ˆ  j  d k r" ˆ  j  d 8_  d Sd |  j f Sd  S(   Ni    i   u   REPLACEDu   TERMINAL(   u   REPLACEDi    (   t   limitR6   (   R:   (   RE   (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyRE   …   s    i   s   test.cjktestu   abcdu   efght4   abcdREPLACEDabcdREPLACEDabcdREPLACEDabcdTERMINALefghi	   (   RQ   i	   (   RP   R   R?   R   R
   RG   (   R   (    (   RE   s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_callback_backward_index„   s    	c         C   sD   d „  } t  j d | ƒ |  j |  j d |  j d d ƒ d ƒ d  S(   Nc         S   s   d |  j  d f S(   Nu   REPLACEDi   (   R6   (   R:   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyRE   ’   s    s   test.cjktestu   abcdu   efght   abcdREPLACEDghi	   (   RS   i	   (   R   R?   R   R
   RG   (   R   RE   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_callback_forward_index‘   s    	c         C   s9   d „  } t  j d | ƒ |  j t |  j |  j d ƒ d  S(   Nc         S   s   d S(   Nu   TERMid   (   u   TERMid   (    (   R:   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyRE   ™   s    s   test.cjktest(   R   R?   R$   RM   R
   RG   (   R   RE   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_callback_index_outofbound˜   s    	c         C   sé   t  j d ƒ } xÓ d  g t d d ƒ d d d d d g D]¨ } | t |  j d ƒ ƒ } t ƒ  } |  j ƒ  } xT | d  k	 rŽ | j | ƒ } n | j ƒ  } | s¤ Pn  | j | ƒ } | j	 | ƒ qp W|  j
 | j ƒ  |  j d	 ƒ q9 Wd  S(
   Ns   utf-8i   i!   i@   i€   i   i   i   i    (   R   t	   getreaderR   t   rangeR   R   R   t   readR
   t   writeR   t   getvalue(   R   t
   UTF8Readert   sizehintt   istreamt   ostreamt   encodert   datat   e(    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_incrementalencoderŸ   s    	c         C   sÑ   t  j d ƒ } x» d  d g t d d ƒ d d d d d	 g D]� } t |  j d
 ƒ } | t ƒ  ƒ } |  j ƒ  } x9 | j | ƒ } | sŒ Pqs | j | ƒ } | j	 | ƒ qs W|  j
 | j ƒ  |  j d ƒ q< Wd  S(   Ns   utf-8iÿÿÿÿi   i!   i@   i€   i   i   i   i    (   R   t	   getwriterR   RW   R   R   R   RX   R   RY   R   RZ   (   R   t
   UTF8WriterR\   R]   R^   t   decoderR`   R   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_incrementaldecoder³   s    c         C   sÄ   |  j  } |  j ƒ  } |  j t | j | t ƒ d | _ |  j | j | t ƒ d ƒ | j ƒ  d „  } t	 j
 d | ƒ d | _ |  j | j | t ƒ d ƒ d | _ |  j | j | t ƒ d ƒ d  S(   Nt   ignoreR   c         S   s   d |  j  f S(   Nu   called(   R6   (   R:   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   tempreplaceÎ   s    s   test.incremental_error_callbackt   called(   RG   R   R$   R2   R
   t   Truet   errorsR   t   resetR   R?   (   R   t   invRa   Rh   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt&   test_incrementalencoder_error_callbackÄ   s    		
			c         C   s  t  j d ƒ } xë d d d g D]Ú } xÑ d  d g t d d ƒ d d	 d
 d d g D]£ } |  j t |  j d ƒ ƒ } | t ƒ  ƒ } t | | ƒ } xC | | ƒ } | s« Pn  | d k rÇ | j | ƒ q• | j	 | ƒ q• W|  j
 | j ƒ  |  j d ƒ qR Wq Wd  S(   Ns   utf-8RX   t   readlineR   iÿÿÿÿi   i!   i@   i€   i   i   i   i    (   R   Rc   R   RW   R   R   R   t   getattrt
   writelinesRY   R   RZ   (   R   Rd   t   nameR\   R]   R^   R)   R`   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_streamreaderØ   s    c   	      C   s  d } t  j d ƒ } x÷ | D]ï } xæ d  g t d d ƒ d d d	 d
 d g D]» } | t |  j d ƒ ƒ } |  j t ƒ  ƒ } t | | ƒ } x[ | d  k	 rª | | ƒ } n	 | ƒ  } | s½ Pn  | d k rÙ | j | ƒ q� | j	 | ƒ q� W|  j
 | j ƒ  |  j d ƒ qL Wq Wd  S(   NRX   Ro   R   s   utf-8i   i!   i@   i€   i   i   i   i    (   RX   Ro   R   (   R   RV   R   RW   R   R   R   Rp   Rq   RY   R   RZ   (	   R   t	   readfuncsR[   Rr   R\   R]   R^   R)   R`   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_streamwriterë   s$    	N(   t   __name__t
   __module__R	   R   R   R   R   R   R-   R@   RG   R   R   R+   R0   RC   RH   RN   RO   RR   RT   RU   Rb   Rf   Rn   Rs   Ru   (    (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyR      s0   	
			
												t   TestBase_Mappingc           B   sh   e  Z g  Z g  Z g  Z g  Z d  „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z RS(   c         O   s\   t  j j |  | | Ž y |  j ƒ  j ƒ  Wn+ t t f k
 rW |  j d |  j ƒ n Xd  S(   Ns   Could not retrieve (	   t   unittestt   TestCaset   __init__t   open_mapping_filet   closet   IOErrorR    R.   t
   mapfileurl(   R   t   argst   kw(    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyR{   	  s
    c         C   s   t  j |  j ƒ S(   N(   R   t   open_urlresourceR   (   R   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyR|     s    c         C   s-   |  j  j d ƒ r |  j ƒ  n
 |  j ƒ  d  S(   Ns   .xml(   R   t   endswitht   _test_mapping_file_ucmt   _test_mapping_file_plain(   R   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_mapping_file  s    c   	   	      sÀ  d „  ‰  ‡  f d †  } i  } |  j  ƒ  ��} x†| D]~} | sD Pn  | j d ƒ d j ƒ  j ƒ  } t | ƒ d k r{ q4 n  t | d ƒ } | d k rª t | d @ƒ } nÀ | d k rû t | d	 ?ƒ t | d
 ?d @ƒ t | d ?d @ƒ t | d @ƒ } no | d k r:t | d
 ?ƒ t | d ?d @ƒ t | d @ƒ } n0 | d k r4 t | d ?ƒ t | d @ƒ } n q4 | | d ƒ } | d k s4 | | k r˜q4 n  | | | <|  j | | ƒ q4 WWd  QXd  S(   Nc         S   s   t  d t |  d ƒ ƒ S(   Ns	   u'\U%08x'i   (   t   evalt   int(   R<   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   <lambda>  R   c            s&   d j  ‡  f d †  |  j d ƒ Dƒ ƒ S(   Nu    c         3   s   |  ] } ˆ  | ƒ Vq d  S(   N(    (   t   .0R<   (   t   _unichr(    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pys	   <genexpr>  s    t   +(   R9   t   split(   R/   (   R‹   (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyR‰     R   t   #i    i   i   iÿ   i   i   i   i   i   i   i   u   ï¿½(   R|   R�   t   stript   lenR‡   t   chrt
   _testpoint(	   R   t   unichrst   urt_waR   t   lineR`   t   csetvalt   csetcht   unich(    (   R‹   s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyR…     s2    	E3!
c         C   s’   |  j  ƒ  � } | j ƒ  } Wd  QXt j d | ƒ } xX | D]P \ } } t t | d ƒ ƒ } d j d „  | j ƒ  Dƒ ƒ } |  j | | ƒ q: Wd  S(   Ns'   <a u="([A-F0-9]{4})" b="([0-9A-F ]+)"/>i   R   c         s   s$   |  ] } t  t | d  ƒ ƒ Vq d S(   i   N(   R‘   Rˆ   (   RŠ   R<   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pys	   <genexpr>A  s    (	   R|   RX   t   ret   findallt   unichrRˆ   R9   R�   R’   (   R   R   t   ucmdatat   uct   unit   codedR˜   t   codech(    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyR„   ;  s    c         C   s%   x |  j  D] } |  j | Œ  q
 Wd  S(   N(   t   supmapsR’   (   R   t   mapping(    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   test_mapping_supplementalD  s    c         C   sò   | | f |  j  k rw y  |  j | j |  j ƒ | ƒ Wqw t k
 rs } |  j d t | ƒ t | ƒ | j f ƒ qw Xn  | | f |  j k rî y  |  j | j	 |  j ƒ | ƒ Wqî t k
 rê } |  j d t | ƒ t | ƒ | j f ƒ qî Xn  d  S(   Ns*   Encoding failed while testing %s -> %s: %ss*   Decoding failed while testing %s -> %s: %s(
   t   pass_enctestR   R
   R	   R%   t   failt   reprt   reasont   pass_dectestR   (   R   R—   R˜   R:   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyR’   H  s     	' 	c      
   C   s3  x,|  j  D]!\ } } } t | t ƒ r4 | j } n	 | j } | rt | t ƒ r² | |  j | ƒ } |  j t | ƒ t k t | ƒ ƒ |  j	 | | d | |  j | | | f ƒ q+| |  j | ƒ } |  j t | ƒ t k t | ƒ ƒ |  j	 | | d | |  j | | | f ƒ q
 |  j
 t | |  j | ƒ q
 Wd  S(   Ns   %r.decode(%r, %r)=%r != %rs   %r.encode(%r, %r)=%r != %r(   R   R   R    R   R
   R	   R!   R"   R#   R   R$   R%   (   R   R&   R'   R(   R)   R*   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyR+   V  s&    	""(   Rv   Rw   R¤   R¨   R¡   R   R{   R|   R†   R…   R„   R£   R’   R+   (    (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyRx     s   				"				c         C   s™   t  j j t  j j t ƒ d ƒ } t t  j j | |  d ƒ d ƒ � } | j ƒ  } Wd  QXt t  j j | |  d ƒ d ƒ � } | j ƒ  } Wd  QX| | f S(   Nt   cjkencodingss   .txtt   rbs	   -utf8.txt(   t   ost   pathR9   t   dirnamet   __file__t   openRX   (   Rr   t   dirR   t   encodedR   (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   load_teststringn  s    !%%(    (   R   R«   R™   RK   Ry   t   httplibR    t   testR   R   R   Rz   Rx   R²   (    (    (    s‘   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/multibytecodec_support.pyt   <module>   s   õk