
    ;e:                         d Z ddlZddlmZ ddlmZ  G d d          Z G d deej                  Z G d	 d
eej                  Z	e
dk    r ej        dd           dS dS )zi Test mock_tk.Text class against tkinter.Text class

Run same tests with both by creating a mixin class.
    N)requires)TclErrorc                   \    e Zd ZdZdZedz   Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZdS )TextTestz*Define items common to both sets of tests.zhello
world
c                     |                      | j                            d          d           |                      | j                            d          d           d S )N1.0r   end )assertEqualtextgetselfs    2/usr/lib/python3.11/idlelib/idle_test/test_text.py	test_initzTextTest.test_init   sP    u--t444u--r22222    c                     | j         j        }dD ]!}|                      ||          d           "dD ]!}|                      ||          d           "d S )N)      333333?1.-1r	   1.0 lineend1.end1.33insertr	   )r
   g       @2.133.442.0)r   indexr   r   r   dexs      r   test_index_emptyzTextTest.test_index_empty   sw    	 	0 	0CUU3ZZ////- 	0 	0CUU3ZZ////	0 	0r   c                 6   | j         j        }| j                             d| j                   dD ]!}|                      ||          d           "dD ]!}|                      ||          d           "dD ]!}|                      ||          d           "d S )Nr	   )r   r   r   r	   )r   r   r   z1.5)r
   r   z3.0)r   r   r   hwr   r    s      r   test_index_datazTextTest.test_index_data    s    		(((+ 	0 	0CUU3ZZ////1 	0 	0CUU3ZZ////" 	0 	0CUU3ZZ////	0 	0r   c                    | j         j        }| j        }| j                             d| 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          | j                    | |dd          | j                    | |dd          | j                   d S )Nr	   r
   r   h1.11.3helelr   hello1.10r   2.3zello
worz2.5z0.0z5.0)r   r   r   r   r$   hwn)r   r   Equals      r   test_getzTextTest.test_get-   s   im 	(((cc%jj"cc%$$$cc%jj#cc%%%%cc%'''cc%&&&cc%''111cc%  '***cc-  $'''cc%---cc%)))cc%***cc%*****r   c                 >   | j         j        }| j         j        }| j        } |d| j                    | |dd          | j                    |dd            | |dd          | 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 S )Nr	   r
   r   *z*hello
world
r   z*hello*
world
r.   z*hello*
wor*ld
xz*hello*
wor*ldx
1.4zx
z*helx
lo*
wor*ldx
)r   r   r   r   r$   r/   )r   r   r   r0   s       r   test_insertzTextTest.test_insert@   s~   !im udgcc%***ubcc%***uccc%!2333}c"""cc%!3444uccc%!4555uccc%!5666uecc%!899999r   c                 T   | j         j        }| j         j        }| j        }| j                             d| j                    |d            | |dd          | j                    |d            | |dd          | j                    |dd            | |dd          | j                    |dd            | |dd          | j                    |dd            | |dd          | j                    |dd            | |dd          | j                   d S )Nr	   r   r
   z5.5r5   )r   deleter   r   r   r$   r/   r   r8   r   r0   s       r   test_no_deletezTextTest.test_no_deleteZ   sb   !im 	(((xcc%***ucc%***xcc%***xcc%***uecc%***uecc%*****r   c                 >   | j         j        }| j         j        }| j        }| j                             d| j                    |d            | |dd          d            |dd            | |dd          d            |d            | |dd          d           | j                             dd            |d	            | |dd          d           | j                             dd            |dd
            | |dd          d           d S )Nr	   r   ellor(   llolloworldr)   r   r-   r   r   r8   r   r   r   r$   r9   s       r   test_delete_charzTextTest.test_delete_chars   sP   !im 	(((ucc%!!6***uecc%!!5))) 	wcc%!!:...	%%%vcc%!!:...	%%%uecc%!!:.....r   c                 X   | j         j        }| j         j        }| j        }| j                             d| j                    |dd            | |dd          d            |dd            | |dd          d           | j                             d| j                    |dd            | |dd          d            |dd            | |dd          d           | j                             d| j                    |dd	            | |dd          d
           d S )Nr	   r   r
   z
world
r   r   zworld
z1.2r.   zheld
r?   r9   s       r   test_delete_slicezTextTest.test_delete_slice   sa   !im 	(((um$$$cc%---uecc%&&&	(((uecc%+++uecc%&&&	(((uecc%*****r   c                 d   | j                             dd           | j                             dd           |                     | j                             dd          d           | j                             dd           |                     | j                             dd          d           d S )	Nr	   r,   r)   z	1
2
3
4
5r
   zhel1
2
3
4
5lo
z5.1zhello
)r   r   r   r   r8   r   s    r   test_multiple_lineszTextTest.test_multiple_lines   s    	(((	000ue446LMMM	&&&ue44i@@@@@r   c                    | j         j        }| j        }| j                             dd           |                     t
          |ddd           dD ]\  }}}}}} | |d|d          ||            | |d|d          ||            | |d|d          ||            | |d|d          ||            | |d	|d          ||           d S )
Nr	   zFirst
Second
Third
z2.2op))<TTFFF)z<=TTTFF)>FFFTT)z>=FFTTT)z==FFTFF)z!=TTFTTr(   r   r.   z3.3)r   comparer   r   assertRaisesr   )	r   rI   r0   rF   less1less0equalgreater0greater1s	            r   test_comparezTextTest.test_compare   s    )# 	 8999(GUD%@@@< 	; 	;7BueXx E''%U++UB777E''%U++UB777E''%U++UB777E''%U++Xr:::E''%U++Xr::::	; 	;r   N)__name__
__module____qualname____doc__r$   r/   r   r"   r%   r1   r6   r:   r@   rB   rD   rP    r   r   r   r   	   s        00	B
T'C
3 3 30 0 00 0 0+ + +&: : :4+ + +2/ / /0+ + +.A A A; ; ; ; ;r   r   c                   0    e Zd Zed             Zd Zd ZdS )MockTextTestc                      ddl m} || _        d S )Nr   )Text)idlelib.idle_test.mock_tkrY   )clsrY   s     r   
setUpClasszMockTextTest.setUpClass   s    222222r   c                 8    |                                  | _        d S N)rY   r   r   s    r   setUpzMockTextTest.setUp   s    IIKK			r   c                    | j         j        }| j        }| j                             d| j                    | |dd          d            | |dd          d            | |dd          d            | |dd          d           d S )Nr	   r
   )      z3.1r   )rb      )r   _decoder   r   r$   )r   decoder0   s      r   test_decodezMockTextTest.test_decode   s    " 	(((ffUB(((ffUB(((ffUQ(((ffUA'''''r   N)rQ   rR   rS   classmethodr\   r_   rg   rU   r   r   rW   rW      sK          [     	( 	( 	( 	( 	(r   rW   c                   @    e Zd Zed             Zed             Zd ZdS )
TkTextTestc                 `    t          d           ddlm}m} || _         |            | _        d S )Nguir   )TkrY   )r   tkinterrm   rY   root)r[   rm   rY   s      r   r\   zTkTextTest.setUpClass   s=    $$$$$$$$244r   c                 <    | j                                          | ` d S r^   )ro   destroy)r[   s    r   tearDownClasszTkTextTest.tearDownClass   s    HHHr   c                 D    |                      | j                  | _        d S r^   )rY   ro   r   r   s    r   r_   zTkTextTest.setUp   s    IIdi((			r   N)rQ   rR   rS   rh   r\   rr   r_   rU   r   r   rj   rj      sW          [   [) ) ) ) )r   rj   __main__rb   F)	verbosityexit)rT   unittesttest.supportr   _tkinterr   r   TestCaserW   rj   rQ   mainrU   r   r   <module>r|      s      ! ! ! ! ! !      v; v; v; v; v; v; v; v;r( ( ( ( (8X. ( ( (.) ) ) ) )8, ) ) )$ zHMAE****** r   