a  ze^<@szddlmZddlZddlmZddlmZmZddlZddlm Z ddl m Z Gdddej Z Gd d d ej ZGd d d ej ZGd ddej ZGdddej ZGdddej ZGdddej ZGdddej ZGdddej ZGdddej ZGdddej ZGdddej ZGdd d ej ZGd!d"d"ej ZGd#d$d$ej Zed%krvejd&d'd(dS)))queryNrequires)TkEND)mock)Varc@sBeZdZGdddZddZddZddZd d Zd d Zd S) QueryTestc@s<eZdZejjZejjZejjZddZddZ ddZ dS)zQueryTest.Dummy_QuerycCs&t|d|_ddi|_d|_d|_dS)NvaluetextF)rentry entry_errorresult destroyedselfZ dummy_entryrP/opt/bitninja-python-dojo/embedded/lib/python3.9/idlelib/idle_test/test_query.py__init__!s  zQueryTest.Dummy_Query.__init__cCs||jd<dSNr rrmessagerrr showerror&szQueryTest.Dummy_Query.showerrorcCs d|_dSNT)rrrrrdestroy(szQueryTest.Dummy_Query.destroyN) __name__ __module__ __qualname__rQueryentry_okokcancelrrrrrrr Dummy_Querys r&cCsD|d}||d||j|jfd|d|jddS)N NFz blank liner )r& assertEqualr#rrassertInrrdialogrrrtest_entry_ok_blank+s zQueryTest.test_entry_ok_blankcCsD|d}|j}||d||j|jfd||jdddS)N good goodr(r r )r&r)r#rrr)rr,Equalrrrtest_entry_ok_good1s  zQueryTest.test_entry_ok_goodcCsT|d}t|j_||d||jjj|j`||j |j fddS)Nr r() r&rMockrZ focus_setr)r$ assertTruecalledrrr+rrr test_ok_blank8s   zQueryTest.test_ok_blankcCs2|d}||d||j|jfddS)Nr/)r/T)r&r)r$rrr+rrr test_ok_good@s zQueryTest.test_ok_goodcCs2|d}||d||j|jfddS)Nzdoes not matterr)r&r)r%rrr+rrr test_cancelEs zQueryTest.test_cancelN) rr r!r&r-r1r5r6r7rrrrr s r c@s:eZdZGdddZddZddZddZd d Zd S) SectionNameTestc@s*eZdZejjZdgZddZddZdS)z!SectionNameTest.Dummy_SectionNameusedcCst|d|_ddi|_dSNr r r rrrrrrrrQs z*SectionNameTest.Dummy_SectionName.__init__cCs||jd<dSrrrrrrrTsz+SectionNameTest.Dummy_SectionName.showerrorN) rr r!r SectionNamer# used_namesrrrrrrDummy_SectionNameNsr>cCs0|d}||d|d|jddSNr'zno namer r>r)r#r*rr+rrrtest_blank_section_nameWs z'SectionNameTest.test_blank_section_namecCs0|d}||d|d|jddS)Nr9Zuser r@r+rrrtest_used_section_name\s z&SectionNameTest.test_used_section_namecCs0|d}||d|d|jddS)NZ goodgoodgoodgoodgoodgoodgoodgoodzlonger than 30r r@r+rrrtest_long_section_nameas z&SectionNameTest.test_long_section_namecCs0|d}||d||jdddS)Nr.r/r r )r>r)r#rr+rrrtest_good_section_namefs z&SectionNameTest.test_good_section_nameN)rr r!r>rArBrCrDrrrrr8Ks  r8c@s:eZdZGdddZddZddZddZd d Zd S) ModuleNameTestc@s(eZdZejjZdZddZddZdS)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#text0rrrrrrDummy_ModuleNameosrHcCs0|d}||d|d|jddSr?rHr)r#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 rIr+rrrtest_bogus_module_name}s z%ModuleNameTest.test_bogus_module_namecCs0|d}||d|d|jddS)N itertoolsz source-basedr rIr+rrrtest_c_source_names z!ModuleNameTest.test_c_source_namecCsd|d}||d||jdd|d}||d||jdddS)Nidlelib __init__.pyr r z idlelib.idlezidle.py)rHr3r#endswithr)rr+rrrtest_good_module_names   z$ModuleNameTest.test_good_module_nameN)rr r!rHrJrKrMrQrrrrrEls  rEc@s2eZdZGdddZddZddZddZd S) GotoTestc@s$eZdZejjZddZddZdS)zGotoTest.Dummy_ModuleNamecCst|d|_ddi|_dSr:r;rrrrrs z"GotoTest.Dummy_ModuleName.__init__cCs||jd<dSrrrrrrrsz#GotoTest.Dummy_ModuleName.showerrorN)rr r!rGotor#rrrrrrrHsrHcCs0|d}||d|d|jddS)Naznot a base 10 integerr rIr+rrrtest_bogus_gotos zGotoTest.test_bogus_gotocCs0|d}||d|d|jddS)N0znot a positive integerr rIr+rrr test_bad_gotos zGotoTest.test_bad_gotocCs0|d}||d||jdddS)N1r r )rHr)r#rr+rrrtest_good_gotos zGotoTest.test_good_gotoN)rr r!rHrUrWrZrrrrrRsrRc@s"eZdZGdddZddZdS)HelpsourceBrowsefileTestc@seZdZejjZeZdS)z)HelpsourceBrowsefileTest.Dummy_HelpSourceN)rr r!r HelpSource browse_filerpathvarrrrrDummy_HelpSourcesr_c Cs|}ddddfdddtfddddfdddtffD]^\}}}|<|j|||_|||j|Wdq<1s0YqzBHelpsourceBrowsefileTest.test_file_replaces_path..cSstSN__file__rarrrrdreZhtestcSsdSr`rrarrrrdrecSstSrfrgrarrrrdre) r_rhsubTestr^setZ askfilenamer]r)get)rr,pathfuncrrrrtest_file_replaces_paths      z0HelpsourceBrowsefileTest.test_file_replaces_pathN)rr r!r_rnrrrrr[sr[c@sLeZdZGdddZejZeddZddZ ddZ d d Z d d Z d S)HelpsourcePathokTestc@s&eZdZejjZddZdddZdS)z%HelpsourcePathokTest.Dummy_HelpSourcecCst|d|_ddi|_dSr:)rrl path_error)rZ dummy_pathrrrrs z.HelpsourcePathokTest.Dummy_HelpSource.__init__NcCs||jd<dSr)rp)rrZwidgetrrrrsz/HelpsourcePathokTest.Dummy_HelpSource.showerror)N)rr r!rr\path_okrrrrrrr_sr_cCs |jt_dSrf) orig_platformrplatformclsrrr tearDownClasssz"HelpsourcePathokTest.tearDownClasscCs0|d}||d|d|jddS)Nr'z no help filer )r_r)rqr*rpr+rrrtest_path_ok_blanks z'HelpsourcePathokTest.test_path_ok_blankcCs4|td}||d|d|jddS)Nz bad-bad-badz not existr )r_rhr)rqr*rpr+rrrtest_path_ok_badsz%HelpsourcePathokTest.test_path_ok_badc Cst|d}|j}dD]Z}|>|j||||||jddWdq1sd0YqdS)Nr )z www.py.orgz http://py.orgr )r_r)rirlrjrqrp)rr,r0urlrrrtest_path_ok_webs   z%HelpsourcePathokTest.test_path_ok_webc Cs||d}dD]h\}}|H|t_|jt|||t||j ddWdq1sl0YqdS)Nr ))darwinfile://)otherr r ) r_rirrsrlrjrhr)rqrp)rr,rsprefixrrrtest_path_ok_files    z&HelpsourcePathokTest.test_path_ok_fileN) rr r!r_rrsrr classmethodrvrwrxrzrrrrrros  roc@s"eZdZGdddZddZdS)HelpsourceEntryokTestc@s,eZdZejjZiZiZddZddZ dS)z&HelpsourceEntryokTest.Dummy_HelpSourcecCs|jSrf)namerrrritem_oksz.HelpsourceEntryokTest.Dummy_HelpSource.item_okcCs|jSrf)rlrrrrrqsz.HelpsourceEntryokTest.Dummy_HelpSource.path_okN) rr r!rr\r#rrprrqrrrrr_s r_c Csb|}dD]P\}}}|.|||_|_|||Wdq 1sR0Yq dS)N))NNN)Ndoc.txtN)docNN)rr)rr)r_rirrlr)r#)rr,rrlrrrrtest_entry_ok_helpsources  z.HelpsourceEntryokTest.test_entry_ok_helpsourceN)rr r!r_rrrrrrs rc@s2eZdZGdddZddZddZddZd S) CustomRunCLIargsokTestc@s$eZdZejjZddZddZdS)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_okrrrrrrDummy_CustomRunsrcCs|d}||gdS)Nr')rr)rr+rrrtest_blank_argss z&CustomRunCLIargsokTest.test_blank_argscCs0|d}||d|d|jddS)Nz'no-closing-quotez No closingr )rr)rr*rr+rrrtest_invalid_argss z(CustomRunCLIargsokTest.test_invalid_argscCsHgd}|d|d}|||dg||jdddS)N)z-nZ10z --verbosez-pz/pathz--namer'z "my name"zmy namer r )rjoinr)rr)rargsr,rrrtest_good_args sz%CustomRunCLIargsokTest.test_good_argsN)rr r!rrrrrrrrr src@s"eZdZGdddZddZdS)CustomRunEntryokTestc@s&eZdZejjZiZeZddZ dS)z$CustomRunEntryokTest.Dummy_CustomRuncCs|jSrf)cli_argsrrrrr.sz0CustomRunEntryokTest.Dummy_CustomRun.cli_args_okN) rr r!rrr#rr restartvarrrrrrr*src Cs|}dD]r}|j|ddgdg|fffD]L\}}|j||d&||_|||Wdq01sr0Yq0q dS)N>FT)NNzmy arg)restartr)rrrjrirr)r#)rr,rrrrrrtest_entry_ok_customrun1s  z,CustomRunEntryokTest.test_entry_ok_customrunN)rr r!rrrrrrr'src@sDeZdZeddZeddZddZddZd d Zd d Z d S) QueryGuiTestcCsBtdt|_}|jtj|dddd|_t|j_ dS)NguiZTESTtestT_utest) rrrootwithdrawrr"r,rr2r)rurrrr setUpClass@s   zQueryGuiTest.setUpClasscCs|j`|`|j|`dSrf)r,rrrtrrrrvHs zQueryGuiTest.tearDownClasscCs(|jjddd|j_|jjdS)Nrend)r,rdeleterrZ reset_mockrrrrsetUpOszQueryGuiTest.setUpcCs>|j}|jdd|j||jd||jj dSNrabc) r,rinsert button_okinvoker)rr3rr4r+rrr test_click_okTs  zQueryGuiTest.test_click_okcCs0|j}|j||jd||jjdSrf)r,rrr)rZ assertFalserr4r+rrrtest_click_blank[s zQueryGuiTest.test_click_blankcCs>|j}|jdd|j||jd||jj dSr) r,rrZ button_cancelrr)rr3rr4r+rrrtest_click_cancelas  zQueryGuiTest.test_click_cancelN) rr r!rrrvrrrrrrrrr>s  rc@s eZdZeddZddZdS)SectionnameGuiTestcCs tddSNrrrtrrrrkszSectionnameGuiTest.setUpClasscCslt}|tj|dddhdd}|j}||jdh|jdd|j ||j d| dS)NTtrTrrZokay) rrrr<r)r=rrrrrr)rrr,r0rrrtest_click_section_nameos z*SectionnameGuiTest.test_click_section_nameN)rr r!rrrrrrrris rc@s eZdZeddZddZdS)ModulenameGuiTestcCs tddSrrrtrrrr}szModulenameGuiTest.setUpClasscCsjt}|tj|ddddd}||jd||jd|j | |j d| dS)NrrrNTrrO)rrrrFr)rGrrkrrr3rrPrrrr,rrrtest_click_module_names z(ModulenameGuiTest.test_click_module_nameNrr r!rrrrrrrr{s rc@s eZdZeddZddZdS) GotoGuiTestcCs tddSrrrtrrrrszGotoGuiTest.setUpClasscCsRt}|tj|dddd}|jdd|j||j d| dS)NrrTrrZ22) rrrrSrrrrr)rrrrrrrs z"GotoGuiTest.test_click_module_nameNrrrrrrs rc@s eZdZeddZddZdS)HelpsourceGuiTestcCs tddSrrrtrrrrszHelpsourceGuiTest.setUpClasscCst}|tj|ddtdd}|j}||jd||jt|j t j dkr`dnd}||j d|tf|dS)NrZ__test__T)Zmenuitemfilepathrr{r|r )rrrr\rhr)rrkrlrrsysrsrr)rrr,r0r~rrrtest_click_help_sources  z(HelpsourceGuiTest.test_click_help_sourceN)rr r!rrrrrrrrs rc@s eZdZeddZddZdS)CustomRunGuiTestcCs tddSrrrtrrrrszCustomRunGuiTest.setUpClasscCspt}|tj|dddgdd}||jd|jtd|j ||j gddf| dS) NZTitlerTb=1T)rrza b=1z c)rTrrc) rrrrr)rrkrrrrrrrrrrtest_click_argss z CustomRunGuiTest.test_click_argsN)rr r!rrrrrrrrs r__main__F) verbosityexit)rNrZunittestZ test.supportrtkinterrrrrZidlelib.idle_test.mock_tkrZTestCaser r8rErRr[rorrrrrrrrrrmainrrrr s.    3!$-+