• File: test_query.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/idlelib/idle_test/__pycache__/test_query.cpython-37.pyc
  • Date Modified: 10/26/2026 8:08 PM
  • File size: 19.57 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

Nj;@s~dZddlmZddlZddlmZddlmZmZddl	Z	ddlm
Z
ddlmZGdd	d	ej
ZGd
ddej
ZGdd
d
ej
ZGdddej
ZGdddej
ZGdddej
ZGdddej
ZGdddej
ZGdddej
ZGdddej
ZGdddej
ZGdddej
ZGd d!d!ej
ZGd"d#d#ej
ZGd$d%d%ej
Zed&krzejd'd(d)dS)*aTest 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)TkEND)mock)Varc@sFeZdZdZGdddZddZddZdd	Zd
dZdd
Z	dS)	QueryTestzTest Query base class.c@s<eZdZejjZejjZejjZddZddZ	ddZ
dS)zQueryTest.Dummy_QuerycCs&t|d|_ddi|_d|_d|_dS)N)valuetextF)rentryentry_errorresult	destroyed)selfdummy_entryrA/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_query.py__init__!s
zQueryTest.Dummy_Query.__init__cCs||jd<dS)Nr
)r
)rmessagerrr	showerror&szQueryTest.Dummy_Query.showerrorcCs
d|_dS)NT)r)rrrrdestroy(szQueryTest.Dummy_Query.destroyN)__name__
__module____qualname__rQueryentry_okokcancelrrrrrrrDummy_QuerysrcCsD|d}||d||j|jfd|d|jddS)N )NFz
blank liner
)rassertEqualrrrassertInr
)rdialogrrrtest_entry_ok_blank+s
zQueryTest.test_entry_ok_blankcCsD|d}|j}||d||j|jfd||jdddS)Nz  good good)NFr
r)rr!rrrr
)rr#Equalrrrtest_entry_ok_good1s

