a 9êdg;ã@sˆdZddlZddlmZddlmZmZmZddlm Z ddl m Z ddl m ZddlmZGd d „d ejƒZed kr„ejd d d dS)zTest searchbase, coverage 98%.éN)Úrequires)ÚTextÚTkÚToplevel)ÚFrame)Ú searchengine)Ú searchbase)ÚFuncc@s„eZdZedd„ƒZedd„ƒZdd„Zdd„Zd d „Zd d „Z d d„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„ZdS)ÚSearchDialogBaseTestcCstdƒtƒ|_dS)NZgui)rrÚroot©Úcls©rú=/usr/local/lib/python3.9/idlelib/idle_test/test_searchbase.pyÚ setUpClassszSearchDialogBaseTest.setUpClasscCs|j ¡|j ¡|`dS©N)r Úupdate_idletasksÚdestroyr rrrÚ tearDownClass!s  z"SearchDialogBaseTest.tearDownClasscCs&t |j¡|_tj|j|jd|_dS)N)r Úengine)ÚseZ SearchEnginer rÚsdbZSearchDialogBaseÚdialog©ÚselfrrrÚsetUp'szSearchDialogBaseTest.setUpcCs|j ¡dSr)rÚcloserrrrÚtearDown+szSearchDialogBaseTest.tearDowncCsd|j_t|jƒ}t|ƒ}|j |¡| |jj ¡d¡|j  ¡| |jj ¡d¡|jj|dd| |jj   ¡d¡|  ¡|  ¡dS)NZnormalZ withdrawnÚhello)Z searchphrase)rÚdefault_commandrr rÚopenÚ assertEqualÚtopÚstaterÚentÚgetrr)rZtoplevelÚtextrrrÚtest_open_and_close.s   z(SearchDialogBaseTest.test_open_and_closecCs~tƒ|j_tƒ|j_tƒ|j_tƒ|j_d|j_|j ¡| |jjj ¡| |jjj ¡| |jjj ¡| |jjj ¡dSr) r rÚcreate_entriesÚcreate_option_buttonsÚcreate_other_buttonsÚcreate_command_buttonsrZcreate_widgetsZ assertTrueZcalledrrrrÚtest_create_widgets>s     z(SearchDialogBaseTest.test_create_widgetscCs®|j}d|j_t|jƒ|j_|j dd¡\}}||ddƒ| | ¡d¡|  ¡}|t |dƒdƒ|t |dƒdƒ|t |dƒdƒ|t |d ƒdƒ||jjdƒdS) NrzTest:rr&ÚrowÚcolumnéZrowspanZ columnspan) r!rr-rr ÚframeZ make_entryÚassertInr%Z grid_infoÚint)rZequalÚentryÚlabelZegirrrÚtest_make_entryLsz$SearchDialogBaseTest.test_make_entrycCsDt|jƒ|j_d|j_|j d¡|j ¡| |jj   ¡d¡dS)Nrr) rr rr0r-rZsetpatr(r1r$r%rrrrÚtest_create_entries[s   z(SearchDialogBaseTest.test_create_entriescCshd|j_t|jƒ|j_|j ¡\}}| |d¡| tt|ƒƒd¡|j d¡\}}| |dd¡dS)NrÚzZ testlabelr&) rr-rr r0Z make_framer!ÚstrÚtype)rr0r4rrrÚtest_make_framebs z$SearchDialogBaseTest.test_make_framecCst|jƒ|j_d|j_|ƒS)Nr)rr rr0r-)rÚmethrrrÚbtn_test_setupnsz#SearchDialogBaseTest.btn_test_setupc CsŠ|j}dD]z}|j|j|j|jfD]}| |¡q"| |jj¡\}}t ||  ¡ƒD]0\}}|\}}|  |d|¡|  |  ¡|¡qRq dS)N)rr/r&) rZrevarZcasevarZwordvarZwrapvarÚsetr<rr)ÚzipÚ pack_slavesr!r%) rÚer#Úvarr0ÚoptionsÚspecÚbuttonr4rrrÚtest_create_option_buttonsss ÿz/SearchDialogBaseTest.test_create_option_buttonsc Cs~dD]t}|jj}| |¡| |jj¡\}}| ¡}t||ƒD]8\}}|\}} | |d| ¡||kr>| |  ¡|¡q>qdS)N)FTr&) rZbackvarr=r<rr*r?r>r!r%) rr#rAr0ZothersZbuttonsrCrDÚvalr4rrrÚtest_create_other_buttonss ÿz.SearchDialogBaseTest.test_create_other_buttonscCsDt|jƒ|j_t|jjƒ|j_|j d|jj¡}| |dd¡dS)NZTestr&)rr rr0Ú buttonframeZ make_buttonrr!)rZbtnrrrÚtest_make_buttonŽsz%SearchDialogBaseTest.test_make_buttoncCsRt|jƒ|j_|j ¡d}|jj ¡D]}|ddkr(|d}q(| d|¡dS)Nr7r&ÚCloseZcommandr)rr rr0r+rHZwinfo_childrenr1)rZclosebuttoncommandÚchildrrrÚtest_create_command_buttons”s   z0SearchDialogBaseTest.test_create_command_buttonsN)Ú__name__Ú __module__Ú __qualname__Ú classmethodrrrrr'r,r5r6r:r<rErGrIrLrrrrr s     r Ú__main__é)Ú verbosityÚexit)Ú__doc__ZunittestZ test.supportrÚtkinterrrrZ tkinter.ttkrZidlelibrrrrZidlelib.idle_test.mock_idler ZTestCaser rMÚmainrrrrÚs