HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/idlelib/idle_test/__pycache__/test_query.cpython-310.pyc
o

�i^<�@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&kr�ejd'd(d)�dSdS)*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�9/usr/local/lib/python3.10/idlelib/idle_test/test_query.py�__init__!s

zQueryTest.Dummy_Query.__init__cC�||jd<dS�Nr�r�r�messagerrr�	showerror&�zQueryTest.Dummy_Query.showerrorcCs
d|_dS�NT)r�rrrr�destroy(s
zQueryTest.Dummy_Query.destroyN)�__name__�
__module__�__qualname__r�Query�entry_ok�ok�cancelrrr rrrr�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_blankcC�2|�d�}|�|��d�|�|j|jfd�dS)Nr1)r1T)r(r+r&rrr-rrr�test_ok_good@�
zQueryTest.test_ok_goodcCr8)Nzdoes not matterr)r(r+r'rrr-rrr�test_cancelEr:zQueryTest.test_cancelN)
r!r"r#�__doc__r(r/r3r7r9r;rrrrr	sr	c@�>eZdZdZGdd�d�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�SectionNameTestz#Test SectionName subclass of Query.c@s*eZdZejjZdgZdd�Zdd�ZdS)z!SectionNameTest.Dummy_SectionName�usedcC�t|d�|_ddi|_dS�Nr
rr
�rrrrrrrrQ�z*SectionNameTest.Dummy_SectionName.__init__cCrrrrrrrrTrz+SectionNameTest.Dummy_SectionName.showerrorN)	r!r"r#r�SectionNamer%�
used_namesrrrrrr�Dummy_SectionNameNs
rFcC�0|�d�}|�|��d�|�d|jd�dS�Nr)zno namer�rFr+r%r,rr-rrr�test_blank_section_nameW�
z'SectionNameTest.test_blank_section_namecCrG)Nr?ZuserrIr-rrr�test_used_section_name\rKz&SectionNameTest.test_used_section_namecCrG)NZ goodgoodgoodgoodgoodgoodgoodgoodzlonger than 30rrIr-rrr�test_long_section_namearKz&SectionNameTest.test_long_section_namecC�0|�d�}|�|��d�|�|jdd�dS)Nr0r1rr
)rFr+r%rr-rrr�test_good_section_namefrKz&SectionNameTest.test_good_section_nameN)	r!r"r#r<rFrJrLrMrOrrrrr>K�	r>c@r=)
�ModuleNameTestz"Test ModuleName subclass of Query.c@s(eZdZejjZdZdd�Zdd�ZdS)zModuleNameTest.Dummy_ModuleNamer
cCr@rArBrrrrrrrCz(ModuleNameTest.Dummy_ModuleName.__init__cCrrrrrrrrurz)ModuleNameTest.Dummy_ModuleName.showerrorN)	r!r"r#r�
ModuleNamer%�text0rrrrrr�Dummy_ModuleNameos
rTcCrGrH�rTr+r%r,rr-rrr�test_blank_module_namexrKz%ModuleNameTest.test_blank_module_namecCrG)NZ __name_xyz123_should_not_exist__z	not foundrrUr-rrr�test_bogus_module_name}rKz%ModuleNameTest.test_bogus_module_namecCrG)N�	itertoolszsource-basedrrUr-rrr�test_c_source_name�rKz!ModuleNameTest.test_c_source_namecCsd|�d�}|�|���d��|�|jdd�|�d�}|�|���d��|�|jdd�dS)N�idlelib�__init__.pyrr
zidlelib.idlezidle.py)rTr5r%�endswithr+rr-rrr�test_good_module_name�s

