Your IP : 18.220.74.19


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

B

� f�;�@s~dZddlmZddlZddlmZddlmZmZddl	Z	ddlm
Z
ddlmZGdd	�d	ej
�ZGd
d�dej
�ZGdd
�d
ej
�ZGdd�dej
�ZGdd�dej
�ZGdd�dej
�ZGdd�dej
�ZGdd�dej
�ZGdd�dej
�ZGdd�dej
�ZGdd�dej
�ZGdd�dej
�ZGd d!�d!ej
�ZGd"d#�d#ej
�ZGd$d%�d%ej
�Zed&k�rzejd'd(d)�dS)*a�Test query, coverage 93%).

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�END)�mock)�Varc@sFeZdZdZGdd�d�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�	QueryTestzTest Query base class.c@s<eZdZejjZejjZejjZdd�Zdd�Z	dd�Z
dS)zQueryTest.Dummy_QuerycCs&t|d�|_ddi|_d|_d|_dS)N)�value�text�F)r�entry�entry_error�result�	destroyed)�self�dummy_entry�r�A/opt/alt/python37/lib64/python3.7/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�cancelrrrrrrr�Dummy_QuerysrcCsD|�d�}|�|��d�|�|j|jfd�|�d|jd�dS)N� )NFz
blank liner
)r�assertEqualrrr�assertInr
)r�dialogrrr�test_entry_ok_blank+s
zQueryTest.test_entry_ok_blankcCsD|�d�}|j}||��d�||j|jfd�||jdd�dS)Nz  good �good)NFr
r)rr!rrrr
)rr#�Equalrrr�test_entry_ok_good1s

