Your IP : 18.118.10.75


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_query.cpython-36.pyc

3

� f�-�@s&dZddlmZddlZddlmZddlmZddlZddlm	Z	ddl
mZGdd	�d	ej�Z
Gd
d�dej�ZGdd
�d
ej�ZejZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedk�r"ejddd�dS) a�Test query, coverage 91%).

Non-gui tests for Query, SectionName, ModuleName, and HelpSource use
dummy versions that extract the non-gui methods and add other needed
attributes.  GUI tests create an instance of each class and simulate
entries and button clicks.  Subclass tests only target the new code in
the subclass definition.

The appearance of the widgets is checked by the Query and
HelpSource htests.  These are run by running query.py.
�)�queryN)�requires)�Tk)�mock)�Varc@sFeZdZdZGdd�d�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�	QueryTestzTest Query base class.c@sFeZdZejjZejjZejjZe�Z	iZ
dd�Zdd�Zdd�Z
dS)zQueryTest.Dummy_QuerycCs&|jj|�d|jd<d|_d|_dS)N��textF)�entry�set�entry_error�result�	destroyed)�self�dummy_entry�r�A/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_query.py�__init__#s
zQueryTest.Dummy_Query.__init__cCs||jd<dS)Nr	)r)r�messagerrr�	showerror(szQueryTest.Dummy_Query.showerrorcCs
d|_dS)NT)r)rrrr�destroy*szQueryTest.Dummy_Query.destroyN)�__name__�
__module__�__qualname__r�Query�entry_ok�ok�cancelrr
rrrrrrrr�Dummy_QuerysrcCsD|jd�}|j|j�d�|j|j|jfd�|jd|jd�dS)N� Fz
blank liner	)NF)r�assertEqualrr
r�assertInr)r�dialogrrr�test_entry_ok_blank-s
zQueryTest.test_entry_ok_blankcCsD|jd�}|j}||j�d�||j|jfd�||jdd�dS)Nz  good �goodFr	r)NF)rr rr
rr)rr"�Equalrrr�test_entry_ok_good3s