z$ModuleNameTest.test_good_module_nameN)	r!r"r#r<rTrVrWrYr]rrrrrQlrPrQc@�6eZdZdZGdd�d�Zdd�Zdd�Zdd	�Zd
S)�GotoTestzTest Goto subclass of Query.c@�$eZdZejjZdd�Zdd�ZdS)zGotoTest.Dummy_ModuleNamecCr@rArBrrrrr�rCz"GotoTest.Dummy_ModuleName.__init__cCrrrrrrrr�rz#GotoTest.Dummy_ModuleName.showerrorN)r!r"r#r�Gotor%rrrrrrrT��rTcCrG)N�aznot a base 10 integerrrUr-rrr�test_bogus_goto�rKzGotoTest.test_bogus_gotocCrG)N�0znot a positive integerrrUr-rrr�
test_bad_goto�rKzGotoTest.test_bad_gotocCrN)N�1�rr
)rTr+r%rr-rrr�test_good_goto�rKzGotoTest.test_good_gotoN)r!r"r#r<rTrdrfrirrrrr_�sr_c@�&eZdZdZGdd�d�Zdd�ZdS)�HelpsourceBrowsefileTestz8Test browse_file method of ModuleName subclass of Query.c@seZdZejjZe�ZdS)z)HelpsourceBrowsefileTest.Dummy_HelpSourceN)r!r"r#r�
HelpSource�browse_filer�pathvarrrrr�Dummy_HelpSource�s
roc	Cs�|��}ddd�dfddd�tfddd�dfddd�tffD]/\}}}|���|j�|�||_|��|�|j��|�Wd�n1sHwYqdS)Nr
cS�dS�Nr
r�rc�b�crrr�<lambda>��zBHelpsourceBrowsefileTest.test_file_replaces_path.<locals>.<lambda>cS�tS�N��__file__rrrrrru�rvZhtestcSrprqrrrrrrru�rvcSrwrxryrrrrrru�rv)	rorz�subTestrn�setZaskfilenamermr+�get)rr.�path�funcrrrr�test_file_replaces_path�s�
���z0HelpsourceBrowsefileTest.test_file_replaces_pathN)r!r"r#r<ror�rrrrrk�srkc@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_HelpSourcecCr@rA)rr~�
path_error)rZ
dummy_pathrrrr�rCz.HelpsourcePathokTest.Dummy_HelpSource.__init__NcCrr)r�)rrZwidgetrrrr�rz/HelpsourcePathokTest.Dummy_HelpSource.showerrorrx)r!r"r#rrl�path_okrrrrrrro�srocCs|jt_dSrx)�
orig_platformr�platform��clsrrr�
tearDownClass��z"HelpsourcePathokTest.tearDownClasscCrG)Nr)zno help filer)ror+r�r,r�r-rrr�test_path_ok_blank�rKz'HelpsourcePathokTest.test_path_ok_blankcCs4|�td�}|�|��d�|�d|jd�dS)Nzbad-bad-badz	not existr)rorzr+r�r,r�r-rrr�test_path_ok_bad�sz%HelpsourcePathokTest.test_path_ok_badc	Cst|�d�}|j}dD]-}|���|j�|�|�|��|�|�|jdd�Wd�n1s2wYq
dS)Nr
)z
www.py.orgz
http://py.orgr)ror+r{r~r|r�r�)rr.r2�urlrrr�test_path_ok_web�s

���z%HelpsourcePathokTest.test_path_ok_webc	Cs||�d�}dD]4\}}|���$|t_|j�t�|�|��|t�|�|j	dd�Wd�n1s6wYqdS)Nr
))�darwin�file://)�otherr
r)
ror{rr�r~r|rzr+r�r�)rr.r��prefixrrr�test_path_ok_file�s

���z&HelpsourcePathokTest.test_path_ok_fileN)r!r"r#r<rorr�r��classmethodr�r�r�r�r�rrrrr��s
	r�c@rj)�HelpsourceEntryokTestz5Test entry_ok method of HelpSource subclass of Query.c@s,eZdZejjZiZiZdd�Zdd�Z	dS)z&HelpsourceEntryokTest.Dummy_HelpSourcecC�|jSrx)�namerrrr�item_ok��z.HelpsourceEntryokTest.Dummy_HelpSource.item_okcCr�rx)r~rrrrr��r�z.HelpsourceEntryokTest.Dummy_HelpSource.path_okN)
r!r"r#rrlr%rr�r�r�rrrrro�sroc	Csb|��}dD](\}}}|���|||_|_|�|��|�Wd�n1s)wYqdS)N))NNN)N�doc.txtN)�docNN)r�r�)r�r�)ror{r�r~r+r%)rr.r�r~rrrr�test_entry_ok_helpsource�s
���z.HelpsourceEntryokTest.test_entry_ok_helpsourceN)r!r"r#r<ror�rrrrr��s	r�c@r^)�CustomRunCLIargsokTestz6Test cli_ok method of the CustomRun subclass of Query.c@r`)z&CustomRunCLIargsokTest.Dummy_CustomRuncCr@rArBrrrrrrCz/CustomRunCLIargsokTest.Dummy_CustomRun.__init__cCrrrrrrrrrz0CustomRunCLIargsokTest.Dummy_CustomRun.showerrorN)r!r"r#r�	CustomRun�cli_args_okrrrrrr�Dummy_CustomRunrbr�cCs|�d�}|�|��g�dS)Nr))r�r+r�r-rrr�test_blank_argss
z&CustomRunCLIargsokTest.test_blank_argscCrG)Nz'no-closing-quotez
No closingr)r�r+r�r,rr-rrr�test_invalid_argsrKz(CustomRunCLIargsokTest.test_invalid_argscCsHgd�}|�d�|�d�}|�|��|dg�|�|jdd�dS)N)z-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)r!r"r#r<r�r�r�r�rrrrr�sr�c@rj)�CustomRunEntryokTestz8Test entry_ok method of the CustomRun subclass of Query.c@s&eZdZejjZiZe�Zdd�Z	dS)z$CustomRunEntryokTest.Dummy_CustomRuncCr�rx)�cli_argsrrrrr�.r�z0CustomRunEntryokTest.Dummy_CustomRun.cli_args_okN)
r!r"r#rr�r%rr�
restartvarr�rrrrr�*s
r�c
Cs�|��}dD]9}|j�|�ddgdg|fffD]&\}}|j||d��||_|�|��|�Wd�n1s9wYqqdS)N>FT)NNzmy arg)�restartr�)r�r�r|r{r�r+r%)rr.r�r�rrrr�test_entry_ok_customrun1s�����z,CustomRunEntryokTest.test_entry_ok_customrunN)r!r"r#r<r�r�rrrrr�'sr�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.rr4r )r�r�rrr�
setUpClass@s

