Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/idlelib/idle_test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/idlelib/idle_test/__pycache__/test_textview.cpython-310.pyc

o

0�i��@sdZddlmZddlmZed�ddlZddlZddlm	Z	m
Z
mZmZm
Z
ddlmZddlmZdd	lmZd
d�Zdd
�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedkr�ej dd�dSdS)aTest textview, coverage 100%.

Since all methods and functions create (or destroy) a ViewWindow, which
is a widget containing a widget, etcetera, all tests must be gui tests.
Using mock Text would not change this.  Other mocks are used to retrieve
information about calls.
�)�textview)�requiresZguiN)�Tk�TclError�CHAR�NONE�WORD)�Button)�Func)�	Mbox_funccCst�at��dS�N�r�root�withdraw�rr�F/opt/alt/python310/lib64/python3.10/idlelib/idle_test/test_textview.py�setUpModulesrcCst��t��bdSr�r�update_idletasks�destroyrrrr�tearDownModulesrc@seZdZe�Ze�Ze�ZdS)�VWN)�__name__�
__module__�__qualname__r
�	transient�grab_set�wait_windowrrrrr#s
rc@�,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ViewWindowTestcCs"tj��tj��tj��dSr)rr�__init__rr��selfrrr�setUp,s

zViewWindowTest.setUpcCsBttdd�}|�tjj�|�tjj�|�tjj�|��dS)N�Title�	test text)rr�
assertTruer�calledrr�ok�r"�viewrrr�test_init_modal1s
zViewWindowTest.test_init_modalcCsFttdddd�}|�tjj�|�tjj�|�tjj�|��dS�Nr$r%F��modal)rrZassertFalserr'rrr(r)rrr�test_init_nonmodal8s
z!ViewWindowTest.test_init_nonmodalcCs>ttdddd�}t�|_|��|�|jj�|`|��dSr,)rrr
rr(r&r'r)rrr�test_ok?szViewWindowTest.test_okN)rrrr#r+r/r0rrrrr*s
rc@seZdZdd�ZdS)�AutoHideScrollbarTestcCs*t�t�}|�t|j�|�t|j�dSr)�tvZAutoHideScrollbarrZassertRaisesrZpackZplace)r"Zscrollrrr�test_forbidden_geometryJs
z-AutoHideScrollbarTest.test_forbidden_geometryN)rrrr3rrrrr1Hsr1c@s@eZdZedd��Zedd��Zefdd�Zdd�Zd	d
�Z	dS)�ScrollableTextFrameTestcCst�|_}|��dSrr
��clsrrrr�
setUpClassRsz"ScrollableTextFrameTest.setUpClasscCs|j��|j��|`dSrr�r6rrr�
tearDownClassWs

z%ScrollableTextFrameTest.tearDownClasscs2tj|jfd|i|����fdd�}|�|��S)N�wrapcs������dSr)rrr��framerr�
cleanup_frame_sz9ScrollableTextFrameTest.make_frame.<locals>.cleanup_frame)r2ZScrollableTextFramer�
addCleanup)r"r:�kwargsr=rr;r�
make_frame]s
z"ScrollableTextFrameTest.make_framecCs0|��}|j�dd�|�|j�dd�d�dS)N�1.0r%�1.end)r@�text�insert�assertEqual�get)r"r<rrr�
test_line1esz"ScrollableTextFrameTest.test_line1c	Cs�|jtd�}|�|j�d�t�|�|j�ttfD].}|j	|d��|j|d�}|�|j�d�|�|�
|j�Wd�n1sCwYqdS)N)r:r:)r@rrErC�cgetZassertIsNotNoneZxscrollrrZsubTest�assertIsNone)r"r<r:rrr�test_horiz_scrollbarjs���z,ScrollableTextFrameTest.test_horiz_scrollbarN)
rrr�classmethodr7r9rr@rGrJrrrrr4Ps

r4c@s,eZdZedd��Zedd��Zdd�ZdS)�
ViewFrameTestcCs&t�|_}|��t�|d�|_dS)Nr%)rrrr2�	ViewFramer<r5rrrr7~szViewFrameTest.setUpClasscCs |`|j��|j��|`dSr)r<rrrr8rrrr9�s

