HEX
Server: Apache
System: Linux sg2plmcpnl492417.prod.sin2.secureserver.net 4.18.0-553.58.1.lve.el8.x86_64 #1 SMP Fri Jul 4 12:07:06 UTC 2025 x86_64
User: nyiet8349bzl (9207396)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //proc/self/root/opt/python38/lib/python3.8/idlelib/idle_test/__pycache__/test_query.cpython-38.pyc
U

�i�_Z<�@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��selfZdummy_entry�r�;/opt/python38/lib/python3.8/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r&cCsD|�d�}|�|��d�|�|j|jfd�|�d|jd�dS)N� �NFz
blank liner)r&�assertEqualr#rr�assertInr�r�dialogrrr�test_entry_ok_blank+s
zQueryTest.test_entry_ok_blankcCsD|�d�}|j}||��d�||j|jfd�||jdd�dS)N�  good �goodr(rr
)r&r)r#rrr)rr,�Equalrrr�test_entry_ok_good1s

zQueryTest.test_entry_ok_goodcCsT|�d�}t��|j_|�|��d�|�|jjj�|j`|�|j	|j
fd�dS)Nr
r()r&r�MockrZ	focus_setr)r$�
assertTrue�calledrrr+rrr�
test_ok_blank8s
zQueryTest.test_ok_blankcCs2|�d�}|�|��d�|�|j|jfd�dS)Nr/)r/T)r&r)r$rrr+rrr�test_ok_good@s
zQueryTest.test_ok_goodcCs2|�d�}|�|��d�|�|j|jfd�dS)Nzdoes not matterr)r&r)r%rrr+rrr�test_cancelEs
zQueryTest.test_cancelN)
rr r!�__doc__r&r-r1r5r6r7rrrrr	sr	c@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�Nr
rr
�rrrrrrrrQsz*SectionNameTest.Dummy_SectionName.__init__cCs||jd<dSrrrrrrrTsz+SectionNameTest.Dummy_SectionName.showerrorN)	rr r!r�SectionNamer#�
used_namesrrrrrr�Dummy_SectionNameNsr?cCs0|�d�}|�|��d�|�d|jd�dS�Nr'zno namer�r?r)r#r*rr+rrr�test_blank_section_nameWs
z'SectionNameTest.test_blank_section_namecCs0|�d�}|�|��d�|�d|jd�dS)Nr:ZuserrAr+rrr�test_used_section_name\s
z&SectionNameTest.test_used_section_namecCs0|�d�}|�|��d�|�d|jd�dS)NZ goodgoodgoodgoodgoodgoodgoodgoodzlonger than 30rrAr+rrr�test_long_section_nameas
z&SectionNameTest.test_long_section_namecCs0|�d�}|�|��d�|�|jdd�dS)Nr.r/rr
)r?r)r#rr+rrr�test_good_section_namefs
z&SectionNameTest.test_good_section_nameN)	rr r!r8r?rBrCrDrErrrrr9Ks	r9c@s>eZdZdZGdd�d�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�ModuleNameTestz"Test ModuleName subclass of Query.c@s(eZdZejjZdZdd�Zdd�ZdS)zModuleNameTest.Dummy_ModuleNamer
cCst|d�|_ddi|_dSr;r<rrrrrrsz(ModuleNameTest.Dummy_ModuleName.__init__cCs||jd<dSrrrrrrrusz)ModuleNameTest.Dummy_ModuleName.showerrorN)	rr r!r�
ModuleNamer#�text0rrrrrr�Dummy_ModuleNameosrIcCs0|�d�}|�|��d�|�d|jd�dSr@�rIr)r#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rJr+rrr�test_bogus_module_name}s
z%ModuleNameTest.test_bogus_module_namecCs0|�d�}|�|��d�|�d|jd�dS)N�	itertoolszsource-basedrrJr+rrr�test_c_source_name�s
z!ModuleNameTest.test_c_source_namecCsd|�d�}|�|���d��|�|jdd�|�d�}|�|���d��|�|jdd�dS)N�idlelib�__init__.pyrr
zos.pathzpath.py)rIr3r#�endswithr)rr+rrr�test_good_module_name�s

z$ModuleNameTest.test_good_module_nameN)	rr r!r8rIrKrLrNrRrrrrrFls	rFc@s6eZdZdZGdd�d�Zdd�Zdd�Zdd	�Zd
S)�GotoTestzTest Goto subclass of Query.c@s$eZdZejjZdd�Zdd�ZdS)zGotoTest.Dummy_ModuleNamecCst|d�|_ddi|_dSr;r<rrrrr�sz"GotoTest.Dummy_ModuleName.__init__cCs||jd<dSrrrrrrr�sz#GotoTest.Dummy_ModuleName.showerrorN)rr r!r�Gotor#rrrrrrrI�srIcCs0|�d�}|�|��d�|�d|jd�dS)N�aznot a base 10 integerrrJr+rrr�test_bogus_goto�s
zGotoTest.test_bogus_gotocCs0|�d�}|�|��d�|�d|jd�dS)N�0znot a positive integerrrJr+rrr�
test_bad_goto�s
zGotoTest.test_bad_gotocCs0|�d�}|�|��d�|�|jdd�dS)N�1�rr
)rIr)r#rr+rrr�test_good_goto�s
zGotoTest.test_good_gotoN)rr r!r8rIrVrXr[rrrrrS�s
rSc@s&eZdZdZGdd�d�Zdd�ZdS)�HelpsourceBrowsefileTestz8Test browse_file method of ModuleName subclass of Query.c@seZdZejjZe�ZdS)z)HelpsourceBrowsefileTest.Dummy_HelpSourceN)rr r!r�
HelpSource�browse_filer�pathvarrrrr�Dummy_HelpSource�sr`c
Cs�|��}ddd�dfddd�tfddd�dfddd�tffD]J\}}}|���2|j�|�||_|��|�|j��|�W5QRXq<dS)Nr
cSsdS�Nr
r�rU�b�crrr�<lambda>��zBHelpsourceBrowsefileTest.test_file_replaces_path.<locals>.<lambda>cSstS�N��__file__rbrrrre�rfZhtestcSsdSrarrbrrrre�rfcSstSrgrhrbrrrre�rf)	r`ri�subTestr_�setZaskfilenamer^r)�get)rr,�path�funcrrrr�test_file_replaces_path�s�
z0HelpsourceBrowsefileTest.test_file_replaces_pathN)rr r!r8r`rorrrrr\�sr\c@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|_dSr;)rrm�
path_error)rZ
dummy_pathrrrr�sz.HelpsourcePathokTest.Dummy_HelpSource.__init__NcCs||jd<dSr)rq)rrZwidgetrrrr�sz/HelpsourcePathokTest.Dummy_HelpSource.showerror)N)rr r!rr]�path_okrrrrrrr`�sr`cCs|jt_dSrg)�
orig_platformr�platform��clsrrr�
tearDownClass�sz"HelpsourcePathokTest.tearDownClasscCs0|�d�}|�|��d�|�d|jd�dS)Nr'zno help filer)r`r)rrr*rqr+rrr�test_path_ok_blank�s
z'HelpsourcePathokTest.test_path_ok_blankcCs4|�td�}|�|��d�|�d|jd�dS)Nzbad-bad-badz	not existr)r`rir)rrr*rqr+rrr�test_path_ok_bad�sz%HelpsourcePathokTest.test_path_ok_badc
Cs`|�d�}|j}dD]F}|���4|j�|�|�|��|�|�|jdd�W5QRXqdS)Nr
)z
www.py.orgz
http://py.orgr)r`r)rjrmrkrrrq)rr,r0Zurlrrr�test_path_ok_web�s

