B  f!@sdZddlmZddlZddlmZmZddlmZm Z ddl m Z ddl m Z ddlmZddlZdd lmZejZGd d d ejZGd d d ejZGdddejZGdddZGdddejZedkrejdddS)zTest help_about, coverage 100%. help_about.build_bits branches on sys.platform='darwin'. '100% combines coverage on Mac and others. ) help_aboutN)requiresfindfile)TkTclError)Func) Mbox_func)textview)python_versionc@sPeZdZdZeddZeddZddZdd Zd d Z d d Z ddZ dS)LiveDialogTestzmSimulate user clicking buttons other than [Close]. Test that invoked textview has text from source. cCs0tdt|_|jt|jddd|_dS)Nguiz About IDLET)_utest)rrrootwithdrawAboutdialog)clsrF/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_help_about.py setUpClasss zLiveDialogTest.setUpClasscCs |`|j|j|`dS)N)rrupdate_idletasksdestroy)rrrr tearDownClasss  zLiveDialogTest.tearDownClasscCs|tddS)N)Z32Z64)ZassertInr build_bits)selfrrrtest_build_bits&szLiveDialogTest.test_build_bitscCs||jddS)zTest about dialog titlez About IDLEN) assertEqualrtitle)rrrrtest_dialog_title)sz LiveDialogTest.test_dialog_titlecCs8tj|jjd\}}tj|\}}||ddS)zTest about dialog logo.fileZidle_48N)ospathsplitrZ icon_imagesplitextr)rr!rfnZextrrrtest_dialog_logo-szLiveDialogTest.test_dialog_logoc Cs|j}|jtdf|jtdf|jtdfg}x|D]\}}}|j|dz|| |j j j j j}|j}t|dkr||d||d|dd ||d |d d |j Wd QRXq.Wd S)z1Test buttons whose commands use printer function.license copyrightcredits)namez full text was not foundrz1.0z1.endz2.0z2.endN)rZ py_licenser&Z py_copyrightr'Z py_creditsr(subTest_Printer__setupinvoke_current_textview viewframe textframetextget_Printer__lineslenZfailrr)rrbutton_sourcesbuttonZprinterr)r3linesrrrtest_printer_buttons3s   z#LiveDialogTest.test_printer_buttonsc Cs|j}|jjddf|jjddf|jjddfg}x|D]\}}}|j|d|t|dd }|jjj j j }t |d d B}| ||d d || ||ddWdQRX|jWdQRXq4WdS)z Test buttons that display files.z README.txtreadmezNEWS.txtZnewsz CREDITS.txtr()r)idlelib)Zsubdirzutf-8)encodingz1.0z1.endz3.0z3.endN)rr: idle_news idle_creditsr,r.rr/r0r1r2r3openrreadlinestripr) rrr6r7filenamer)r$r3frrrtest_file_buttonsFs   $z LiveDialogTest.test_file_buttonsN) __name__ __module__ __qualname____doc__ classmethodrrrrr%r9rDrrrrr s  r c@s0eZdZdZeddZeddZddZdS) DefaultTitleTestzTest default title.cCs.tdt|_|jt|jdd|_dS)Nr T)r )rrrrrr)rrrrr\s zDefaultTitleTest.setUpClasscCs |`|j|j|`dS)N)rrrr)rrrrrcs  zDefaultTitleTest.tearDownClasscCs*||jdtdtddS)zTest about dialog titlez About IDLE z (z bit)N)rrrr rr)rrrrrjs z"DefaultTitleTest.test_dialog_titleN)rErFrGrHrIrrrrrrrrJYs  rJc@s0eZdZdZeddZeddZddZdS) CloseTestz%Simulate user clicking [Close] buttoncCs0tdt|_|jt|jddd|_dS)Nr z About IDLET)r )rrrrrr)rrrrrts zCloseTest.setUpClasscCs |`|j|j|`dS)N)rrrr)rrrrr{s  zCloseTest.tearDownClassc CsB||jd|jj|t|jWdQRXdS)NZToplevel)rrZ winfo_classZ button_okr.Z assertRaisesr)rrrr test_closes  zCloseTest.test_closeN)rErFrGrHrIrrrLrrrrrKqs  rKc@s(eZdZejZejZejZ ej Z dZ dS)Dummy_about_dialogTN) rErFrGrZshow_idle_creditsr>Z show_readme idle_readmeZshow_idle_newsr=Zdisplay_file_textr rrrrrMs rMc@s6eZdZdZeZeddZeddZddZ dS) DisplayFileTestzTest functions that display files. While somewhat redundant with gui-based test_file_dialog, these unit tests run on all buildbots, not just a few. cCs4tj|_tj|_t|_t|_|jt_|jt_dS)N) r showerror orig_error view_text orig_viewrerrorrview)rrrrrs zDisplayFileTest.setUpClasscCs|jt_|jt_dS)N)rQr rPrSrR)rrrrrszDisplayFileTest.tearDownClassc Csrxl|jj|jj|jjfD]R}d|j_d|j_|j|d,|| |jjd| |jjdWdQRXqWdS)NF)handlerT) rr>rNr=rTmessagerUZcalledr,r)rrWrrrtest_file_displaysz!DisplayFileTest.test_file_displayN) rErFrGrHrMrrIrrrYrrrrrOs  rO__main__r*) verbosity)rHr;rZunittestZ test.supportrrZtkinterrrZidlelib.idle_test.mock_idlerZidlelib.idle_test.mock_tkrr Zos.pathr platformr Z AboutDialogrZTestCaser rJrKrMrOrEmainrrrrs"     F "