
    ;e                         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  G d de j                  Z	 G d de j                  Z
 G d	 d
e j                  Zedk    r e j                     dS dS )    N)array)	os_helper)script_helperc                   ,    e Zd Zd Zd Zd Zd Zd ZdS )LegacyBase64TestCasec                 p   |                      t          |d           |                      t          |g            t          d                              dd          }|                      t          ||           t          d                              d          }|                      t          ||           d S )N s   1234B)   r   I)assertRaises	TypeError
memoryviewcast)selffmultidimensionalint_datas       '/usr/lib/python3.11/test/test_base64.pycheck_type_errorsz&LegacyBase64TestCase.check_type_errors   s    )Q+++)Q+++%g..33C@@)Q(8999g&&++C00)Q11111    c                    | j         } |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        d	          d	            |t          j        d
          d            |t          j        t          d                    d            |t          j        t	          d                    d            |t          j        t          dd                    d           |                     t          j                   d S )N   www.python.org   d3d3LnB5dGhvbi5vcmc=
   a   YQ==
   ab   YWI=
   abc   YWJj
r   R   abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#0^&*();:<>,. []{}r   YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0
NTY3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==
r
   )assertEqualbase64encodebytes	bytearrayr   r   r   r   eqs     r   test_encodebytesz%LegacyBase64TestCase.test_encodebytes   s]   
6/002KLLL
6d##Y///
6e$$i000
6f%%y111
6c""C(((
6 A B B3	4 	4 	4 	6i//00)<<<
6j00119===
6eC00119===v122222r   c                    | j         } |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        d	          d
            |t          j        d          d            |t          j        t          d                    d            |t          j        t	          d                    d            |t          j        t          dd                    d           |                     t          j                   d S )Nr   r   r   r   r   r   r    r   r"   r!   r   r
   )r#   r$   decodebytesr&   r   r   r   r'   s     r   test_decodebytesz%LegacyBase64TestCase.test_decodebytes(   s]   
6788:KLLL
6i(($///
6i((%000
6i((&111
6 G H H-	. 	. 	. 	6c""C(((
6i	2233V<<<
6j3344f===
6eC3344f===v122222r   c                    | j         }ddlm}m}  |d          } |            }t	          j        ||            ||                                d           |                     t          t          j         |d           |                       |                     t          t          j         |d           |                       |                     t          t          j         |d           |                       d S )Nr   BytesIOStringIOr!   r"   abcr   )	r#   ior/   r0   r$   encodegetvaluer   r   )r   r(   r/   r0   infpoutfps         r   test_encodez LegacyBase64TestCase.test_encode;   s   ((((((((w 9 : : 		dE"""
5>>3	4 	4 	4
 	)V]HHUOOWWYYOOO)V]GGFOOXXZZPPP)V]HHUOOXXZZPPPPPr   c                 
   ddl m}m}  |d          } |            }t          j        ||           |                     |                                d           |                     t          t          j	         |d           |                       |                     t          t          j	         |d           |                       |                     t          t          j	         |d           |                       d S )Nr   r.      d3d3LnB5dGhvbi5vcmc=r   zYWJj
r    )
r2   r/   r0   r$   decoder#   r4   r   r   r3   )r   r/   r0   r5   r6   s        r   test_decodez LegacyBase64TestCase.test_decodeL   s    ((((((((w.//		dE"""))+<===)V]HHX4F4F		RRR)V]GGI4F4F

SSS)V]HHX4F4F

SSSSSr   N)__name__
__module____qualname__r   r)   r,   r7   r;    r   r   r   r   
   sg        2 2 23 3 3&3 3 3&Q Q Q"	T 	T 	T 	T 	Tr   r   c                       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d Zd Zd Zd Zd Zd Zd Z d Z!d S )!BaseXYTestCasec                 v    |                      t          |d           |                      t          |g            d S )Nr	   r   r   r   r   s     r   check_encode_type_errorsz'BaseXYTestCase.check_encode_type_errors\   s8    )Q+++)Q+++++r   c                 >    |                      t          |g            d S NrC   rD   s     r   check_decode_type_errorsz'BaseXYTestCase.check_decode_type_errors`   s     )Q+++++r   c                 ~   | j         }t          |          } | ||          |            |||            | |t          |                    |            | |t          d|                    |           |                     t
          j        |           |                     t
          j        |           d S )Nr
   )r#   r&   r   r   check_nonbyte_element_formatr$   	b64encodecheck_multidimensional)r   r   
