
    ;OOf                        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  G d dej                        Z G d dej                        Z	 G d d	ej                        Z
 G d
 dej                        Z G d dej                        Z G d dej                        Z ej                  e j                  dk(  d       G d dej                               Zy)    N)util)Bc                       e Zd Zd Zd Zd Zy)CalcWidthTestc                     t        |      }t        j                  |dt        |            }||k(  sJ |d|d|       y )Nr    got:
 expected:)r   r   
calc_widthlen)selfdescsexpresults        V/var/www/premiumrankchecker/venv/lib/python3.12/site-packages/urwid/tests/test_util.pywtestzCalcWidthTest.wtest   s9    aD!QA/s{ItVSII{    c                     t        j                  d       | j                  ddd       | j                  ddd       | j                  dd	d
       | j                  ddd       | j                  ddd       y )Nutf-8narrowhello   z	wide charu   æ¿   invalid   æ   z
zero widthu   Ìr   mixedu   helloæ¿æ¿	   r   set_encodingr   r   s    r   test1zCalcWidthTest.test1   sa    '"

8Wa(

;2

9fa(

<Q/

7;Q?r   c                     t        j                  d       | j                  ddd       | j                  ddd       | j                  dd	d
       y )Neuc-jpr   r   r   wideu   ¡¡¡¡   r      ¡r   r   r!   s    r   test2zCalcWidthTest.test2   sA    (#

8Wa(

6-q1

9fa(r   N)__name__
__module____qualname__r   r"   r(    r   r   r   r      s    J
@)r   r   c                       e Zd Zd Zd Zy)ConvertDecSpecialTestc                    t        |      }t        j                  d       t        j                  |      j                  d      }|j                  d   }||k(  sJ |d|d|       |j                  d   }||k(  sJ |d|d|       y )Nascii)r   r   r   r	   )r   r   r    urwidTextrender_text_cs)r   r   r   r   expcscr   resultcss           r   ctestzConvertDecSpecialTest.ctest!   s    f'"JJqM  &s{ItVSII{558 	L4;CU!L 	Lr   c                    | j                  ddddg       | j                  ddddg       | j                  dd	d
ddg       | j                  dddddg       | j                  dddg d       | j                  dddg d       y )Nzno conversionr   Nr   zonly specialu
   £££££z}}}}})0r   zmix leftu   ££abcz}}abcr<   r   N   z	mix rightu   abc££zabc}}z	mix inneru   a££bcza}}bc)Nr   r=   )Nr   zmix wellu   £a£b£z}a}b})r<   r   r@   rA   r@   rA   )r9   r!   s    r   r"   zConvertDecSpecialTest.test1+   s    

?HgzB

>='G9E

:z7WX4FG

;
Ghw5GH

;
G'	*

:{G7	:r   N)r)   r*   r+   r9   r"   r,   r   r   r.   r.       s    L:r   r.   c                   *    e Zd Zd Zd Zd Zd Zd Zy)WithinDoubleByteTestc                 .    t        j                  d       y )Nr$   )r1   r    r!   s    r   setUpzWithinDoubleByteTest.setUp7   s    8$r   c                 l    t        j                  t        |      ||      }||k(  sJ |d|d|       y )Nr    expected: )r   within_double_byter   )r   r   lsposexpectedr   r   s          r   r   zWithinDoubleByteTest.wtest:   s>    ((1r37x 	OT=CX"O 	Or   c                 T   | j                  ddddd       | j                  ddddd       | j                  ddddd	       | j                  d
dddd       | j                  d
dddd       | j                  ddddd       | j                  ddddd       | j                  ddddd       y )Nmnopqrr   r   zsimple no high bytesu   mn¡¡qrr   zsimple 1st halfr?   zsimple 2nd halfu
   m¡¡¡¡rzsubsequent 1st halfr&   zsubsequent 2nd halfu   mn¡@qrzsimple 2nd half lou   mn¡¡@rzsubsequent not 2nd half lou	   m¡¡¡@rzsubsequent 2nd half lor   r!   s    r   r"   zWithinDoubleByteTest.test1>   s    

