Your IP : 18.225.98.39


Current Path : /opt/alt/python36/lib64/python3.6/idlelib/idle_test/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/idle_test/__pycache__/test_textview.cpython-36.pyc

3

� f�@s�dZddlmZddlZddlmZed�ddlZddlm	Z	ddl
mZddlm
Z
dd	lmZd
d�Zdd
�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedkr�ejdd�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.
�)�textviewN)�requiresZgui)�Tk)�Button)�Func)�	Mbox_funccCst�atj�dS)N)r�root�withdraw�r
r
�D/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_textview.py�setUpModulesrcCstj�tj�bdS)N)r�update_idletasks�destroyr
r
r
r�tearDownModulesrc@seZdZe�Ze�Ze�ZdS)�VWN)�__name__�
__module__�__qualname__r�	transient�grab_set�wait_windowr
r
r
rr#src@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ViewWindowTestcCs"tjj�tjj�tjj�dS)N)rr�__init__rr)�selfr
r
r�setUp,s

zViewWindowTest.setUpcCsBttdd�}|jtjj�|jtjj�|jtjj�|j�dS)N�Titlez	test text)rr�
assertTruer�calledrr�ok)r�viewr
r
r�test_init_modal1s
zViewWindowTest.test_init_modalcCsFttdddd�}|jtjj�|jtjj�|jtjj�|j�dS)Nrz	test textF)�modal)rrZassertFalserrrrr)rrr
r
r�test_init_nonmodal8s
z!ViewWindowTest.test_init_nonmodalcCs>ttdddd�}t�|_|j�|j|jj�|`|j�dS)Nrz	test textF)r!)rrrrrrr)rrr
r
r�test_ok?szViewWindowTest.test_okN)rrrrr r"r#r
r
r
rr*src@s,eZdZedd��Zedd��Zdd�ZdS)�
TextFrameTestcCs&t�|_}|j�tj|d�|_dS)Nz	test text)rrr	�tvZ	TextFrame�frame)�clsrr
r
r�
setUpClassJszTextFrameTest.setUpClasscCs |`|jj�|jj�|`dS)N)r&rr
r)r'r
r
r�
tearDownClassPs

zTextFrameTest.tearDownClasscCs |jjj}|j|dd�d�dS)Nz1.0z1.endz	test text)r&�text�get�assertEqual)rr+r
r
r�
test_line1Ws
zTextFrameTest.test_line1N)rrr�classmethodr(r)r-r
r
r
rr$Hsr$c@sLeZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�ViewFunctionTestcCstj|_t�t_dS)N)r%�	showerror�
orig_errorr)r'r
r
rr(_szViewFunctionTest.setUpClasscCs|jt_|`dS)N)r1r%r0)r'r
r
rr)dszViewFunctionTest.tearDownClasscCs>tjtdddd�}|j|tj�|j|jtj�|jj�dS)Nrz	test textF)r!)r%�	view_textr�assertIsInstance�
ViewWindow�	viewframe�	ViewFramer)rrr
r
r�test_view_textiszViewFunctionTest.test_view_textcCs\tjtdtddd�}|j|tj�|j|jtj�|jjj	j
}|jd|dd��|j�dS)Nr�asciiF)r!ZTestz1.0z1.end)
r%�	view_filer�__file__r3r4r5r6�	textframer*r+ZassertInr)rrr+r
r
r�test_view_fileoszViewFunctionTest.test_view_filecCs2tjtddddd�}|j|�|jtjjd�dS)Nrzabc.xyzr8F)r!zFile Load Error)r%r9r�assertIsNoner,r0�title)rrr
r
r�
test_bad_filews
zViewFunctionTest.test_bad_filecCsRtj}|j|j|jt�dd��}tjtd|ddd�}|j	|�|j
tjjd�dS)Nz..zCREDITS.txtrr8F)r!zUnicode Decode Error)
�os�path�abspath�join�dirnamer:r%r9rr=r,r0r>)r�p�fnrr
r
r�test_bad_encoding}s

z"ViewFunctionTest.test_bad_encodingcCs4tjtddddd�}|jjj}|j|jd�d�dS)NrZtestFZnone)r!�wraprH)r%r2rr5r;r*r,Zcget)rrZtext_widgetr
r
r�test_nowrap�s
zViewFunctionTest.test_nowrapN)rrrr.r(r)r7r<r?rGrIr
r
r
rr/]sr/c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ButtonClickTestcCsd|_d|_dS)NF)rr)rr
r
rr�szButtonClickTest.setUpcCs|jr|jj�dS)N)rr)rr
r
r�tearDown�szButtonClickTest.tearDowncsn�fdd�}ttd|d�}|j��j|j��j�jd��j�jj�d��j�jj	j
jjdd�d	�dS)
Ncsd�_tjtdddd��_dS)NT�
TITLE_TEXT�COMMAND)�_utest)rr%r2rrr
)rr
r�_command�szAButtonClickTest.test_view_text_bind_with_button.<locals>._command�BUTTON)r*�commandTrLz1.0z1.endrM)
rr�invoke�
addCleanuprr,rrr>r5r;r*r+)rrO�buttonr
)rr�test_view_text_bind_with_button�sz/ButtonClickTest.test_view_text_bind_with_buttoncs��fdd�}ttd|d�}|j��j|j��j�jd��j�jj�d��jj	j
jj}t
t��B}�j|dd�|j�j��|j��j|d	d
�|j�j��WdQRXdS)Ncs d�_tjtdtddd��_dS)NT�
TITLE_FILEr8)�encodingrN)rr%r9rr:rr
)rr
rrO�s
zAButtonClickTest.test_view_file_bind_with_button.<locals>._commandrP)r*rQTrVz1.0z1.endz3.0z3.end)rrrRrSrr,rrr>r5r;r*r+�openr:�readline�strip)rrOrTr+�fr
)rr�test_view_file_bind_with_button�s
z/ButtonClickTest.test_view_file_bind_with_buttonN)rrrrrKrUr\r
r
r
rrJ�s
rJ�__main__�)�	verbosity)�__doc__Zidlelibrr%ZunittestZtest.supportrr@ZtkinterrZtkinter.ttkrZidlelib.idle_test.mock_idlerZidlelib.idle_test.mock_tkrrrr4rZTestCaserr$r/rJr�mainr
r
r
r�<module>s$.)

?>