bytes_dataexpectedr(   bs         r   check_other_typesz BaseXYTestCase.check_other_typesc   s    j!!
11Q44
1j
11Z
##$$h///
11U3
##$$h///))&*:JGGG##F$4jAAAAAr   c                     t          |          dz  rdnd}||z   }t          |          dz  df}t          |                              d|          }|                      ||           ||                     d S )Nr       r   r
   lenr   r   r#   )r   r   datapaddingrM   shaper   s          r   rL   z%BaseXYTestCase.check_multidimensionalo   s     YY]3''G^
ZA%q)%j1166sEBB+,,aa
mm<<<<<r   c                     ddt          |          z
  dz  z  }||z   }t          |                              d          }|                      ||           ||                     d S )NrR      r   rS   )r   r   rU   rV   rM   r   s         r   rJ   z+BaseXYTestCase.check_nonbyte_element_formatv   sk    a#d))mq01G^
j))..s338aa
mm44444r   c           	      |   | j         } |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        d	          d
            |t          j        d          d            |t          j        d          d            |t          j        dd          d            |t          j        dt          d                    d            |t          j        dt	          d                    d            |t          j        dt          dd                    d           |                     t          j        dd           |                     t          j                   |                     t          t          j        dd            |t          j
        d          d            |t          j
        d          d            |t          j
        d          d            |t          j
        d	          d
            |t          j
        d          d            |t          j
        d          d           |                     t          j
        dd           |                     t          j
                    |t          j        d          d           |                     t          j        dd           |                     t          j                   d S )Nr   r9   rR      AA==r      YQ==r      YWI=r      YWJjr   r!   sp   YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NTY3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==   Vo   *$altchars   01a*b$cdr
      abcds   YWJjZA==z*$   01a-b_cd)r#   r$   rK   r&   r   r   rP   rE   r   r   standard_b64encodeurlsafe_b64encoder'   s     r   test_b64encodezBaseXYTestCase.test_b64encode}   sV   