zQueryTest.test_entry_ok_goodcCsT|d}t|j_||d||jjj|j`||j	|j
fddS)Nr)NF)rrMockrZ	focus_setr!r
assertTruecalledrr)rr#rrr
test_ok_blank8s
zQueryTest.test_ok_blankcCs2|d}||d||j|jfddS)Nr%)r%T)rr!rrr)rr#rrrtest_ok_good@s
zQueryTest.test_ok_goodcCs2|d}||d||j|jfddS)Nzdoes not matter)NT)rr!rrr)rr#rrrtest_cancelEs
zQueryTest.test_cancelN)
rrr__doc__rr$r'r+r,r-rrrrrsrc@s>eZdZdZGdddZddZddZdd	Zd
dZdS)
SectionNameTestz#Test SectionName subclass of Query.c@s*eZdZejjZdgZddZddZdS)z!SectionNameTest.Dummy_SectionNameusedcCst|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)	rrrrSectionNamer
used_namesrrrrrrDummy_SectionNameNsr3cCs0|d}||d|d|jddS)Nr zno namer
)r3r!rr"r
)rr#rrrtest_blank_section_nameWs
z'SectionNameTest.test_blank_section_namecCs0|d}||d|d|jddS)Nr0Zuser
)r3r!rr"r
)rr#rrrtest_used_section_name\s
z&SectionNameTest.test_used_section_namecCs0|d}||d|d|jddS)NZ goodgoodgoodgoodgoodgoodgoodgoodzlonger than 30r
)r3r!rr"r
)rr#rrrtest_long_section_nameas
z&SectionNameTest.test_long_section_namecCs0|d}||d||jdddS)Nz  good r%r
r)r3r!rr
)rr#rrrtest_good_section_namefs
z&SectionNameTest.test_good_section_nameN)	rrrr.r3r4r5r6r7rrrrr/Ks	r/c@s>eZdZdZGdddZddZddZdd	Zd
dZdS)
ModuleNameTestz"Test ModuleName subclass of Query.c@s(eZdZejjZdZddZddZdS)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
ModuleNamertext0rrrrrrDummy_ModuleNameosr;cCs0|d}||d|d|jddS)Nr zno namer
)r;r!rr"r
)rr#rrrtest_blank_module_namexs
z%ModuleNameTest.test_blank_module_namecCs0|d}||d|d|jddS)NZ __name_xyz123_should_not_exist__z	not foundr
)r;r!rr"r
)rr#rrrtest_bogus_module_name}s
z%ModuleNameTest.test_bogus_module_namecCs0|d}||d|d|jddS)N	itertoolszsource-basedr
)r;r!rr"r
)rr#rrrtest_c_source_names
z!ModuleNameTest.test_c_source_namecCs4|d}||d||jdddS)Nidlelibz__init__.pyr
r)r;r)rendswithr!r
)rr#rrrtest_good_module_names
z$ModuleNameTest.test_good_module_nameN)	rrrr.r;r<r=r?rBrrrrr8ls	r8c@s6eZdZdZGdddZddZddZdd	Zd
S)GotoTestzTest Goto subclass of Query.c@s$eZdZejjZddZddZdS)zGotoTest.Dummy_ModuleNamecCst|d|_ddi|_dS)N)r	r
r)rrr
)rrrrrrsz"GotoTest.Dummy_ModuleName.__init__cCs||jd<dS)Nr
)r
)rrrrrrsz#GotoTest.Dummy_ModuleName.showerrorN)rrrrGotorrrrrrrr;sr;cCs0|d}||d|d|jddS)Naznot a base 10 integerr
)r;r!rr"r
)rr#rrrtest_bogus_gotos
zGotoTest.test_bogus_gotocCs0|d}||d|d|jddS)N0znot a positive integerr
)r;r!rr"r
)rr#rrr
test_bad_gotos
zGotoTest.test_bad_gotocCs0|d}||d||jdddS)N1r
r)r;r!rr
)rr#rrrtest_good_gotos
zGotoTest.test_good_gotoN)rrrr.r;rFrHrKrrrrrCs
rCc@s&eZdZdZGdddZddZdS)HelpsourceBrowsefileTestz8Test browse_file method of ModuleName subclass of Query.c@seZdZejjZeZdS)z)HelpsourceBrowsefileTest.Dummy_HelpSourceN)rrrr
HelpSourcebrowse_filerpathvarrrrrDummy_HelpSourcesrPc
Cs|}xddddfdddtfddddfdddtffD]J\}}}|2|j|||_|||j|WdQRXq>WdS)NrcSsdS)Nrr)rEbcrrr<lambda>zBHelpsourceBrowsefileTest.test_file_replaces_path.<locals>.<lambda>cSstS)N)__file__)rErQrRrrrrSrTZhtestcSsdS)Nrr)rErQrRrrrrSrTcSstS)N)rU)rErQrRrrrrSrT)	rPrUsubTestrOsetZaskfilenamerNr!get)rr#pathfuncrrrrtest_file_replaces_paths
z0HelpsourceBrowsefileTest.test_file_replaces_pathN)rrrr.rPr[rrrrrLsrLc@sPeZdZdZGdddZejZeddZ	ddZ
dd	Zd
dZdd
Z
dS)HelpsourcePathokTestz4Test path_ok method of HelpSource subclass of Query.c@s&eZdZejjZddZdddZdS)z%HelpsourcePathokTest.Dummy_HelpSourcecCst|d|_ddi|_dS)N)r	r
r)rrY
path_error)rZ
dummy_pathrrrrsz.HelpsourcePathokTest.Dummy_HelpSource.__init__NcCs||jd<dS)Nr
)r])rrZwidgetrrrrsz/HelpsourcePathokTest.Dummy_HelpSource.showerror)N)rrrrrMpath_okrrrrrrrPsrPcCs|jt_dS)N)
orig_platformrplatform)clsrrr
tearDownClasssz"HelpsourcePathokTest.tearDownClasscCs0|d}||d|d|jddS)Nr zno help filer
)rPr!r^r"r])rr#rrrtest_path_ok_blanks
z'HelpsourcePathokTest.test_path_ok_blankcCs4|td}||d|d|jddS)Nzbad-bad-badz	not existr
)rPrUr!r^r"r])rr#rrrtest_path_ok_badsz%HelpsourcePathokTest.test_path_ok_badc
Csd|d}|j}xNdD]F}|4|j||||||jddWdQRXqWdS)Nr)z
www.py.orgz
http://py.orgr
)rPr!rVrYrWr^r])rr#r&Zurlrrrtest_path_ok_webs


z%HelpsourcePathokTest.test_path_ok_webc
Csl|d}x\dD]T\}}|>|t_|jt|||t||j	ddWdQRXqWdS)Nr))darwinzfile://)otherrr
)
rPrVrr`rYrWrUr!r^r])rr#r`prefixrrrtest_path_ok_files