8Aa"89

>!Aa(9:

>!Aa(9:

'!A.CD

'!A.CD

;q1%9:

>!Aa(DE

$Qq+CDr   c                 T   | j                  ddddd       | j                  ddddd       | j                  ddddd       | j                  d	dddd
       | j                  d	dddd       | j                  ddddd       | j                  ddddd       | j                  ddddd       y )Nu   ¡¡qrr   r   zbegin 1st halfr   zbegin 2nd halfu   ¡@qrzbegin 2nd half lou	   ¡¡¡¡rzbegin subs. 1st halfr?   zbegin subs. 2nd halfu   ¡¡¡@rzbegin subs. 2nd half lou   ¡@¡@rzbegin subs. 2nd half lo lou   @¡¡@rzbegin subs. not 2nd half lorN   r!   s    r   r(   zWithinDoubleByteTest.test2H   s    

<!A&67

<!A&67

9Qq#67

&q1-CD

&q1-CD

#Aa*CD

=1Q'CD

=1Q'DEr   c                 T   | j                  ddddd       | j                  ddddd       | j                  ddddd	       | j                  d
dddd       | j                  d
dddd       | j                  ddddd       | j                  ddddd       | j                  ddddd       y )Nu
   abc ¡¡qrr&   r   znewline 1st halfr   r   znewline 2nd halfu	   abc ¡@qrznewline 2nd half lou   abc ¡¡¡¡r   znewl subs. 1st half   znewl subs. 2nd halfu   abc ¡¡¡@rznewl subs. 2nd half lou   abc ¡@¡@rznewl subs. 2nd half lo lou   abc @¡¡@rr   znewl subs. not 2nd half lorN   r!   s    r   test3zWithinDoubleByteTest.test3R   s    

#Aa*<=

#Aa*<=

=1Q'<=

*1Qq1FG

*1Qq1FG

'!A.FG

$Qq+FG

$Qq+GHr   N)r)   r*   r+   rE   r   r"   r(   rS   r,   r   r   rC   rC   6   s    %OEFIr   rC   c                   *    e Zd Zd Zd Zd Zd Zd Zy)CalcTextPosTestc                     t        |      }|D ]6  \  }}}}t        j                  ||||      }||k(  r&J |||fd|d|        y )Nr   r	   )r   r   calc_text_pos)r   texttestsr   eprK   gots           r   ctptestzCalcTextPosTest.ctptest^   sb    w$ 	NOAa8$$dAq!5C(? N!Aw?BH%N N?	Nr   c                 4    d}g d}| j                  ||       y )Nzhello world out there)r      r   r   r   )r   r`   r   )r   r   )r   r`   r`   r`   r`   )r   r`   2   rb   )r      rc   )rd      rQ   r`   r   )rQ   r   )rQ   r`   r?   )r   r?   )r]   r   rX   rY   s      r   r"   zCalcTextPosTest.test1e   s    & 	T5!r   c                 ^    t        j                  d       d}g d}| j                  ||       y )Nr$   u   hel¡¡ world out there)r_   )r   r`   r&   )r?   r?   )r   r`   r   r?   r   )r   r`   r?   )r   r?   rf   r   r    r]   rg   s      r   
test2_widezCalcTextPosTest.test2_wider   s,    (#, 	T5!r   c                 ^    t        j                  d       d}g d}| j                  ||       y )Nr   u   helÄ world â there)r_   )r   r`   r&   )r   r&   )r   r`   r   ri   )r   r`   r   )r   r   )r   r`   r?   )rQ   r?   )rQ   r`   rR   )rd   rR   )rQ   r`      )   rm   rj   rg   s      r   
test3_utf8zCalcTextPosTest.test3_utf8~   s,    '"5 	T5!r   c                 ^    t        j                  d       d}g d}| j                  ||       y )Nr   u   heÌllo æ¿ world))r   rd   r   ra   )r   rd   r   )r   r   )r   rd   r   )r&   r   )r   rd   r&   )rQ   r&   )rm   rd   r   rm   r   )rm   rd   r   rq   )rm   rd   r   )   r   )rm   rd   r   )   r   rj   rg   s      r   
test4_utf8zCalcTextPosTest.test4_utf8   s,    '"1	 	T5!r   N)r)   r*   r+   r]   r"   rk   ro   rt   r,   r   r   rU   rU   ]   s    N"
"""r   rU   c            	           e Zd Zddg fdddgfg ddg fddd	d
gfdgdg dfddgdg f ed       ed      g ed      g fgZd Zd Zd Zy)TagMarkupTestz
simple one)bluejohnrx   )rw   r&   )za littzle listza little listmixhighz it )italzup az littlezmix it up a little)r>   )r{   r&   )r|   r&   u   ££u   x££u	   ££x££u   Âu   ÂÂc                     | j                   D ]B  \  }}}t        j                  |      \  }}||k(  sJ d|d|       ||k(  r7J d|d|        y )Nzgot: rG   )mytestsr1   decompose_tagmarkup)r   inputrX   attrrestextresattrs         r   testzTagMarkupTest.test   s^    !% 	ME4#77@OGGd?Lgt$LL?d?Lgt$LL?	Mr   c                 F    | j                  t        j                  d        y )Nc                  ,    t        j                  d      S )N)r   r   r?   r1   r   r,   r   r   <lambda>z.TagMarkupTest.test_bad_tuple.<locals>.<lambda>   s    %%g. r   assertRaisesr1   TagMarkupExceptionr!   s    r   test_bad_tuplezTagMarkupTest.test_bad_tuple   s    %22 5/ 	0r   c                 F    | j                  t        j                  d        y )Nc                  ,    t        j                  d      S r;   r   r,   r   r   r   z-TagMarkupTest.test_bad_type.<locals>.<lambda>   s    %%a( r   r   r!   s    r   test_bad_typezTagMarkupTest.test_bad_type   s    %22 5) 	*r   N)r)   r*   r+   r   r~   r   r   r   r,   r   r   rv   rv      s    	|R(	&:,/	 /26
01)	< ,	. 8	lB/
J-:	'+=)>C	
GM0*r   rv   c                       e Zd Zd Zd Zy)RleTestc                     ddg}|d d  |d d  }}t        j                  |d       t        j                  |d       | j                  |ddg       | j                  |g d       y )NA
   r   rd   )r   r?   Xr   )r   re   )r   r   r   )r   rle_prepend_modifyassertListEqual)r   rle0rle1rle2s       r   test_rle_prependzRleTest.test_rle_prepend   sc    9%!Wd1gdh/h/TIy#9:T#CDr   c                     ddg}|d d  |d d  }}t        j                  |d       t        j                  |d       | j                  |ddg       | j                  |g d       y )Nr   r   )r   r   Kr   )r      )r   r   r   )r   rle_append_modifyr   )r   r   rle3rle4s       r   test_rle_appendzRleTest.test_rle_append   sc    9%!Wd1gdtX.tX.TIy#9:T#CDr   N)r)   r*   r+   r   r   r,   r   r   r   r      s    EEr   r   win32zdoes not run on windows)reasonc                       e Zd Zd Zy)PortabilityTestc                    t        j                         }t        j                  t         j                  d       t	        j
                          | j                  t        j                         d       t        j                  t         j                  d       t	        j
                          | j                  t        j                         d       t        j                  t         j                  |       y )N)NN)en_USzUTF-8)locale	getlocale	setlocaleLC_ALLr   detect_encodingassertEqual)r   initials     r   test_localezPortabilityTest.test_locale   s    ""$5))+\:(:;))+-?@0r   N)r)   r*   r+   r   r,   r   r   r   r      s    1r   r   )sysunittestr   r1   r   urwid.compatr   TestCaser   r.   rC   rU   rv   r   skipIfplatformr   r,   r   r   <module>r      s    
     )H%% )*:H-- :,$I8,, $IN<"h'' <"~*H%% *4Eh E$ (1JK1h'' 1 L1r   