zQueryTest.test_entry_ok_goodcCsT|�d�}t��|j_|�|��d�|�|jjj�|j`|�|j	|j
fd�dS)Nr)NF)rr�MockrZ	focus_setr!r�
assertTrue�calledrr)rr#rrr�
test_ok_blank8s
zQueryTest.test_ok_blankcCs2|�d�}|�|��d�|�|j|jfd�dS)Nr%)r%T)rr!rrr)rr#rrr�test_ok_good@s
zQueryTest.test_ok_goodcCs2|�d�}|�|��d�|�|j|jfd�dS)Nzdoes not matter)NT)rr!rrr)rr#rrr�test_cancelEs
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@s*eZdZejjZdgZdd�Zdd�ZdS)z!SectionNameTest.Dummy_SectionName�usedcCst|d�|_ddi|_dS)N)r	r
r)rrr
)rrrrrrQsz*SectionNameTest.Dummy_SectionName.__init__cCs||jd<dS)Nr
)r
)rrrrrrTsz+SectionNameTest.Dummy_SectionName.showerrorN)	rrrr�SectionNamer�
used_namesrrrrrr�Dummy_SectionNameNsr3cCs0|�d�}|�|��d�|�d|jd�dS)Nr zno namer
)r3r!rr"r
)rr#rrr�test_blank_section_nameWs
z'SectionNameTest.test_blank_section_namecCs0|�d�}|�|��d�|�d|jd�dS)Nr0Zuser
)r3r!rr"r
)rr#rrr�test_used_section_name\s
z&SectionNameTest.test_used_section_namecCs0|�d�}|�|��d�|�d|jd�dS)NZ goodgoodgoodgoodgoodgoodgoodgoodzlonger than 30r
)r3r!rr"r
)rr#rrr�test_long_section_nameas
z&SectionNameTest.test_long_section_namecCs0|�d�}|�|��d�|�|jdd�dS)Nz  good r%r
r)r3r!rr
)rr#rrr�test_good_section_namefs
z&SectionNameTest.test_good_section_nameN)	rrrr.r3r4r5r6r7rrrrr/Ks	r/c@s>eZdZdZGdd�d�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�ModuleNameTestz"Test ModuleName subclass of Query.c@s(eZdZejjZdZdd�Zdd�ZdS)zModuleNameTest.Dummy_ModuleNamercCst|d�|_ddi|_dS)N)r	r
r)rrr
)rrrrrrrsz(ModuleNameTest.Dummy_ModuleName.__init__cCs||jd<dS)Nr
)r
)rrrrrrusz)ModuleNameTest.Dummy_ModuleName.showerrorN)	rrrr�
ModuleNamer�text0rrrrrr�Dummy_ModuleNameosr;cCs0|�d�}|�|��d�|�d|jd�dS)Nr zno namer
)r;r!rr"r
)rr#rrr�test_blank_module_namexs
z%ModuleNameTest.test_blank_module_namecCs0|�d�}|�|��d�|�d|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|�d�}|�|��d�|�d|jd�dS)N�	itertoolszsource-basedr
)r;r!rr"r
)rr#rrr�test_c_source_name�s
z!ModuleNameTest.test_c_source_namecCs4|�d�}|�|���d��|�|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?rBrrrrr8ls	r8c@s6eZdZdZGdd�d�Zdd�Zdd�Zdd	�Zd
S)�GotoTestzTest Goto subclass of Query.c@s$eZdZejjZdd�Zdd�ZdS)zGotoTest.Dummy_ModuleNamecCst|d�|_ddi|_dS)N)r	r
r)rrr
)rrrrrr�sz"GotoTest.Dummy_ModuleName.__init__cCs||jd<dS)Nr
)r
)rrrrrr�sz#GotoTest.Dummy_ModuleName.showerrorN)rrrr�Gotorrrrrrrr;�sr;cCs0|�d�}|�|��d�|�d|jd�dS)N�aznot a base 10 integerr
)r;r!rr"r
)rr#rrr�test_bogus_goto�s
zGotoTest.test_bogus_gotocCs0|�d�}|�|��d�|�d|jd�dS)N�0znot a positive integerr
)r;r!rr"r
)rr#rrr�
test_bad_goto�s
zGotoTest.test_bad_gotocCs0|�d�}|�|��d�|�|jdd�dS)N�1�r
r)r;r!rr
)rr#rrr�test_good_goto�s
zGotoTest.test_good_gotoN)rrrr.r;rFrHrKrrrrrC�s
rCc@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�srPc
Cs�|��}x�ddd�dfddd�tfddd�dfddd�tffD]J\}}}|���2|j�|�||_|��|�|j��|�WdQRXq>WdS)NrcSsdS)Nrr)rE�b�crrr�<lambda>��zBHelpsourceBrowsefileTest.test_file_replaces_path.<locals>.<lambda>cSstS)N)�__file__)rErQrRrrrrS�rTZhtestcSsdS)Nrr)rErQrRrrrrS�rTcSstS)N)rU)rErQrRrrrrS�rT)	rPrU�subTestrO�setZaskfilenamerNr!�get)rr#�path�funcrrrr�test_file_replaces_path�s
z0HelpsourceBrowsefileTest.test_file_replaces_pathN)rrrr.rPr[rrrrrL�srLc@sPeZdZdZGdd�d�ZejZedd��Z	dd�Z
dd	�Zd
d�Zdd
�Z
dS)�HelpsourcePathokTestz4Test path_ok method of HelpSource subclass of Query.c@s&eZdZejjZdd�Zddd�ZdS)z%HelpsourcePathokTest.Dummy_HelpSourcecCst|d�|_ddi|_dS)N)r	r
r)rrY�
path_error)rZ
dummy_pathrrrr�sz.HelpsourcePathokTest.Dummy_HelpSource.__init__NcCs||jd<dS)Nr
)r])rrZwidgetrrrr�sz/HelpsourcePathokTest.Dummy_HelpSource.showerror)N)rrrrrM�path_okrrrrrrrP�srPcCs|jt_dS)N)�
orig_platformr�platform)�clsrrr�
tearDownClass�sz"HelpsourcePathokTest.tearDownClasscCs0|�d�}|�|��d�|�d|jd�dS)Nr zno help filer
)rPr!r^r"r])rr#rrr�test_path_ok_blank�s
z'HelpsourcePathokTest.test_path_ok_blankcCs4|�td�}|�|��d�|�d|jd�dS)Nzbad-bad-badz	not existr
)rPrUr!r^r"r])rr#rrr�test_path_ok_bad�sz%HelpsourcePathokTest.test_path_ok_badc
Csd|�d�}|j}xNdD]F}|���4|j�|�|�|��|�|�|jdd�WdQRXqWdS)Nr)z
www.py.orgz
http://py.orgr
)rPr!rVrYrWr^r])rr#r&Zurlrrr�test_path_ok_web�s


z%HelpsourcePathokTest.test_path_ok_webc
Csl|�d�}x\dD]T\}}|���>|t_|j�t�|�|��|t�|�|j	dd�WdQRXqWdS)Nr))�darwinzfile://)�otherrr
)
rPrVrr`rYrWrUr!r^r])rr#r`�prefixrrr�test_path_ok_file�s