z&HelpsourcePathokTest.test_path_ok_fileN)rrrr.rPrr`r_classmethodrbrcrdrerirrrrr\s	r\c@s&eZdZdZGdddZddZdS)HelpsourceEntryokTestz5Test entry_ok method of HelpSource subclass of Query.c@s,eZdZejjZiZiZddZddZ	dS)z&HelpsourceEntryokTest.Dummy_HelpSourcecCs|jS)N)name)rrrritem_oksz.HelpsourceEntryokTest.Dummy_HelpSource.item_okcCs|jS)N)rY)rrrrr^sz.HelpsourceEntryokTest.Dummy_HelpSource.path_okN)
rrrrrMrr
r]rmr^rrrrrPs
rPc
CsR|}xDdD]<\}}}|$|||_|_|||WdQRXqWdS)N))NNN)Nzdoc.txtN)docNN)rnzdoc.txt)rnzdoc.txt)rPrVrlrYr!r)rr#rlrYrrrrtest_entry_ok_helpsources

z.HelpsourceEntryokTest.test_entry_ok_helpsourceN)rrrr.rProrrrrrks	rkc@s6eZdZdZGdddZddZddZdd	Zd
S)CustomRunCLIargsokTestz6Test cli_ok method of the CustomRun subclass of Query.c@s$eZdZejjZddZddZdS)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	CustomRuncli_args_okrrrrrrDummy_CustomRunsrscCs|d}||gdS)Nr )rsr!rr)rr#rrrtest_blank_argss
z&CustomRunCLIargsokTest.test_blank_argscCs0|d}||d|d|jddS)Nz'no-closing-quotez
No closingr
)rsr!rrr"r
)rr#rrrtest_invalid_argss
z(CustomRunCLIargsokTest.test_invalid_argscCsPddddddg}|d|d}|||d	g||jd
ddS)Nz-nZ10z	--verbosez-pz/pathz--namer z
 "my name"zmy namer
r)rsjoinr!rrr
)rargsr#rrrtest_good_argssz%CustomRunCLIargsokTest.test_good_argsN)rrrr.rsrtrurxrrrrrp	s
rpc@s&eZdZdZGdddZddZdS)CustomRunEntryokTestz8Test entry_ok method of the CustomRun subclass of Query.c@s&eZdZejjZiZeZddZ	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|rzrrrrtest_entry_ok_customrun.s
z,CustomRunEntryokTest.test_entry_ok_customrunN)rrrr.rsr}rrrrry$sryc@sDeZdZeddZeddZddZddZd	d
ZddZ	d
S)QueryGuiTestcCsBtdt|_}|jtj|dddd|_t|j_	dS)NguiZTESTZtestT)_utest)
rrrootwithdrawrrr#rr(r)rarrrr
setUpClass=s

zQueryGuiTest.setUpClasscCs|j`|`|j|`dS)N)r#rr)rarrrrbEs
zQueryGuiTest.tearDownClasscCs(|jjddd|j_|jjdS)Nrend)r#rdeleterrZ
reset_mock)rrrrsetUpLszQueryGuiTest.setUpcCs>|j}|jdd|j||jd||jj	dS)Nrabc)
r#rinsert	button_okinvoker!rr)rr*)rr#rrr
test_click_okQs

zQueryGuiTest.test_click_okcCs0|j}|j||jd||jjdS)N)r#rrr!rZassertFalserr*)rr#rrrtest_click_blankXs
zQueryGuiTest.test_click_blankcCs>|j}|jdd|j||jd||jj	dS)Nrr)
r#rrZ
button_cancelrr!rr)rr*)rr#rrrtest_click_cancel^s

zQueryGuiTest.test_click_cancelN)
rrrrjrrbrrrrrrrrr~;sr~c@s eZdZeddZddZdS)SectionnameGuiTestcCstddS)Nr)r)rarrrrhszSectionnameGuiTest.setUpClasscCslt}|tj|dddhdd}|j}||jdh|jdd|j	||j
d|dS)NTtrT)rrZokay)rrrr1r!r2rrrrrr)rrr#r&rrrtest_click_section_namels
z*SectionnameGuiTest.test_click_section_nameN)rrrrjrrrrrrrfsrc@s eZdZeddZddZdS)ModulenameGuiTestcCstddS)Nr)r)rarrrrzszModulenameGuiTest.setUpClasscCsjt}|tj|ddddd}||jd||jd|j	|
|jd|
dS)Nrrr@T)rz__init__.py)rrrr9r!r:rrXrrr)rrAr)rrr#rrrtest_click_module_name~s
z(ModulenameGuiTest.test_click_module_nameN)rrrrjrrrrrrrxsrc@s eZdZeddZddZdS)GotoGuiTestcCstddS)Nr)r)rarrrrszGotoGuiTest.setUpClasscCsRt}|tj|dddd}|jdd|j||j	d|
dS)NrrT)rrZ22)rrrrDrrrrr!rr)rrr#rrrrs
z"GotoGuiTest.test_click_module_nameN)rrrrjrrrrrrrsrc@s eZdZeddZddZdS)HelpsourceGuiTestcCstddS)Nr)r)rarrrrszHelpsourceGuiTest.setUpClasscCst}|tj|ddtdd}|j}||jd||jt|j	
tjdkr`dnd}||j
d|tf|dS)NrZ__test__T)Zmenuitemfilepathrrfzfile://r)rrrrMrUr!rrXrYrrsysr`rr)rrr#r&rhrrrtest_click_help_sources


z(HelpsourceGuiTest.test_click_help_sourceN)rrrrjrrrrrrrsrc@s eZdZeddZddZdS)CustomRunGuiTestcCstddS)Nr)r)rarrrrszCustomRunGuiTest.setUpClasscCsrt}|tj|dddgdd}||jd|jtd|j	
||jdddgdf|dS)	NZTitlerEzb=1T)rzrza b=1z crR)
rrrrqr!rrXrrrrrr)rrr#rrrtest_click_argss
z CustomRunGuiTest.test_click_argsN)rrrrjrrrrrrrsr__main__F)	verbosityexit)r.r@rZunittestZtest.supportrZtkinterrrrrZidlelib.idle_test.mock_tkrZTestCaserr/r8rCrLr\rkrpryr~rrrrrrmainrrrr<module>s03!!-+