6-..0GHHH
6G$$g...
6D!!7+++
6E""G,,,
6F##W---
6C  #&&&
6 > ? ?1	2 	2 	2 	61EBBBKPPP
61Ie<L<LMMM	 	 	
61Ju<M<MNNN	 	 	
61E#u<M<MNNN	 	 	 	v/+FFF%%f&6777)V%5sTJJJ
6$%6779PQQQ
6$T**G444
6$U++W555
6$V,,g666
6$S))3///
6$ &G H H1	2 	2 	2 	v8&	5 	5 	5%%f&?@@@
6#$9::KHHHv74k	C 	C 	C%%f&>?????r   c                    | j         }dddddddd}|                                D ]T\  }} |t          j        |          |            |t          j        |                    d	                    |           U|                     t          j        d
d           |                     t          j                   ddi}|                                D ]\  \  }}}|                    d	          }|                    d	          } |t          j        ||          |            |t          j        ||          |            |t          j        ||          |            |t          j        ||          |           |                                D ]T\  }} |t          j        |          |            |t          j        |                    d	                    |           U|                     t          j        d
d           |                     t          j                   ddd}	|	                                D ]T\  }} |t          j        |          |            |t          j        |                    d	                    |           U|                     t          j        dd           |                     t          j                   d S )Nr   rR   r   r   r   r!   r   )r9   r[   r\   r]   r^   sq   YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0
NTY3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==r   asciir^   )rc   r`   r_   ra   )re   r   re   )	r#   itemsr$   	b64decoder:   rP   rH   standard_b64decodeurlsafe_b64decode)
r   r(   testsrU   restests_altcharsrb   data_straltchars_strtests_urlsafes
             r   test_b64decodezBaseXYTestCase.test_b64decode   s   *;! 
3    	< 	<ID#Bv%%s+++BvG 4 455s;;;;v/&AAA%%f&6777 /0E %3%9%9%;%; 	G 	G!T8c{{7++H#??733LBvx888#>>>Bv8<<<cBBBBv|<<<cBBBBv<@@@#FFFF  	E 	EID#Bv(..444Bv(W)=)=>>DDDDv8'6JJJ%%f&?@@@ '<!  ',,.. 	D 	DID#Bv'--s333Bv'G(<(<==sCCCCv74	6 	6 	6%%f&>?????r   c                     |                      t          j        t          j        d           |                      t          j        t          j        d           d S )Nr   r1   )r   binasciiErrorr$   rl   r   s    r   test_b64decode_padding_errorz+BaseXYTestCase.test_b64decode_padding_error   sB    (.&*:FCCC(.&*:EBBBBBr   c           
      n   d}t           j        t           j        t           j        f}|D ]8\  }}|D ]}|                     ||          5  |                      ||          |           |                      ||                    d                    |           d d d            n# 1 swxY w Y   |                     t          j	                  5  t          j        |d           d d d            n# 1 swxY w Y   |                     t          j	                  5  t          j        |                    d          d           d d d            n# 1 swxY w Y   :d}|                     t          j        dd          |           |                     t          j        d	          |           d S )
N)
)s   %3d==   )s   $3d==r|   )s   [==r   )s   YW]3=s   am)s   3{d==r|   )s   3d}==r|   )s   @@r   )   !r   )r    r   )s	   YWJj
YWI=s   abcab)bstrfuncrj   T)validates   s   ++[[//]]s   []s   ++--//__)
r$   rl   rm   rn   subTestr#   r:   r   rw   rx   )r   ro   funcsr~   rp   r   s         r   test_b64decode_invalid_charsz+BaseXYTestCase.test_b64decode_invalid_chars   s   	, %$

  	F 	FID# F F\\t$\77 F F$$TT$ZZ555$$TT$++g*>*>%?%?EEEF F F F F F F F F F F F F F F ""8>22 6 6 55556 6 6 6 6 6 6 6 6 6 6 6 6 6 6""8>22 F F W!5!5EEEEF F F F F F F F F F F F F F F *)+u==sCCC1+>>DDDDDs7   	AB''B+.B+C55C9	<C9	*EE	E	c                 8   | j         } |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        d          d	            |t          j        d
          d            |t          j        d          d           |                     t          j        d
d           |                     t          j                   d S )Nr   rR      AA======r      ME======r      MFRA====r      MFRGG===rd      MFRGGZA=   abcde   MFRGGZDF)r#   r$   	b32encoderP   rE   r'   s     r   test_b32encodezBaseXYTestCase.test_b32encode  s   
6C  #&&&
6G$$k222
6D!!;///
6E""K000
6F##[111
6G$$k222
6H%%{333v/+FFF%%f&677777r   c                 z   | j         }dddddddd}|                                D ]T\  }} |t          j        |          |            |t          j        |                    d	                    |           U|                     t          j        d
d           |                     t          j                   d S )Nr   rR   r   r   r   rd   r   )r   r   r   r   r   r   r   rj   r   )r#   rk   r$   	b32decoder:   rP   rH   r   r(   ro   rU   rp   s        r   test_b32decodezBaseXYTestCase.test_b32decode  s    %"#$%&   	< 	<ID#Bv%%s+++BvG 4 455s;;;;v/fEEE%%f&677777r   c                 r   | j         }dddddddddddd}|                                D ]V\  }} |t          j        |d          |            |t          j        |                    d	          d          |           W|                     t          j        t          j        d
           |                     t          j        t          j        d            |t          j        d          d            |t          j        d          d           ddd}|                                D ]	\  \  }}}|                    d	          }|                    d	          } |t          j        ||          |            |t          j        ||          |            |t          j        ||          |            |t          j        ||          |           |                     t          j        t          j        |           |                     t          j        t          j        |           d S )Nr   r   r   r   rd   r   )r   r   r   r   r   r      me======s   mfra====s   mfrgg===s   mfrggza=s   mfrggzdfTrj   r   zme======s   MLO23456s   bݭMLO23456s   b))   M1023456   L)r      I)map01)r#   rk   r$   r   r:   r   rw   rx   )	r   r(   ro   rU   rp   	map_testsr   rr   	map01_strs	            r   test_b32decode_casefoldz&BaseXYTestCase.test_b32decode_casefold)  sF   "#$%&"#$%&   	B 	BID#Bvd++S111BvG 4 4d;;SAAAA(.&*:KHHH(.&*:JGGG 	6K((*>???
6J'')=>>>*>*> 	 #,//"3"3 		J 		JMT53{{7++HW--IBvE222C888Bv666<<<BvI666<<<Bv	:::C@@@hnf.>EEEhnf.>IIII		J 		Jr   c                    g d}g d}t          dd          D ]R}|r|                    d|z             |D ]3}t          |          |z   dk    r|                    |d|z  z              4S|D ]}|                     |          5  |                     t
          j                  5  t          j        |           d d d            n# 1 swxY w Y   |                     t
          j                  5  t          j        |	                    d                     d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d S )	N)r      ABCDEF==   ==ABCDEF   Ms   MEs   MFRAs   MFRGGs   MFRGGZAr   r         =   )rU   rj   )
rangeappendrT   r   r   rw   rx   r$   r   r:   r   ro   prefixesiprefixrU   s         r   test_b32decode_errorz#BaseXYTestCase.test_b32decode_errorR  s   222LLLq" 	2 	2A %T!V$$$" 2 2v;;?a''LL$q&1112  	; 	;D4(( ; ;&&x~66 + +$T***+ + + + + + + + + + + + + + +&&x~66 ; ;$T[[%9%9:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ;	; 	;Z    D<&C;D<CD<C"D<1(D%D<%D))D<,D)-D<<E 	E 	c                     g d}|D ][\  }}|                      |          5  |                     t          j        |          |           d d d            n# 1 swxY w Y   \d S )N))r   r   )rR      00======)r      C4======)r      C5H0====)r      C5H66===)rd      C5H66P0=)r      C5H66P35	to_decode)r   r#   r$   b32hexencode)r   
test_cases	to_encoderN   s       r   test_b32hexencodez BaseXYTestCase.test_b32hexencodeb  s    	
 	
 	

 $. 	K 	KIx	22 K K  !4Y!?!?JJJK K K K K K K K K K K K K K K	K 	Ks   )AA	A	c                     |                      t          j        dd           |                     t          j                   d S )Nrd   r   )rP   r$   r   rE   ry   s    r   test_b32hexencode_other_typesz,BaseXYTestCase.test_b32hexencode_other_typesq  s:    v2G[III%%f&9:::::r   c           	      H   g d}|D ]\  }}}|                      ||          5  |                     t          j        ||          |           |                     t          j        |                    d          |          |           d d d            n# 1 swxY w Y   d S )N))r   r   F)r   rR   F)r   r   F)r   r   F)r   r   F)r   rd   F)r   r   F)r   r   T)r   rR   T)r   r   T)r   r   T)r   r   T)r   rd   T)r   r   T)   c4======r   T)s   c5h0====r   T)s   c5h66===r   T)s   c5h66p0=rd   T)s   c5h66p35r   T)r   casefoldrj   )r   r#   r$   b32hexdecoder:   )r   r   r   rN   r   s        r   test_b32hexdecodez BaseXYTestCase.test_b32hexdecodeu  s   
 
 

, .8 	6 	6)Ix	HEE 6 6  !4Y!I!I!)+ + +  !4Y5E5Eg5N5N!)"+ "+,46 6 66 6 6 6 6 6 6 6 6 6 6 6 6 6 6	6 	6s   A&BB	B	c                     |                      t          j        dd           |                     t          j                   d S )Nr   r   )rP   r$   r   rH   ry   s    r   test_b32hexdecode_other_typesz,BaseXYTestCase.test_b32hexdecode_other_types  s:    v2KHHH%%f&9:::::r   c                    g d}g d}t          dd          D ]R}|r|                    d|z             |D ]3}t          |          |z   dk    r|                    |d|z  z              4S|D ]}|                     |          5  |                     t
          j                  5  t          j        |           d d d            n# 1 swxY w Y   |                     t
          j                  5  t          j        |	                    d                     d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d S )	N)r   r   r   r   r   r   r   r   r   r   rj   )
r   r   rT   r   r   rw   rx   r$   r   r:   r   s         r   test_b32hexdecode_errorz&BaseXYTestCase.test_b32hexdecode_error  s   ???LLLq" 	2 	2A %T!V$$$" 2 2v;;?a''LL$q&1112  	> 	>D-- > >&&x~66 . .'---. . . . . . . . . . . . . . .&&x~66 > >'G(<(<===> > > > > > > > > > > > > > >> > > > > > > > > > > > > > >	> 	>r   c                    | j         } |t          j        d          d            |t          j        d          d           |                     t          j        dd           |                     t          j                   d S )N   
   0102ABCDEFrR      00)r#   r$   	b16encoderP   rE   r'   s     r   test_b16encodezBaseXYTestCase.test_b16encode  s    
6344mDDD
6G$$e,,,v/1H,	. 	. 	.%%f&677777r   c                 b   | j         } |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        d          d           |                     t          j        t          j        d           |                     t          j        t          j        d            |t          j        dd	          d            |t          j        dd	          d           |                     t          j        dd           |                     t          j                    |t          j        t          d          d	          d            |t          j        t          d          d	          d            |t          j        t          d
d          d	          d           |                     t          j        t          j        d           |                     t          j        t          j        d           d S )Nr   r   
0102ABCDEFr   rR   00s
   0102abcdef
0102abcdefTr
   0102AG010)r#   r$   	b16decoder   rw   rx   rP   rH   r&   r   r   r'   s     r   test_b16decodezBaseXYTestCase.test_b16decode  s   
6M**,CDDD
6L))+BCCC
6E""G,,,
6D!!7+++(.&*:MJJJ(.&*:LIII
6M4002IJJJ
6L$//1HIIIv/6	8 	8 	8%%f&6777
6Im44d;;"	$ 	$ 	$
6J}55t<<"	$ 	$ 	$
6E#}55t<<"	$ 	$ 	$ 	(.&*:HEEE(.&*:EBBBBBr   c                    | j         }ddddt          t          d                    ddddd	d
dddddddddddddddi}|                                D ]l\  }} |t	          j        |          ||            |t	          j        |d          ||            |t	          j        |d          d|z   dz   |           m|                     t          j        dd           |                     t          t          j        d            |t	          j        dd d!          d"            |t	          j        d#d d!          d$            |t	          j        dd d!          d%            |t	          j        d&dd'          d(            |t	          j        d)dd'          d*            |t	          j        d+dd'          d,            |t	          j        d-dd'          d.           d S )/Nr   r      GB\6`E-ZP=Df.1GEb>   s?  !!*-'"9eu7#RLhG$k3[W&.oNg'GVB"(`=52*$$(B+<_pR,UFcb-n-Vr/1iJ-0JP==1c70M3&s#]4?Ykm5X@_(6q'R884cEH9MJ8X:f1+h<)lt#=BSg3>[:ZC?t!MSA7]@cBPD3sCi+'.E,fo>FEMbNG^4U^I!pHnJ:W<)KS>/9Ll%"IN/`jYOHG]iPa.Q$R$jD4S=Q7DTV8*TUnsrdW2ZetXKAY/Yd(L?['d?O\@K2_]Y2%o^qmn*`5Ta:aN;TJbg"GZd*^:jeCE.%f\,!5gtgiEi8N\UjQ5OekiqBum-X60nF?)@o_%qPq"ad`r;HTr!   g   @:E_WAS,RgBkhF"D/O92EH6,BF`qtRH$VbC6UX@47n?3D92&&T:Jand;cHat='/U/0JP==1c70M3&r-I,;<FN.OZ`-3]oSW/g+A(H[P   no padding..   DJpY:@:Wn_DJ(RS   zero compression       H=_,8+Cf>,E,oN2F(oQ1z   zero compression      H=_,8+Cf>,E,oN2F(oQ1!!!!   Boundary:       6>q!aA79M(3WK-[!!   Space compr:       ;fH/TAKYK$D/aMV+<VdL      rr      s8N      s8W*      s8W-!FadobeT   <~   ~>r	      )wrapcolr   s   GB\6`E-
ZP=Df.1
GEb>s       www.python.orgs   zGB\6`E
-ZP=Df.
1GEb>s   <~GB\6`
E-ZP=Df
.1GEb>
~>           
foldspacesr      yy             y+<Vd            y+<U           y+9)	r#   bytesr   rk   r$   	a85encoderP   r   r   r   s        r   test_a85encodezBaseXYTestCase.test_a85encode  s_    5%**  2I/')A%'B "6!8Uvwx-2  	N 	NID#Bv%%sD111BvE222C>>>BvD11153;3FMMMMv/1B5	7 	7 	7 	)V%5r:::
6-qFFF%	' 	' 	'
65qNNN&	( 	( 	(
6-qEEE+	- 	- 	- 	6Ft5AAA5III
6Ft5AAA8LLL
6Ft5AAA7KKK
6Ft5AAA6JJJJJr   c                 2   | j         }ddddt          t          d                    ddddd	d
dddddddddddddddi}|                                D ]#\  }} |t	          j        |          |           $|                     t          j        dd           d S )Nr   r      cXxL#aCvlSZ*DGca%Tr   ?  009C61O)~M2nh-c3=Iws5D^j+6crX17#SKH9337XAR!_nBqb&%C@Cr{EG;fCFflSSG&MFiI5|2yJUu=?KtV!7L`6nNNJ&adOifNtP*GA-R8>}2SXo+ITwPvYU}0ioWMyV&XlZI|Y;A6DaB*^Tbai%jczJqze0_d@fPsR8goTEOh>41ejE#<ukdcy;l$Dm3n3<ZJoSmMZprN9pq@|{(sHv)}tgWuEu(7hUw6(UkxVgH!yuH4^z`?@9#Kp$P$jQpf%+1cv(9zP<)YaD4*xB0K+}+;a;Njxq<mKk)=;`X~?CtLF@bU8V^!4`l`1$(#{Qdpr!   g   VPa!sWoBn+X=-b1ZEkOHadLBXb#`}nd3r%YLqtVJM@UIZOH55pPf$@(Q&d$}S6EqEFflSSG&MFiI5{CeBQRbjDkv#CIy^osE+AW7dwlr      Zf_uPVPs@!Zf7nor      dS!BNAY*TBaB^jHb7^mG00000r      dS!BNAY*TBaB^jHb7^mG0000r      LT`0$WMOi7IsgCw00r      Q*dEpWgug3ZE$irARr(hr      {{r      |Njr      |Ns9r      |NsC0)r#   r   r   rk   r$   	b85encoderP   r   s        r   test_b85encodezBaseXYTestCase.test_b85encode  s     4%**  6H//1M+-H,.F!8Uvwx-
2  	, 	,ID#Bv%%s++++v/1B4	6 	6 	6 	6 	6r   c                    | j         }ddt          t          d                    dddddd	d
dddd}|                                D ]\  }} |t	          j        |          ||            |t	          j        |d          ||            |t	          j        |                    d          d          ||            |t	          j        d|z   dz   d          ||            |t	          j        |dz   d          ||            |t	          j        d|                    d          z  d          ||            |t	          j        ddd          d            |t	          j        ddd          d            |t	          j        ddd          d            |t	          j        ddd          d           |                     t          j        dd           d S ) Nr   r   r   r!   r   r   r   r   r   r   r   r   r   )r   r   sJ  ! ! * -'"
		9eu