z%HelpsourcePathokTest.test_path_ok_webc
Csh|�d�}dD]T\}}|���>|t_|j�t�|�|��|t�|�|j	dd�W5QRXqdS)Nr
))�darwin�file://)�otherr
r)
r`rjrrtrmrkrir)rrrq)rr,rt�prefixrrr�test_path_ok_file�s

z&HelpsourcePathokTest.test_path_ok_fileN)rr r!r8r`rrtrs�classmethodrwrxryrzrrrrrrp�s
	rpc@s&eZdZdZGdd�d�Zdd�ZdS)�HelpsourceEntryokTestz5Test entry_ok method of HelpSource subclass of Query.c@s,eZdZejjZiZiZdd�Zdd�Z	dS)z&HelpsourceEntryokTest.Dummy_HelpSourcecCs|jSrg)�namerrrr�item_ok�sz.HelpsourceEntryokTest.Dummy_HelpSource.item_okcCs|jSrg)rmrrrrrr�sz.HelpsourceEntryokTest.Dummy_HelpSource.path_okN)
rr r!rr]r#rrqr�rrrrrrr`�s
r`c
CsN|��}dD]<\}}}|���$|||_|_|�|��|�W5QRXqdS)N))NNN)N�doc.txtN)�docNN)r�r�)r�r�)r`rjr�rmr)r#)rr,r�rmrrrr�test_entry_ok_helpsource�s