zQueryTest.test_entry_ok_goodcCsT|jd�}tj�|j_|j|j�d�|j|jjj�|j`|j|j	|j
fd�dS)NrF)NF)rr�Mockr
Z	focus_setr r�
assertTrue�calledr
r)rr"rrr�
test_ok_blank:s
zQueryTest.test_ok_blankcCs2|jd�}|j|j�d�|j|j|jfd�dS)Nr$T)r$T)rr rr
r)rr"rrr�test_ok_goodBs
zQueryTest.test_ok_goodcCs2|jd�}|j|j�d�|j|j|jfd�dS)Nzdoes not matterT)NT)rr rr
r)rr"rrr�test_cancelGs
zQueryTest.test_cancelN)
rrr�__doc__rr#r&r*r+r,rrrrrsrc@s>eZdZdZGdd�d�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�SectionNameTestz#Test SectionName subclass of Query.c@s4eZdZejjZdgZe�ZiZ	dd�Z
dd�ZdS)z!SectionNameTest.Dummy_SectionName�usedcCs|jj|�d|jd<dS)Nrr	)r
rr)rrrrrrUsz*SectionNameTest.Dummy_SectionName.__init__cCs||jd<dS)Nr	)r)rrrrrrXsz+SectionNameTest.Dummy_SectionName.showerrorN)rrrr�SectionNamer�
used_namesrr
rrrrrrr�Dummy_SectionNamePsr2cCs0|jd�}|j|j�d�|jd|jd�dS)Nrzno namer	)r2r rr!r)rr"rrr�test_blank_section_name[s
z'SectionNameTest.test_blank_section_namecCs0|jd�}|j|j�d�|jd|jd�dS)Nr/Zuser	)r2r rr!r)rr"rrr�test_used_section_name`s
z&SectionNameTest.test_used_section_namecCs4|jdd�}|j|j�d�|jd|jd�dS)Nr$�zlonger than 30r	)r2r rr!r)rr"rrr�test_long_section_nameesz&SectionNameTest.test_long_section_namecCs0|jd�}|j|j�d�|j|jdd�dS)Nz  good r$r	r)r2r rr)rr"rrr�test_good_section_namejs
z&SectionNameTest.test_good_section_nameN)	rrrr-r2r3r4r6r7rrrrr.Msr.c@s>eZdZdZGdd�d�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�ModuleNameTestz"Test ModuleName subclass of Query.c@s2eZdZejjZdZe�ZiZ	dd�Z
dd�ZdS)zModuleNameTest.Dummy_ModuleNamercCs|jj|�d|jd<dS)Nrr	)r
rr)rrrrrrxsz(ModuleNameTest.Dummy_ModuleName.__init__cCs||jd<dS)Nr	)r)rrrrrr{sz)ModuleNameTest.Dummy_ModuleName.showerrorN)rrrr�
ModuleNamer�text0rr
rrrrrrr�Dummy_ModuleNamessr;cCs0|jd�}|j|j�d�|jd|jd�dS)Nrzno namer	)r;r rr!r)rr"rrr�test_blank_module_name~s
z%ModuleNameTest.test_blank_module_namecCs0|jd�}|j|j�d�|jd|jd�dS)NZ __name_xyz123_should_not_exist__z	not foundr	)r;r rr!r)rr"rrr�test_bogus_module_name�s
z%ModuleNameTest.test_bogus_module_namecCs0|jd�}|j|j�d�|jd|jd�dS)N�	itertoolszsource-basedr	)r;r rr!r)rr"rrr�test_c_source_name�s
z!ModuleNameTest.test_c_source_namecCs4|jd�}|j|j�jd��|j|jdd�dS)N�idlelibz__init__.pyr	r)r;r(r�endswithr r)rr"rrr�test_good_module_name�s
z$ModuleNameTest.test_good_module_nameN)	rrrr-r;r<r=r?rBrrrrr8psr8c@s&eZdZdZGdd�d�Zdd�ZdS)�HelpsourceBrowsefileTestz8Test browse_file method of ModuleName subclass of Query.c@seZdZejjZe�ZdS)z)HelpsourceBrowsefileTest.Dummy_HelpSourceN)rrrr�
HelpSource�browse_filer�pathvarrrrr�Dummy_HelpSource�srGcCs�|j�}x�ddd�dfddd�tfddd�dfddd�tffD]J\}}}|j��2|jj|�||_|j�|j|jj�|�WdQRXq>WdS)NrcSsdS)Nrr)�a�b�crrr�<lambda>�szBHelpsourceBrowsefileTest.test_file_replaces_path.<locals>.<lambda>cSstS)N)�__file__)rHrIrJrrrrK�sZhtestcSsdS)Nrr)rHrIrJrrrrK�scSstS)N)rL)rHrIrJrrrrK�s)	rGrL�subTestrFrZaskfilenamerEr �get)rr"�path�funcr
rrr�test_file_replaces_path�s
z0HelpsourceBrowsefileTest.test_file_replaces_pathN)rrrr-rGrQrrrrrC�srCc@sJeZdZdZGdd�d�Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dS)�HelpsourcePathokTestz4Test path_ok method of HelpSource subclass of Query.c@s0eZdZejjZe�ZiZdd�Z	ddd�Z
dS)z%HelpsourcePathokTest.Dummy_HelpSourcecCs|jj|�d|jd<dS)Nrr	)rOr�
path_error)rZ
dummy_pathrrrr�sz.HelpsourcePathokTest.Dummy_HelpSource.__init__NcCs||jd<dS)Nr	)rS)rrZwidgetrrrr�sz/HelpsourcePathokTest.Dummy_HelpSource.showerror)N)rrrrrD�path_okrrOrSrrrrrrrG�s
rGcCs
tt_dS)N)�
orig_platformr�platform)�clsrrr�
tearDownClass�sz"HelpsourcePathokTest.tearDownClasscCs0|jd�}|j|j�d�|jd|jd�dS)Nrzno help filer	)rGr rTr!rS)rr"rrr�test_path_ok_blank�s
z'HelpsourcePathokTest.test_path_ok_blankcCs4|jtd�}|j|j�d�|jd|jd�dS)Nzbad-bad-badz	not existr	)rGrLr rTr!rS)rr"rrr�test_path_ok_bad�sz%HelpsourcePathokTest.test_path_ok_badcCsd|jd�}|j}xNdD]F}|j��4|jj|�|j|j�|�|j|jdd�WdQRXqWdS)Nr�
www.py.org�
http://py.orgr	)r[r\)rGr rMrOrrTrS)rr"r%Zurlrrr�test_path_ok_web�s


z%HelpsourcePathokTest.test_path_ok_webcCsl|jd�}x\dD]T\}}|j��>|t_|jjt�|j|j�|t�|j|j	dd�WdQRXqWdS)	Nr�darwin�file://�otherr	�r^r_�r`r)rarb)
rGrMrrVrOrrLr rTrS)rr"rV�prefixrrr�test_path_ok_file�s