z&HelpsourcePathokTest.test_path_ok_fileN)rrrr.rPrr`r_�classmethodrbrcrdrerirrrrr\�s	r\c@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)rY)rrrrr^�sz.HelpsourceEntryokTest.Dummy_HelpSource.path_okN)
rrrrrMrr
r]rmr^rrrrrP�s
rPc
CsR|��}xDdD]<\}}}|���$|||_|_|�|��|�WdQRXqWdS)N))NNN)Nzdoc.txtN)�docNN)rnzdoc.txt)rnzdoc.txt)rPrVrlrYr!r)rr#rlrYrrrr�test_entry_ok_helpsource�s

z.HelpsourceEntryokTest.test_entry_ok_helpsourceN)rrrr.rProrrrrrk�s	rkc@s6eZdZdZGdd�d�Zdd�Zdd�Zdd	�Zd
S)�CustomRunCLIargsokTestz6Test cli_ok method of the CustomRun subclass of Query.c@s$eZdZejjZdd�Zdd�ZdS)z&CustomRunCLIargsokTest.Dummy_CustomRuncCst|d�|_ddi|_dS)N)r	r
r)rrr
)rrrrrrsz/CustomRunCLIargsokTest.Dummy_CustomRun.__init__cCs||jd<dS)Nr
)r
)rrrrrrsz0CustomRunCLIargsokTest.Dummy_CustomRun.showerrorN)rrrr�	CustomRun�cli_args_okrrrrrr�Dummy_CustomRunsrscCs|�d�}|�|��g�dS)Nr )rsr!rr)rr#rrr�test_blank_argss
z&CustomRunCLIargsokTest.test_blank_argscCs0|�d�}|�|��d�|�d|jd�dS)Nz'no-closing-quotez
No closingr
)rsr!rrr"r
)rr#rrr�test_invalid_argss
z(CustomRunCLIargsokTest.test_invalid_argscCsPddddddg}|�d�|�d�}|�|��|d	g�|�|jd
d�dS)Nz-nZ10z	--verbosez-pz/pathz--namer z
 "my name"zmy namer
r)rs�joinr!rrr
)r�argsr#rrr�test_good_argssz%CustomRunCLIargsokTest.test_good_argsN)rrrr.rsrtrurxrrrrrp	s
rpc@s&eZdZdZGdd�d�Zdd�ZdS)�CustomRunEntryokTestz8Test entry_ok method of the CustomRun subclass of Query.c@s&eZdZejjZiZe�Zdd�Z	dS)z$CustomRunEntryokTest.Dummy_CustomRuncCs|jS)N)�cli_args)rrrrrr+sz0CustomRunEntryokTest.Dummy_CustomRun.cli_args_okN)
rrrrrqrr
r�
restartvarrrrrrrrs'srscCsx|��}xjdD]b}|j�|�xPddgdg|fffD]8\}}|j||d��||_|�|��|�WdQRXq4WqWdS)N>FT)NNzmy arg)�restartrz)rsr{rWrVrzr!r)rr#r|rzrrrr�test_entry_ok_customrun.s
z,CustomRunEntryokTest.test_entry_ok_customrunN)rrrr.rsr}rrrrry$sryc@sDeZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�QueryGuiTestcCsBtd�t�|_}|j��tj|dddd�|_t��|j_	dS)N�guiZTESTZtestT)�_utest)
rr�root�withdrawrrr#rr(r)rar�rrr�
setUpClass=s

zQueryGuiTest.setUpClasscCs|j`|`|j��|`dS)N)r#rr�)rarrrrbEs
zQueryGuiTest.tearDownClasscCs(|jj�dd�d|j_|jj��dS)Nr�end)r#r�deleterrZ
reset_mock)rrrr�setUpLszQueryGuiTest.setUpcCs>|j}|j�dd�|j��|�|jd�|�|jj	�dS)Nr�abc)
r#r�insert�	button_ok�invoker!rr)rr*)rr#rrr�
test_click_okQs

