a  ze@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|_dSNgui About IDLET_utestrrrootZwithdrawAboutdialogclsrU/opt/bitninja-python-dojo/embedded/lib/python3.9/idlelib/idle_test/test_help_about.py setUpClasss zLiveDialogTest.setUpClasscCs |`|j|j|`dSNrrZupdate_idletasksdestroyrrrr tearDownClasss  zLiveDialogTest.tearDownClasscCs|tddS)N)Z32Z64)ZassertInr build_bitsselfrrrtest_build_bits&szLiveDialogTest.test_build_bitscCs||jddS)Test about dialog titlerN) assertEqualrtitlerrrrtest_dialog_title)sz LiveDialogTest.test_dialog_titlecCs8tj|jjd\}}tj|\}}||ddS)zTest about dialog logo.fileZidle_48N)ospathsplitrZ icon_imagesplitextr#)r r(r&fnextrrrtest_dialog_logo-szLiveDialogTest.test_dialog_logoc Cs|j}|jtdf|jtdf|jtdfg}|D]\}}}|j|d|| |j j j j j}|j}t|dkr||d||d|dd ||d |d d |j Wd q,1s0Yq,d S)z1Test buttons whose commands use printer function.license copyrightcreditsnamez full text was not foundr1.01.endz2.0z2.endN)rZ py_licenser.Z py_copyrightr/Z py_creditsr0subTest_Printer__setupinvoke_current_textview viewframe textframetextget_Printer__lineslenZfailr#r)r rbutton_sourcesbuttonZprinterr2r>linesrrrtest_printer_buttons3s     z#LiveDialogTest.test_printer_buttonsc Cs|j}|jjddf|jjddf|jjddfg}|D]\}}}|j|d|t|dd }|jjj j j }t |d d L}| ||d d || ||ddWdn1s0Y|jWdq21s0Yq2dS)z Test buttons that display files.z README.txtreadmezNEWS.txtnewsz CREDITS.txtr0r1idlelib)Zsubdirzutf-8)encodingr4r5z3.0z3.endN)rrE idle_news idle_creditsr7r9rr:r;r<r=r>openr#readlinestripr) r rrArBfilenamer2r+r>frrrtest_file_buttonsFs    8z LiveDialogTest.test_file_buttonsN) __name__ __module__ __qualname____doc__ classmethodrrr!r%r-rDrPrrrrr s  r c@s0eZdZdZeddZeddZddZdS) DefaultTitleTestzTest default title.cCs.tdt|_|jt|jdd|_dS)Nr Trrrrrrr\s zDefaultTitleTest.setUpClasscCs |`|j|j|`dSrrrrrrrcs  zDefaultTitleTest.tearDownClasscCs*||jdtdtddS)r"z About IDLE z (z bit)N)r#rr$r rrrrrrr%js   z"DefaultTitleTest.test_dialog_titleN)rQrRrSrTrUrrr%rrrrrVYs   rVc@s0eZdZdZeddZeddZddZdS) CloseTestz%Simulate user clicking [Close] buttoncCs0tdt|_|jt|jddd|_dSr rrrrrrts zCloseTest.setUpClasscCs |`|j|j|`dSrrrrrrr{s  zCloseTest.tearDownClasscCsV||jd|jj|t|jWdn1sH0YdS)NZToplevel)r#rZ winfo_classZ button_okr9Z assertRaisesrrrrr test_closes  zCloseTest.test_closeN)rQrRrSrTrUrrrXrrrrrWqs   rWc@s(eZdZejZejZejZ ej Z dZ dS)Dummy_about_dialogTN) rQrRrSrZshow_idle_creditsrJZ show_readme idle_readmeZshow_idle_newsrIZdisplay_file_textrrrrrrYs rYc@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_dSr) r showerror orig_error view_text orig_viewrerrorrviewrrrrrs zDisplayFileTest.setUpClasscCs|jt_|jt_dSr)r]r r\r_r^rrrrrszDisplayFileTest.tearDownClassc Cs|jj|jj|jjfD]f}d|j_d|j_|j|d6|| |jjd| |jjdWdq1sr0YqdS)NF)handlerT) rrJrZrIr`messageraZcalledr7r#)r rcrrrtest_file_displaysz!DisplayFileTest.test_file_displayN) rQrRrSrTrYrrUrrrerrrrr[s  r[__main__r3) verbosity)rTrGrZunittestZ test.supportrrtkinterrrZidlelib.idle_test.mock_idlerZidlelib.idle_test.mock_tkrr Zos.pathr'platformr Z AboutDialogrZTestCaser rVrWrYr[rQmainrrrrs"     F "