z&HelpsourcePathokTest.test_path_ok_fileN)rrrr-rG�classmethodrXrYrZr]rdrrrrrR�s
	rRc@s&eZdZdZGdd�d�Zdd�ZdS)�HelpsourceEntryokTestz5Test entry_ok method of HelpSource subclass of Query.c@s,eZdZejjZiZiZdd�Zdd�Z	dS)z&HelpsourceEntryokTest.Dummy_HelpSourcecCs|jS)N)�name)rrrr�item_ok�sz.HelpsourceEntryokTest.Dummy_HelpSource.item_okcCs|jS)N)rO)rrrrrT�sz.HelpsourceEntryokTest.Dummy_HelpSource.path_okN)
rrrrrDrrrSrhrTrrrrrG�s
rGcCsR|j�}xDdD]<\}}}|j��$|||_|_|j|j�|�WdQRXqWdS)	N�doc.txt�doc�NNN�NriN�rjNN�rjri�rjrirn)rkrlrmro)rGrMrgrOr r)rr"rgrOr
rrr�test_entry_ok_helpsource�s
z.HelpsourceEntryokTest.test_entry_ok_helpsourceN)rrrr-rGrprrrrrf�s	rfc@sDeZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�QueryGuiTestcCsBtd�t�|_}|jj�tj|dddd�|_tj�|j_	dS)N�guiZTESTZtestT)�_utest)
rr�root�withdrawrrr"rr'r)rWrtrrr�
setUpClass�s

zQueryGuiTest.setUpClasscCs|j`|`|jj�|`dS)N)r"rrt)rWrrrrXs
zQueryGuiTest.tearDownClasscCs(|jjjdd�d|j_|jjj�dS)Nr�end)r"r
�deleter
rZ
reset_mock)rrrr�setUpszQueryGuiTest.setUpcCs>|j}|jjdd�|jj�|j|jd�|j|jj	�dS)Nr�abc)
r"r
�insert�	button_ok�invoker r
r(rr))rr"rrr�
test_click_ok
s

zQueryGuiTest.test_click_okcCs0|j}|jj�|j|jd�|j|jj�dS)N)r"r|r}r r
ZassertFalserr))rr"rrr�test_click_blanks
zQueryGuiTest.test_click_blankcCs>|j}|jjdd�|jj�|j|jd�|j|jj	�dS)Nrrz)
r"r
r{Z
button_cancelr}r r
r(rr))rr"rrr�test_click_cancels

zQueryGuiTest.test_click_cancelN)
rrrrervrXryr~rr�rrrrrq�srqc@s eZdZedd��Zdd�ZdS)�SectionnameGuiTestcCstd�dS)Nrr)r)rWrrrrv$szSectionnameGuiTest.setUpClasscCspt�}|j�tj|dddhdd�}|j}|j|jdh�|jjdd�|jj	�|j|j
d�~|j�~dS)N�T�trzT)rsrZokay)rrurr0r r1r
r{r|r}r
r)rrtr"r%rrr�test_click_section_name(s
z*SectionnameGuiTest.test_click_section_nameN)rrrrervr�rrrrr�"sr�c@s eZdZedd��Zdd�ZdS)�ModulenameGuiTestcCstd�dS)Nrr)r)rWrrrrv8szModulenameGuiTest.setUpClasscCsnt�}|j�tj|ddddd�}|j|jd�|j|jj�d�|jj	�|j
|jjd��~|j
�~dS)Nr�r�r@T)rsz__init__.py)rrurr9r r:r
rNr|r}r(r
rAr)rrtr"rrr�test_click_module_name<s
z(ModulenameGuiTest.test_click_module_nameN)rrrrervr�rrrrr�6sr�c@s eZdZedd��Zdd�ZdS)�HelpsourceGuiTestcCstd�dS)Nrr)r)rWrrrrvKszHelpsourceGuiTest.setUpClasscCs�t�}|j�tj|ddtdd�}|j}||jj�d�||jj�t�|j	j
�tjdkr`dnd}||j
d|tf�~|j�~dS)Nr�Z__test__T)Zmenuitem�filepathrsr^zfile://r)rrurrDrLr r
rNrOr|r}�sysrVr
r)rrtr"r%rcrrr�test_click_help_sourceOs


z(HelpsourceGuiTest.test_click_help_sourceN)rrrrervr�rrrrr�Isr��__main__�F)�	verbosity�exit)r-r@rZunittestZtest.supportrZtkinterrr�rZidlelib.idle_test.mock_tkrZTestCaserr.r8rVrUrCrRrfrqr�r�r�r�mainrrrr�<module>s(5#%.+


?>