7#  RLhG$k3[W&.oNg'GVB"(`=52*$$(B+<_pR,UFcb-n-Vr/1iJ-0JP==1c70M3&s#]4?Ykm5X@_(6q'R884cEH9MJ8X:f1+h<)lt#=BSg3>[:ZC?t!MSA7]@cBPD3sCi+'.E,fo>FEMbNG^4U^I!pHnJ:W<)KS>/9Ll%"IN/`jYOHG]iPa.Q$R$jD4S=Q7DTV8*TUnsrdW2ZetXKAY/Yd(L?['d?O\@K2_]Y2%o^qmn*`5Ta:aN;TJbg"GZd*^:jeCE.%f\,!5gtgiEi8N\UjQ5OekiqBum-X60nF?)@o_%qPq"ad`r;HTr   r   r   r   r   r   r   r   r   r   Fr   rj   r   r   Tz<~%s~>r   r   r   r   r   r   r   r   r   r   )r#   r   r   rk   r$   	a85decoder:   rP   r   s        r   test_a85decodezBaseXYTestCase.test_a85decode   s6    $5 "%**--- /&I)H">%8- 2  	 	ID#Bv%%sD111BvE222C>>>BvG 4 4EBBBCNNNBvu 4DAAA3MMMBvuD9993EEEBv4;;w+?+? ?tLLLD    	6Ed%@@@&III
6HUCCCVLLL
6GEBBBFKKK
6Ft5AAA6JJJv/1G0	2 	2 	2 	2 	2r   c                 |   | j         }ddt          t          d                    dddddd	d
dddd}|                                D ]T\  }} |t	          j        |          |            |t	          j        |                    d                    |           U|                     t          j        dd           d S )Nr   r   r   r!   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r  r  r  r  r  r  r  rj   r   )r#   r   r   rk   r$   	b85decoder:   rP   r   s        r   test_b85decodezBaseXYTestCase.test_b85decodeM  s     #4 #5::..6 /*M)H&F%8-
 