zViewFrameTest.tearDownClasscCs |jjj}|�|dd�d�dS)NrArBr%)r<rCrFrE)r"rFrrrrG�s
zViewFrameTest.test_line1N)rrrrKr7r9rGrrrrrL|s

rLc@sLeZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�ViewFunctionTestcCstj|_t�t_dSr)r2�	showerror�
orig_errorrr8rrrr7�szViewFunctionTest.setUpClasscCs|jt_|`dSr)rPr2rOr8rrrr9�szViewFunctionTest.tearDownClasscCs>tjtdddd�}|�|tj�|�|jtj�|j��dSr,)r2�	view_textr�assertIsInstance�
ViewWindow�	viewframerMr(r)rrr�test_view_text�szViewFunctionTest.test_view_textcCs\tjtdtddd�}|�|tj�|�|jtj�|jjj	j
}|�d|dd��|��dS)Nr$�asciiFr-ZTestrArB)
r2�	view_filer�__file__rRrSrTrM�	textframerCrFZassertInr()r"r*rFrrr�test_view_file�szViewFunctionTest.test_view_filecCs2tjtddddd�}|�|�|�tjjd�dS)Nr$zabc.xyzrVFr-zFile Load Error)r2rWrrIrErO�titler)rrr�
test_bad_file�s
zViewFunctionTest.test_bad_filecCsRtj}|�|�|�t�dd��}tjtd|ddd�}|�	|�|�
tjjd�dS)Nz..zCREDITS.txtr$rVFr-zUnicode Decode Error)
�os�path�abspath�join�dirnamerXr2rWrrIrErOr[)r"�p�fnr*rrr�test_bad_encoding�s

z"ViewFunctionTest.test_bad_encodingcCs4tjtddddd�}|jjj}|�|�d�d�dS)Nr$�testFZnone)r.r:r:)r2rQrrTrYrCrErH)r"r*Ztext_widgetrrr�test_nowrap�s
zViewFunctionTest.test_nowrapN)rrrrKr7r9rUrZr\rdrfrrrrrN�s

rNc@r)
�ButtonClickTestcCsd|_d|_dS)NF)r*r'r!rrrr#�s
zButtonClickTest.setUpcCs|jr
|j��dSdSr)r*rr!rrr�tearDown�s�zButtonClickTest.tearDowncsn�fdd�}ttd|d�}|����|j����jd����j��d����jj	j
j�dd�d	�dS)
Ncsd�_tjtdddd��_dS)NT�
TITLE_TEXT�COMMAND)�_utest)r'r2rQrr*rr!rr�_command�szAButtonClickTest.test_view_text_bind_with_button.<locals>._command�BUTTON�rCZcommandTrirArBrj)
r	r�invoker>rrEr'r*r[rTrYrCrF)r"rl�buttonrr!r�test_view_text_bind_with_button�s�z/ButtonClickTest.test_view_text_bind_with_buttoncs��fdd�}ttd|d�}|����|j����jd����j��d��jj	j
jj}t
t��'}��|dd�|�����|����|d	d
�|�����Wd�dS1s\wYdS)Ncs d�_tjtdtddd��_dS)NT�
TITLE_FILErV)�encodingrk)r'r2rWrrXr*rr!rrrl�s
�zAButtonClickTest.test_view_file_bind_with_button.<locals>._commandrmrnTrrrArBz3.0z3.end)r	rror>rrEr'r*r[rTrYrCrF�openrX�readline�strip)r"rlrprF�frr!r�test_view_file_bind_with_button�s
"�z/ButtonClickTest.test_view_file_bind_with_buttonN)rrrr#rhrqrxrrrrrg�s

rg�__main__�)�	verbosity)!�__doc__Zidlelibrr2Ztest.supportrr]ZunittestZtkinterrrrrrZtkinter.ttkr	Zidlelib.idle_test.mock_idler
Zidlelib.idle_test.mock_tkrrrrSrZTestCaserr1r4rLrNrgr�mainrrrr�<module>s,,.)