Your IP : 216.73.216.85


Current Path : /opt/alt/python38/lib64/python3.8/idlelib/idle_test/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/idlelib/idle_test/__pycache__/test_textview.cpython-38.pyc

U

i�f��@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�Zedk�rej dd�dS)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�D/opt/alt/python38/lib64/python3.8/idlelib/idle_test/test_textview.py�setUpModulesrcCst��t��bdSr�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��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.r/rrrrr*src@seZdZdd�ZdS)�AutoHideScrollbarTestcCs*t�t�}|�t|j�|�t|j�dSr)�tvZAutoHideScrollbarrZassertRaisesrZpackZplace)r!Zscrollrrr�test_forbidden_geometryJs
z-AutoHideScrollbarTest.test_forbidden_geometryN)rrrr2rrrrr0Hsr0c@s@eZdZedd��Zedd��Zefdd�Zdd�Zd	d
�Z	dS)�ScrollableTextFrameTestcCst�|_}|��dSrr
��clsrrrr�
setUpClassRsz"ScrollableTextFrameTest.setUpClasscCs|j��|j��|`dSrr�r5rrr�
tearDownClassWs

z%ScrollableTextFrameTest.tearDownClasscs2tj|jfd|i|����fdd�}|�|��S)N�wrapcs������dSr)rrr��framerr�
cleanup_frame_sz9ScrollableTextFrameTest.make_frame.<locals>.cleanup_frame)r1ZScrollableTextFramer�
addCleanup)r!r9�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]H}|j	|d��2|j|d�}|�|j�d�|�|�
|j�W5QRXq4dS)N)r9r9)r?rrDrB�cgetZassertIsNotNoneZxscrollrrZsubTest�assertIsNone)r!r;r9rrr�test_horiz_scrollbarjsz,ScrollableTextFrameTest.test_horiz_scrollbarN)
rrr�classmethodr6r8rr?rFrIrrrrr3Ps

r3c@s,eZdZedd��Zedd��Zdd�ZdS)�
ViewFrameTestcCs&t�|_}|��t�|d�|_dS)Nr$)rrrr1�	ViewFramer;r4rrrr6~szViewFrameTest.setUpClasscCs |`|j��|j��|`dSr)r;rrrr7rrrr8�s

zViewFrameTest.tearDownClasscCs |jjj}|�|dd�d�dS)Nr@rAr$)r;rBrErD)r!rErrrrF�s
zViewFrameTest.test_line1N)rrrrJr6r8rFrrrrrK|s


rKc@sLeZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�ViewFunctionTestcCstj|_t�t_dSr)r1�	showerror�
orig_errorrr7rrrr6�szViewFunctionTest.setUpClasscCs|jt_|`dSr)rOr1rNr7rrrr8�szViewFunctionTest.tearDownClasscCs>tjtdddd�}|�|tj�|�|jtj�|j��dSr+)r1�	view_textr�assertIsInstance�
ViewWindow�	viewframerLr'r(rrr�test_view_text�szViewFunctionTest.test_view_textcCs\tjtdtddd�}|�|tj�|�|jtj�|jjj	j
}|�d|dd��|��dS)Nr#�asciiFr,ZTestr@rA)
r1�	view_filer�__file__rQrRrSrL�	textframerBrEZassertInr')r!r)rErrr�test_view_file�szViewFunctionTest.test_view_filecCs2tjtddddd�}|�|�|�tjjd�dS)Nr#zabc.xyzrUFr,zFile Load Error)r1rVrrHrDrN�titler(rrr�
test_bad_file�s
zViewFunctionTest.test_bad_filecCsRtj}|�|�|�t�dd��}tjtd|ddd�}|�	|�|�
tjjd�dS)Nz..zCREDITS.txtr#rUFr,zUnicode Decode Error)
�os�path�abspath�join�dirnamerWr1rVrrHrDrNrZ)r!�p�fnr)rrr�test_bad_encoding�s

z"ViewFunctionTest.test_bad_encodingcCs4tjtddddd�}|jjj}|�|�d�d�dS)Nr#ZtestFZnone)r-r9r9)r1rPrrSrXrBrDrG)r!r)Ztext_widgetrrr�test_nowrap�s
zViewFunctionTest.test_nowrapN)rrrrJr6r8rTrYr[rcrdrrrrrM�s

rMc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ButtonClickTestcCsd|_d|_dS)NF)r)r&r rrrr"�szButtonClickTest.setUpcCs|jr|j��dSr)r)rr rrr�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&r1rPrr)rr rr�_command�szAButtonClickTest.test_view_text_bind_with_button.<locals>._command�BUTTON�rBZcommandTrgr@rArh)
r	r�invoker=rrDr&r)rZrSrXrBrE)r!rj�buttonrr r�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
jj}t
t��B}��|dd�|�����|����|d	d
�|�����W5QRXdS)Ncs d�_tjtdtddd��_dS)NT�
TITLE_FILErU)�encodingri)r&r1rVrrWr)rr rrrj�s

�zAButtonClickTest.test_view_file_bind_with_button.<locals>._commandrkrlTrpr@rAz3.0z3.end)r	rrmr=rrDr&r)rZrSrXrBrE�openrW�readline�strip)r!rjrnrE�frr r�test_view_file_bind_with_button�s
z/ButtonClickTest.test_view_file_bind_with_buttonN)rrrr"rfrorvrrrrre�s
re�__main__�)�	verbosity)!�__doc__Zidlelibrr1Ztest.supportrr\ZunittestZtkinterrrrrrZtkinter.ttkr	Zidlelib.idle_test.mock_idler
Zidlelib.idle_test.mock_tkrrrrRrZTestCaserr0r3rKrMrer�mainrrrr�<module>s(,.)