2  	< 	<ID#Bv%%s+++BvG 4 455s;;;;v/1F0	2 	2 	2 	2 	2r   c                    | j         } |t          j        dd          d            |t          j        dd          d            |t          j        dd          d            |t          j        d	d          d
            |t          j        dd          d            |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        d
          d	            |t          j        d          d           d S )N   xTpads   GQ7^D   xxs   G^'2g   xxxs   G^+H5   xxxxs   G^+IX   xxxxxs
   G^+IXGQ7^D   x      xx     xxx    xxxxx   )r#   r$   r   r  r'   s     r   test_a85_paddingzBaseXYTestCase.test_a85_paddingp  M   
6Dd+++X666
6Et,,,h777
6F---x888
6G...999
6H$///???
6H%%'7888
6H%%}555
6H%%z222
6H%%w///
6M**,@AAAAAr   c                    | j         } |t          j        dd          d            |t          j        dd          d            |t          j        dd          d            |t          j        d	d          d
            |t          j        dd          d            |t          j        d          d            |t          j        d          d            |t          j        d          d            |t          j        d
          d	            |t          j        d          d           d S )Nr  Tr  s   cmMzZr  s   cz6H+r  s   czAdKr  s   czAetr  s
   czAetcmMzZr  r  r  r  )r#   r$   r  r  r'   s     r   test_b85_paddingzBaseXYTestCase.test_b85_padding  r  r   c                 
   t          t          d                    t          t          dd                    z  t          d          z
  }|D ]?}|                     t          t	          |g                    5  t          j        dt	          |g          z              d d d            n# 1 swxY w Y   |                     t          t	          |g                    5  t          j        dt	          |g          z   d           d d d            n# 1 swxY w Y   |                     t          t	          |g                    5  t          j        d	t	          |g          z   d
