B YI~d��@sddlmZddlmZed�ddlZddlZddlmZm Z m Z m Z m Z ddl mZddlmZddlmZd d �Zd d �ZGd d�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedk�rejdd�dS)�)�textview)�requiresZguiN)�Tk�TclError�CHAR�NONE�WORD)�Button)�Func)� Mbox_funccCst�at��dS)N)r�root�withdraw�rr�D/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_textview.py� setUpModulesrcCst��t��bdS)N)r �update_idletasks�destroyrrrr�tearDownModulesrc@seZdZe�Ze�Ze�ZdS)�VWN)�__name__� __module__� __qualname__r � transient�grab_set� wait_windowrrrrr#src@s,eZdZdd�Zdd�Zdd�Zdd�Zd S) �ViewWindowTestcCs"tj��tj��tj��dS)N)rr�__init__rr)�selfrrr�setUp,s  zViewWindowTest.setUpcCsBttdd�}|�tjj�|�tjj�|�tjj�|��dS)N�Titlez test text)rr � assertTruer�calledrr�ok)r�viewrrr�test_init_modal1s  zViewWindowTest.test_init_modalcCsFttdddd�}|�tjj�|�tjj�|�tjj�|��dS)Nrz test textF)�modal)rr Z assertFalserr!rrr")rr#rrr�test_init_nonmodal8s z!ViewWindowTest.test_init_nonmodalcCs>ttdddd�}t�|_|��|�|jj�|`|��dS)Nrz test textF)r%)rr r rr"r r!)rr#rrr�test_ok?s zViewWindowTest.test_okN)rrrrr$r&r'rrrrr*src@seZdZdd�ZdS)�AutoHideScrollbarTestcCs*t�t�}|�t|j�|�t|j�dS)N)�tvZAutoHideScrollbarr Z assertRaisesr�packZplace)rZscrollrrr�test_forbidden_geometryJs z-AutoHideScrollbarTest.test_forbidden_geometryN)rrrr+rrrrr(Hsr(c@s@eZdZedd��Zedd��Zefdd�Zdd�Zd d �Z d S) �ScrollableTextFrameTestcCst�|_}|��dS)N)rr r )�clsr rrr� setUpClassRs z"ScrollableTextFrameTest.setUpClasscCs|j��|j��|`dS)N)r rr)r-rrr� tearDownClassWs  z%ScrollableTextFrameTest.tearDownClassc s2tj|jfd|i|����fdd�}|�|��S)N�wrapcs������dS)N)rrr)�framerr� cleanup_frame_sz9ScrollableTextFrameTest.make_frame..cleanup_frame)r)ZScrollableTextFramer � addCleanup)rr0�kwargsr2r)r1r� make_frame]s  z"ScrollableTextFrameTest.make_framecCs0|��}|j�dd�|�|j�dd�d�dS)Nz1.0z test textz1.end)r5�text�insert� assertEqual�get)rr1rrr� test_line1esz"ScrollableTextFrameTest.test_line1c Cs�|jtd�}|�|j�d�t�|�|j�xTttgD]H}|j |d��2|j|d�}|�|j�d�|�|� |j�WdQRXq6WdS)N)r0r0) r5rr8r6�cgetZassertIsNotNoneZxscrollrrZsubTest� assertIsNone)rr1r0rrr�test_horiz_scrollbarjs   z,ScrollableTextFrameTest.test_horiz_scrollbarN) rrr� classmethodr.r/rr5r:r=rrrrr,Ps    r,c@s,eZdZedd��Zedd��Zdd�ZdS)� ViewFrameTestcCs&t�|_}|��t�|d�|_dS)Nz test text)rr r r)� ViewFramer1)r-r rrrr.~s zViewFrameTest.setUpClasscCs |`|j��|j��|`dS)N)r1r rr)r-rrrr/�s  zViewFrameTest.tearDownClasscCs |jjj}|�|dd�d�dS)Nz1.0z1.endz test text)r1r6r9r8)rr9rrrr:�s zViewFrameTest.test_line1N)rrrr>r.r/r:rrrrr?|s  r?c@sLeZdZedd��Zedd��Zdd�Zdd�Zd d �Zd d �Z d d�Z dS)�ViewFunctionTestcCstj|_t�t_dS)N)r)� showerror� orig_errorr )r-rrrr.�szViewFunctionTest.setUpClasscCs|jt_|`dS)N)rCr)rB)r-rrrr/�szViewFunctionTest.tearDownClasscCs>tjtdddd�}|�|tj�|�|jtj�|j��dS)Nrz test textF)r%)r)� view_textr �assertIsInstance� ViewWindow� viewframer@r")rr#rrr�test_view_text�szViewFunctionTest.test_view_textcCs\tjtdtddd�}|�|tj�|�|jtj�|jjj j }|� d|dd��|� �dS)Nr�asciiF)r%ZTestz1.0z1.end) r)� view_filer �__file__rErFrGr@� textframer6r9ZassertInr")rr#r9rrr�test_view_file�s  zViewFunctionTest.test_view_filecCs2tjtddddd�}|�|�|�tjjd�dS)Nrzabc.xyzrIF)r%zFile Load Error)r)rJr r<r8rB�title)rr#rrr� test_bad_file�s zViewFunctionTest.test_bad_filecCsRtj}|�|�|�t�dd��}tjtd|ddd�}|� |�|� tj j d�dS)Nz..z CREDITS.txtrrIF)r%zUnicode Decode Error) �os�path�abspath�join�dirnamerKr)rJr r<r8rBrN)r�p�fnr#rrr�test_bad_encoding�s  z"ViewFunctionTest.test_bad_encodingcCs4tjtddddd�}|jjj}|�|�d�d�dS)NrZtestFZnone)r%r0r0)r)rDr rGrLr6r8r;)rr#Z text_widgetrrr� test_nowrap�s zViewFunctionTest.test_nowrapN) rrrr>r.r/rHrMrOrWrXrrrrrA�s  rAc@s,eZdZdd�Zdd�Zdd�Zdd�Zd S) �ButtonClickTestcCsd|_d|_dS)NF)r#r!)rrrrr�szButtonClickTest.setUpcCs|jr|j��dS)N)r#r)rrrr�tearDown�szButtonClickTest.tearDowncsn�fdd�}ttd|d�}|����|j����jd����j��d����jj j j � dd�d �dS) Ncsd�_tjtdddd��_dS)NT� TITLE_TEXT�COMMAND)�_utest)r!r)rDr r#r)rrr�_command�szAButtonClickTest.test_view_text_bind_with_button.._command�BUTTON)r6�commandTr[z1.0z1.endr\) r r �invoker3rr8r!r#rNrGrLr6r9)rr^�buttonr)rr�test_view_text_bind_with_button�s  z/ButtonClickTest.test_view_text_bind_with_buttonc s��fdd�}ttd|d�}|����|j����jd����j��d��jj j j j }t t��B}��|dd�|�����|����|d d �|�����WdQRXdS) Ncs d�_tjtdtddd��_dS)NT� TITLE_FILErI)�encodingr])r!r)rJr rKr#r)rrrr^�s zAButtonClickTest.test_view_file_bind_with_button.._commandr_)r6r`Trdz1.0z1.endz3.0z3.end)r r rar3rr8r!r#rNrGrLr6r9�openrK�readline�strip)rr^rbr9�fr)rr�test_view_file_bind_with_button�s   z/ButtonClickTest.test_view_file_bind_with_buttonN)rrrrrZrcrjrrrrrY�s rY�__main__�)� verbosity) Zidlelibrr)Z test.supportrrPZunittestZtkinterrrrrrZ tkinter.ttkr Zidlelib.idle_test.mock_idler Zidlelib.idle_test.mock_tkr rrrFrZTestCaserr(r,r?rArYr�mainrrrr�s&      ,.)