zQueryGuiTest.test_click_okcCs0|j}|j��|�|jd�|�|jj�dS)N)r#r�r�r!rZassertFalserr*)rr#rrr�test_click_blankXs
zQueryGuiTest.test_click_blankcCs>|j}|j�dd�|j��|�|jd�|�|jj	�dS)Nrr�)
r#rr�Z
button_cancelr�r!rr)rr*)rr#rrr�test_click_cancel^s

zQueryGuiTest.test_click_cancelN)
rrrrjr�rbr�r�r�r�rrrrr~;sr~c@s eZdZedd��Zdd�ZdS)�SectionnameGuiTestcCstd�dS)Nr)r)rarrrr�hszSectionnameGuiTest.setUpClasscCslt�}|��tj|dddhdd�}|j}|�|jdh�|j�dd�|j�	�|�|j
d�|��dS)N�T�tr�T)r�rZokay)rr�rr1r!r2rr�r�r�rr)rr�r#r&rrr�test_click_section_namels
z*SectionnameGuiTest.test_click_section_nameN)rrrrjr�r�rrrrr�fsr�c@s eZdZedd��Zdd�ZdS)�ModulenameGuiTestcCstd�dS)Nr)r)rarrrr�zszModulenameGuiTest.setUpClasscCsjt�}|��tj|ddddd�}|�|jd�|�|j��d�|j�	�|�
|j�d��|�
�dS)Nr�r�r@T)r�z__init__.py)rr�rr9r!r:rrXr�r�r)rrAr)rr�r#rrr�test_click_module_name~s
z(ModulenameGuiTest.test_click_module_nameN)rrrrjr�r�rrrrr�xsr�c@s eZdZedd��Zdd�ZdS)�GotoGuiTestcCstd�dS)Nr)r)rarrrr��szGotoGuiTest.setUpClasscCsRt�}|��tj|dddd�}|j�dd�|j��|�|j	d�|�
�dS)Nr�r�T)r�rZ22�)rr�rrDrr�r�r�r!rr)rr�r#rrrr��s
z"GotoGuiTest.test_click_module_nameN)rrrrjr�r�rrrrr��sr�c@s eZdZedd��Zdd�ZdS)�HelpsourceGuiTestcCstd�dS)Nr)r)rarrrr��szHelpsourceGuiTest.setUpClasscCs�t�}|��tj|ddtdd�}|j}||j��d�||j��t�|j	�
�tjdkr`dnd}||j
d|tf�|��dS)Nr�Z__test__T)Zmenuitem�filepathr�rfzfile://r)rr�rrMrUr!rrXrYr�r��sysr`rr)rr�r#r&rhrrr�test_click_help_source�s


z(HelpsourceGuiTest.test_click_help_sourceN)rrrrjr�r�rrrrr��sr�c@s eZdZedd��Zdd�ZdS)�CustomRunGuiTestcCstd�dS)Nr)r)rarrrr��szCustomRunGuiTest.setUpClasscCsrt�}|��tj|dddgdd�}|�|j��d�|j�td�|j	�
�|�|jdddgdf�|��dS)	NZTitlerEzb=1T)rzr�za b=1z crR)
rr�rrqr!rrXr�rr�r�rr)rr�r#rrr�test_click_args�s
z CustomRunGuiTest.test_click_argsN)rrrrjr�r�rrrrr��sr��__main__�F)�	verbosity�exit)r.r@rZunittestZtest.supportrZtkinterrrr�rZidlelib.idle_test.mock_tkrZTestCaserr/r8rCrLr\rkrpryr~r�r�r�r�r�r�mainrrrr�<module>s03!!-+


?>