z   d           d d d            n# 1 swxY w Y   A|                     t          t
          j        dd           |                     t          t
          j        dd           |                     t          t
          j        d           |                     t          t
          j        dd           t          j        dd           |                     t          t
          j        dd           |                     t          t
          j        dd           |                     t          t
          j        ddd           |                     t          t
          j        dd           |                     t          t
          j        dd           |                     t          t
          j        dd           |                     t          t
          j        dd           |                     t          t
          j        dd           d S )N    v      s    	
msgs   !!!!Fr   s   <~!!!!r   Ts	   malformeds   <~still malformeds   <~~>s   abcxs   abcdeys   a b
cr   )r   ignorechars   ss   s8s   s8Ws   s8W-s   s8W-")setr   r   
ValueErrorr   r$   r  r   illegalcs      r   test_a85decode_errorsz$BaseXYTestCase.test_a85decode_errors  s   uRyy>>Cc3$8$88C<M<MM 	M 	MA"":5!::">> 7 7 5!::!56667 7 7 7 7 7 7 7 7 7 7 7 7 7 7"":5!::">> D D 5!::!5UCCCCD D D D D D D D D D D D D D D"":5!::">> M M UA3ZZ!7%!?tLLLLM M M M M M M M M M M M M M M 	*f&6&2$ 	 	@ 	@ 	@*f&6&:$ 	 	H 	H 	H 	*f&6&-	/ 	/ 	/*f&6&-U 	 	< 	< 	<----*f&6&-U 	 	< 	< 	<*f&6&/u 	 	> 	> 	>*f&6&/u# 	 	O 	O 	O 	*f&6EJJJ*f&6UKKK*f&6eLLL*f&6uMMM*f&6NNNNNs6   :&B,,B0	3B0	!(DD	D	
+FF	F	c                    t          t          d                    t          d          z   t          t          dd                    z   }|D ]i}|                     t          t	          |g                    5  t          j        dt	          |g          z              d d d            n# 1 swxY w Y   j|                     t          t
          j        d           |                     t          t
          j        d           |                     t          t
          j        d	           |                     t          t
          j        d
           |                     t          t
          j        d           d S )N!   s	   "',./:[\]   r#  r$  s   0000   |s   |Ns   |Nss   |NsCs   |NsC1)listr   r   r)  r   r$   r  r*  s      r   test_b85decode_errorsz$BaseXYTestCase.test_b85decode_errors  sp   uRyy//~&&'uS#''(  	7 	7A"":5!::">> 7 7 5!::!56667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 	*f&6===*f&6>>>*f&6???*f&6@@@*f&6AAAAAs   9&B++B/	2B/	c                     t           j        t           j        t           j        t           j        t           j        t           j        t           j        f}|D ]}|                     t          |d           d S )Nu   with non-ascii Ë)
