3  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|_|jjt|jddd|_dS)Nguiz About IDLET)_utest)rrrootwithdrawAboutdialog)clsrF/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_help_about.py setUpClasss zLiveDialogTest.setUpClasscCs |`|jj|jj|`dS)N)rrupdate_idletasksdestroy)rrrr tearDownClasss  zLiveDialogTest.tearDownClasscCs|jtjddS)N3264)rr)ZassertInr build_bits)selfrrrtest_build_bits&szLiveDialogTest.test_build_bitscCs|j|jjddS)zTest about dialog titlez About IDLEN) assertEqualrtitle)rrrrtest_dialog_title)sz LiveDialogTest.test_dialog_titlecCs8tjj|jjd\}}tjj|\}}|j|ddS)zTest about dialog logo.fileZidle_48N)ospathsplitrZ icon_imagesplitextr)rr#r!fnZextrrrtest_dialog_logo-szLiveDialogTest.test_dialog_logoc Cs|j}|jtdf|jtdf|jtdfg}x|D]|\}}}|j|d`|j|j |j j j j j}|j}|j|d|dd|j|d|d d |j jWd QRXq.Wd S) z1Test buttons whose commands use printer function.license copyrightcredits)namerz1.0z1.endz2.0z2.endN)rZ py_licenser(Z py_copyrightr)Z py_creditsr*subTest_Printer__setupinvoke_current_textview viewframe textframetextget_Printer__linesrr)rrbutton_sourcesbuttonZprinterr+r4linesrrrtest_printer_buttons3s  z#LiveDialogTest.test_printer_buttonsc Cs|j}|jjddf|jjddf|jjddfg}x|D]\}}}|j|d|jt|dd }|jjj j j }t |d d B}|j |jj|d d |j|j |jj|ddWdQRX|jjWdQRXq4WdS)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/rr0r1r2r3r4openrreadlinestripr) rrr6r7filenamer+r&r4frrrtest_file_buttonsDs   $z LiveDialogTest.test_file_buttonsN) __name__ __module__ __qualname____doc__ classmethodrrrr r'r9rDrrrrr s  r c@s0eZdZdZeddZeddZddZdS) DefaultTitleTestzTest default title.cCs.tdt|_|jjt|jdd|_dS)Nr T)r )rrrrrr)rrrrrZs zDefaultTitleTest.setUpClasscCs |`|jj|jj|`dS)N)rrrr)rrrrras  zDefaultTitleTest.tearDownClasscCs*|j|jjdtdtjddS)zTest about dialog titlez About IDLE z (z bit)N)rrrr rr)rrrrr hs z"DefaultTitleTest.test_dialog_titleN)rErFrGrHrIrrr rrrrrJWs  rJc@s0eZdZdZeddZeddZddZdS) CloseTestz%Simulate user clicking [Close] buttoncCs0tdt|_|jjt|jddd|_dS)Nr z About IDLET)r )rrrrrr)rrrrrrs zCloseTest.setUpClasscCs |`|jj|jj|`dS)N)rrrr)rrrrrys  zCloseTest.tearDownClassc CsB|j|jjd|jjj|jt|jjWdQRXdS)NZToplevel)rrZ winfo_classZ button_okr/Z assertRaisesr)rrrr test_closes  zCloseTest.test_closeN)rErFrGrHrIrrrLrrrrrKos  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,||j |jjd|j |jjdWdQRXqWdS)NF)handlerT) rr>rNr=rTmessagerUZcalledr-r)rrWrrrtest_file_displaysz!DisplayFileTest.test_file_displayN) rErFrGrHrMrrIrrrYrrrrrOs  rO__main__) verbosity)rHr;rZunittestZ test.supportrrZtkinterrrZidlelib.idle_test.mock_idlerZidlelib.idle_test.mock_tkrr Zos.pathr"platformr Z AboutDialogrZTestCaser rJrKrMrOrEmainrrrrs"     D "