z.HelpsourceEntryokTest.test_entry_ok_helpsourceN)rr r!r8r`r�rrrrr��s	r�c@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|_dSr;r<rrrrrsz/CustomRunCLIargsokTest.Dummy_CustomRun.__init__cCs||jd<dSrrrrrrrsz0CustomRunCLIargsokTest.Dummy_CustomRun.showerrorN)rr r!r�	CustomRun�cli_args_okrrrrrr�Dummy_CustomRunsr�cCs|�d�}|�|��g�dS)Nr')r�r)r�r+rrr�test_blank_argss
z&CustomRunCLIargsokTest.test_blank_argscCs0|�d�}|�|��d�|�d|jd�dS)Nz'no-closing-quotez
No closingr)r�r)r�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
)r��joinr)r�r)r�argsr,rrr�test_good_args sz%CustomRunCLIargsokTest.test_good_argsN)rr r!r8r�r�r�r�rrrrr�s
r�c@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|jSrg)�cli_argsrrrrr�.sz0CustomRunEntryokTest.Dummy_CustomRun.cli_args_okN)
rr r!rr�r#rr�
restartvarr�rrrrr�*sr�cCsp|��}dD]^}|j�|�ddgdg|fffD]8\}}|j||d��||_|�|��|�W5QRXq0qdS)N>FT)NNzmy arg)�restartr�)r�r�rkrjr�r)r#)rr,r�r�rrrr�test_entry_ok_customrun1s�z,CustomRunEntryokTest.test_entry_ok_customrunN)rr r!r8r�r�rrrrr�'sr�c@sDeZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�QueryGuiTestcCsBtd�t�|_}|j��tj|dddd�|_t��|j_	dS)N�guiZTEST�testT��_utest)
rr�root�withdrawrr"r,rr2r)rvr�rrr�
setUpClass@s

zQueryGuiTest.setUpClasscCs|j`|`|j��|`dSrg)r,rr�rurrrrwHs
zQueryGuiTest.tearDownClasscCs(|jj�dd�d|j_|jj��dS)Nr�end)r,r�deleterrZ
reset_mockrrrr�setUpOszQueryGuiTest.setUpcCs>|j}|j�dd�|j��|�|jd�|�|jj	�dS�Nr�abc)
r,r�insert�	button_ok�invoker)rr3rr4r+rrr�
test_click_okTs

zQueryGuiTest.test_click_okcCs0|j}|j��|�|jd�|�|jj�dSrg)r,r�r�r)rZassertFalserr4r+rrr�test_click_blank[s
zQueryGuiTest.test_click_blankcCs>|j}|j�dd�|j��|�|jd�|�|jj	�dSr�)
r,rr�Z
button_cancelr�r)rr3rr4r+rrr�test_click_cancelas

zQueryGuiTest.test_click_cancelN)
rr r!r�r�rwr�r�r�r�rrrrr�>s

r�c@s eZdZedd��Zdd�ZdS)�SectionnameGuiTestcCstd�dS�Nr�rrurrrr�kszSectionnameGuiTest.setUpClasscCslt�}|��tj|dddhdd�}|j}|�|jdh�|j�dd�|j�	�|�|j
d�|��dS)N�T�tr�Tr�rZokay)rr�rr=r)r>rr�r�r�rr)rr�r,r0rrr�test_click_section_nameos
z*SectionnameGuiTest.test_click_section_nameN)rr r!r�r�r�rrrrr�is
r�c@s eZdZedd��Zdd�ZdS)�ModulenameGuiTestcCstd�dSr�rrurrrr�}szModulenameGuiTest.setUpClasscCsjt�}|��tj|ddddd�}|�|jd�|�|j��d�|j�	�|�
|j�d��|�
�dS)Nr�r�rOTr�rP)rr�rrGr)rHrrlr�r�r3rrQr�rr�r,rrr�test_click_module_name�s
z(ModulenameGuiTest.test_click_module_nameN�rr r!r�r�r�rrrrr�{s
r�c@s eZdZedd��Zdd�ZdS)�GotoGuiTestcCstd�dSr�rrurrrr��szGotoGuiTest.setUpClasscCsRt�}|��tj|dddd�}|j�dd�|j��|�|j	d�|�
�dS)Nr�r�Tr�rZ22�)rr�rrTrr�r�r�r)rrr�rrrr��s
z"GotoGuiTest.test_click_module_nameNr�rrrrr��s
r�c@s eZdZedd��Zdd�ZdS)�HelpsourceGuiTestcCstd�dSr�rrurrrr��szHelpsourceGuiTest.setUpClasscCs�t�}|��tj|ddtdd�}|j}||j��d�||j��t�|j	�
�tjdkr`dnd}||j
d|tf�|��dS)Nr�Z__test__T)Zmenuitem�filepathr�r{r|r
)rr�rr]rir)rrlrmr�r��sysrtrr)rr�r,r0r~rrr�test_click_help_source�s
�
z(HelpsourceGuiTest.test_click_help_sourceN)rr r!r�r�r�rrrrr��s
r�c@s eZdZedd��Zdd�ZdS)�CustomRunGuiTestcCstd�dSr�rrurrrr��szCustomRunGuiTest.setUpClasscCsrt�}|��tj|dddgdd�}|�|j��d�|j�td�|j	�
�|�|jdddgdf�|��dS)	NZTitlerUzb=1T)r�r�za b=1z crd)
rr�rr�r)rrlr�rr�r�rrr�rrr�test_click_args�s�
z CustomRunGuiTest.test_click_argsN)rr r!r�r�r�rrrrr��s
r��__main__�F)�	verbosity�exit)r8rOrZunittestZtest.supportr�tkinterrrr�rZidlelib.idle_test.mock_tkrZTestCaser	r9rFrSr\rpr�r�r�r�r�r�r�r�r�r�mainrrrr�<module>s03!$-+