r$   rl   rm   rn   r   r   r  r  r   r)  )r   decode_funcsr   s      r   test_decode_nonascii_strz'BaseXYTestCase.test_decode_nonascii_str  sn    (10((((*  	D 	DAj!-BCCCC	D 	Dr   c                 j    |                      t          t          j        t                               d S rG   )
assertTrue
issubclassrw   rx   r)  ry   s    r   test_ErrorHeritagez!BaseXYTestCase.test_ErrorHeritage  s&    
8>:>>?????r   c                 .   t           j        }t           j        }t           j        }t           j        }|                      |d          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d          d	           |                      |d
          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d
          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d
          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d          d           |                      |d
          d           |                      |d          d           d S ) Nr      fs   Zg==s   fos   Zm8=s   foos   Zm9vs   foobs   Zm9vYg==s   foobas   Zm9vYmE=s   foobars   Zm9vYmFys   MY======s   MZXQ====s   MZXW6===s   MZXW6YQ=s   MZXW6YTBs   MZXW6YTBOI======s   CO======s   CPNG====s   CPNMU===s   CPNMUOG=s   CPNMUOJ1s   CPNMUOJ1E8======s   66s   666Fs   666F6Fs   666F6F62s
   666F6F6261s   666F6F626172)r$   rK   r   r   r   r#   )r   rK   r   r   r   s        r   test_RFC4648_test_casesz&BaseXYTestCase.test_RFC4648_test_cases  s   $	*$	$	3---4'2225))73336**G4447++[9998,,k:::9--{;;;3---4+6665));7776**K8887++[9998,,k:::9--/BCCCc**C000d++[999e,,k:::f--{;;;g..<<<h//===i002EFFF3---4%0005))73336**I6667++[9998,,m<<<9--?????r   N)"r<   r=   r>   rE   rH   rP   rL   rJ   rh   ru   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r	  r  r  r  r  r-  r3  r6  r:  r=  r?   r   r   rA   rA   X   s        , , ,, , ,
