Your IP : 18.189.171.188


Current Path : /opt/alt/python37/lib64/python3.7/idlelib/idle_test/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/idlelib/idle_test/__pycache__/test_textview.cpython-37.pyc

B

� 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/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ZassertFalserr!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assertRaisesrZpackZplace)rZscrollrrr�test_forbidden_geometryJs
z-AutoHideScrollbarTest.test_forbidden_geometryN)rrrr*rrrrr(Hsr(c@s@eZdZedd��Zedd��Zefdd�Zdd�Zd	d
�Z	dS)�ScrollableTextFrameTestcCst�|_}|��dS)N)rrr
)�clsrrrr�
setUpClassRsz"ScrollableTextFrameTest.setUpClasscCs|j��|j��|`dS)N)rrr)r,rrr�
tearDownClassWs

z%ScrollableTextFrameTest.tearDownClasscs2tj|jfd|i|����fdd�}|�|��S)N�wrapcs������dS)N)rrr)�framerr�
cleanup_frame_sz9ScrollableTextFrameTest.make_frame.<locals>.cleanup_frame)r)ZScrollableTextFramer�
addCleanup)rr/�kwargsr1r)r0r�
make_frame]s
z"ScrollableTextFrameTest.make_framecCs0|��}|j�dd�|�|j�dd�d�dS)Nz1.0z	test textz1.end)r4�text�insert�assertEqual�get)rr0rrr�
test_line1esz"ScrollableTextFrameTest.test_line1c
Cs�|jtd�}|�|j�d�t�|�|j�xTttgD]H}|j	|d��2|j|d�}|�|j�d�|�|�
|j�WdQRXq6WdS)N)r/r/)r4rr7r5�cgetZassertIsNotNoneZxscrollrrZsubTest�assertIsNone)rr0r/rrr�test_horiz_scrollbarjsz,ScrollableTextFrameTest.test_horiz_scrollbarN)
rrr�classmethodr-r.rr4r9r<rrrrr+Ps
r+c@s,eZdZedd��Zedd��Zdd�ZdS)�
ViewFrameTestcCs&t�|_}|��t�|d�|_dS)Nz	test text)rrr
r)�	ViewFramer0)r,rrrrr-~szViewFrameTest.setUpClasscCs |`|j��|j��|`dS)N)r0rrr)r,rrrr.�s

zViewFrameTest.tearDownClasscCs |jjj}|�|dd�d�dS)Nz1.0z1.endz	test text)r0r5r8r7)rr8rrrr9�s
zViewFrameTest.test_line1N)rrrr=r-r.r9rrrrr>|sr>c@sLeZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�ViewFunctionTestcCstj|_t�t_dS)N)r)�	showerror�
orig_errorr)r,rrrr-�szViewFunctionTest.setUpClasscCs|jt_|`dS)N)rBr)rA)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__rDrErFr?�	textframer5r8ZassertInr")rr#r8rrr�test_view_file�szViewFunctionTest.test_view_filecCs2tjtddddd�}|�|�|�tjjd�dS)Nrzabc.xyzrHF)r%zFile Load Error)r)rIrr;r7rA�title)rr#rrr�
test_bad_file�s
zViewFunctionTest.test_bad_filecCsRtj}|�|�|�t�dd��}tjtd|ddd�}|�	|�|�
tjjd�dS)Nz..zCREDITS.txtrrHF)r%zUnicode Decode Error)
�os�path�abspath�join�dirnamerJr)rIrr;r7rArM)r�p�fnr#rrr�test_bad_encoding�s

z"ViewFunctionTest.test_bad_encodingcCs4tjtddddd�}|jjj}|�|�d�d�dS)NrZtestFZnone)r%r/r/)r)rCrrFrKr5r7r:)rr#Ztext_widgetrrr�test_nowrap�s
zViewFunctionTest.test_nowrapN)rrrr=r-r.rGrLrNrVrWrrrrr@�sr@c@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)rCrr#r)rrr�_command�szAButtonClickTest.test_view_text_bind_with_button.<locals>._command�BUTTON)r5�commandTrZz1.0z1.endr[)
r	r�invoker2rr7r!r#rMrFrKr5r8)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
jj}t
t��B}��|dd�|�����|����|d	d
�|�����WdQRXdS)Ncs d�_tjtdtddd��_dS)NT�
TITLE_FILErH)�encodingr\)r!r)rIrrJr#r)rrrr]�s
zAButtonClickTest.test_view_file_bind_with_button.<locals>._commandr^)r5r_Trcz1.0z1.endz3.0z3.end)r	rr`r2rr7r!r#rMrFrKr5r8�openrJ�readline�strip)rr]rar8�fr)rr�test_view_file_bind_with_button�s
z/ButtonClickTest.test_view_file_bind_with_buttonN)rrrrrYrbrirrrrrX�s
rX�__main__�)�	verbosity)!�__doc__Zidlelibrr)Ztest.supportrrOZunittestZtkinterrrrrrZtkinter.ttkr	Zidlelib.idle_test.mock_idler
Zidlelib.idle_test.mock_tkrrrrErZTestCaserr(r+r>r@rXr�mainrrrr�<module>s(,.)


?>