zQueryGuiTest.setUpClasscCs|j`|`|j��|`dSrx)r.r r�r�rrrr�Hs
zQueryGuiTest.tearDownClasscCs(|jj�dd�d|j_|jj��dS)Nr�end)r.r�deleterr Z
reset_mockrrrr�setUpOszQueryGuiTest.setUpcCs>|j}|j�dd�|j��|�|jd�|�|jj	�dS�Nr�abc)
r.r�insert�	button_ok�invoker+rr5r r6r-rrr�
test_click_okT�

zQueryGuiTest.test_click_okcCs0|j}|j��|�|jd�|�|jj�dSrx)r.r�r�r+rZassertFalser r6r-rrr�test_click_blank[s
zQueryGuiTest.test_click_blankcCs>|j}|j�dd�|j��|�|jd�|�|jj	�dSr�)
r.rr�Z
button_cancelr�r+rr5r r6r-rrr�test_click_cancelar�zQueryGuiTest.test_click_cancelN)
r!r"r#r�r�r�r�r�r�r�rrrrr�>s

r�c@� eZdZedd��Zdd�ZdS)�SectionnameGuiTestcC�td�dS�Nr�rr�rrrr�kr�zSectionnameGuiTest.setUpClasscCslt�}|��tj|dddhdd�}|j}|�|jdh�|j�dd�|j�	�|�|j
d�|��dS)N�T�tr�Tr�rZokay)rr�rrDr+rErr�r�r�rr )rr�r.r2rrr�test_click_section_nameos
z*SectionnameGuiTest.test_click_section_nameN)r!r"r#r�r�r�rrrrr�i�
r�c@r�)�ModulenameGuiTestcCr�r�rr�rrrr�}r�zModulenameGuiTest.setUpClasscCsjt�}|��tj|ddddd�}|�|jd�|�|j��d�|j�	�|�
|j�d��|�
�dS)Nr�r�rZTr�r[)rr�rrRr+rSrr}r�r�r5rr\r �rr�r.rrr�test_click_module_name�s
z(ModulenameGuiTest.test_click_module_nameN�r!r"r#r�r�r�rrrrr�{r�r�c@r�)�GotoGuiTestcCr�r�rr�rrrr��r�zGotoGuiTest.setUpClasscCsRt�}|��tj|dddd�}|j�dd�|j��|�|j	d�|�
�dS)Nr�r�Tr�rZ22�)rr�rrarr�r�r�r+rr r�rrrr��s
z"GotoGuiTest.test_click_module_nameNr�rrrrr��r�r�c@r�)�HelpsourceGuiTestcCr�r�rr�rrrr��r�zHelpsourceGuiTest.setUpClasscCs�t�}|��tj|ddtdd�}|j}||j��d�||j��t�|j	�
�tjdkr0dnd}||j
d|tf�|��dS)Nr�Z__test__T)Zmenuitem�filepathr�r�r�r
)rr�rrlrzr+rr}r~r�r��sysr�rr )rr�r.r2r�rrr�test_click_help_source�s
�
z(HelpsourceGuiTest.test_click_help_sourceN)r!r"r#r�r�r�rrrrr��r�r�c@r�)�CustomRunGuiTestcCr�r�rr�rrrr��r�zCustomRunGuiTest.setUpClasscCspt�}|��tj|dddgdd�}|�|j��d�|j�td�|j	�
�|�|jgd�df�|��dS)	NZTitlerc�b=1T)r�r�za b=1z c)rcr�rt)
rr�rr�r+rr}r�rr�r�rr r�rrr�test_click_args�s�
z CustomRunGuiTest.test_click_argsN)r!r"r#r�r�r�rrrrr��r�r��__main__�F)�	verbosity�exit)r<rZrZunittestZtest.supportr�tkinterrrr�rZidlelib.idle_test.mock_tkrZTestCaser	r>rQr_rkr�r�r�r�r�r�r�r�r�r�r!�mainrrrr�<module>s43!$-+