B 
B 
B= = =5 5 50@ 0@ 0@d6@ 6@ 6@pC C CE E E@8 8 88 8 8"'J 'J 'JR; ; ; K K K; ; ;6 6 6<; ; ;> > >"8 8 8C C C60K 0K 0Kd 6  6  6D+2 +2 +2Z!2 !2 !2FB B BB B B!O !O !OFB B B	D 	D 	D@ @ @%@ %@ %@ %@ %@r   rA   c                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
TestMainc                     t           j                            t          j                  r t          j        t          j                   d S d S rG   )ospathexistsr   TESTFNunlinkry   s    r   tearDownzTestMain.tearDown  s>    7>>)*++ 	(Ii&'''''	( 	(r   c                 2    t          j        ddg|R  j        S )N-mr$   )r   assert_python_okout)r   argss     r   
get_outputzTestMain.get_output  s     -dHDtDDDHHr   c                     |                      d          }|                     |                                d           d S )Nz-t)   b'Aladdin:open sesame's!   b'QWxhZGRpbjpvcGVuIHNlc2FtZQ==\n'rN  )rL  assertSequenceEqual
splitlinesr   outputs     r   test_encode_decodezTestMain.test_encode_decode  sH    &&  !2!2!4!4 7
 	 	 	 	 	r   c                 $   t          t          j        d          5 }|                    d           d d d            n# 1 swxY w Y   |                     dt          j                  }|                     |                                d           d S )Nwb   ab
-e   Yf9iCg==openr   rD  writerL  r#   rstripr   fprR  s      r   test_encode_filezTestMain.test_encode_file  s    )"D)) 	"RHH[!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"y'788+66666   =AAc                    t          j        ddd          5 }|                    d          \  }}d d d            n# 1 swxY w Y   |                     |                                d           |                     |           d S )NrH  r$   rW  rV  rX  )r   spawn_pythoncommunicater#   r\  assertIsNone)r   procrJ  errs       r   test_encode_from_stdinzTestMain.test_encode_from_stdin  s    'h== 	5''44HC	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5{333#s   <A A c                 $   t          t          j        d          5 }|                    d           d d d            n# 1 swxY w Y   |                     dt          j                  }|                     |                                d           d S )NrU  rX  z-ds   abrY  r]  s      r   r;   zTestMain.test_decode  s    )"D)) 	"RHH[!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"y'788)44444r`  c                     |                      d          }|                     d|           |                     d|           d S )Nz-h   usage:    -d, -u: decode)rL  assertInrQ  s     r    test_prints_usage_with_help_flagz)TestMain.test_prints_usage_with_help_flag  sB    &&j&)))'00000r   c                     t          j        ddd          j        }|                     d|           |                     d|           d S )NrH  r$   z-xrj  rk  )r   assert_python_failurerf  rl  rQ  s     r   #test_prints_usage_with_invalid_flagz,TestMain.test_prints_usage_with_invalid_flag  sH    4T8TJJNj&)))'00000r   N)r<   r=   r>   rF  rL  rS  r_  rg  r;   rm  rp  r?   r   r   r?  r?    s        ( ( (I I I  7 7 7  5 5 51 1 1
1 1 1 1 1r   r?  __main__)unittestr$   rw   rA  r   test.supportr   r   TestCaser   rA   r?  r<   mainr?   r   r   <module>rv     s/      				       " " " " " " & & & & & &KT KT KT KT KT8, KT KT KT\Z
@ Z
@ Z
@ Z
@ Z
@X& Z
@ Z
@ Z
@z*1 *1 *1 *1 *1x  *1 *1 *1X zHMOOOOO r   