B � f!�@s�dZddlmZddlZddlmZmZddlmZm Z ddl m Z ddl m Z ddlmZddlZdd lmZejZGd d �d ej�ZGd d �d ej�ZGdd�dej�ZGdd�d�ZGdd�dej�Zedkr�ejdd�dS)z�Test help_about, coverage 100%. help_about.build_bits branches on sys.platform='darwin'. '100% combines coverage on Mac and others. �)� help_aboutN)�requires�findfile)�Tk�TclError)�Func)� Mbox_func)�textview)�python_versionc@sPeZdZdZedd��Zedd��Zdd�Zdd �Zd d �Z d d �Z dd�Z dS)�LiveDialogTestzmSimulate user clicking buttons other than [Close]. Test that invoked textview has text from source. cCs0td�t�|_|j��t|jddd�|_dS)N�guiz About IDLET)�_utest)rr�root�withdraw�About�dialog)�cls�r�F/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_help_about.py� setUpClasss zLiveDialogTest.setUpClasscCs |`|j��|j��|`dS)N)rr�update_idletasks�destroy)rrrr� tearDownClasss  zLiveDialogTest.tearDownClasscCs|�t��d�dS)N)Z32Z64)ZassertInr� build_bits)�selfrrr�test_build_bits&szLiveDialogTest.test_build_bitscCs|�|j��d�dS)zTest about dialog titlez About IDLEN)� assertEqualr�title)rrrr�test_dialog_title)sz LiveDialogTest.test_dialog_titlecCs8tj�|jjd�\}}tj�|�\}}|�|d�dS)zTest about dialog logo.�fileZidle_48N)�os�path�splitrZ icon_image�splitextr)rr!r�fnZextrrr�test_dialog_logo-szLiveDialogTest.test_dialog_logoc Cs�|j}|jtdf|jtdf|jtdfg}x�|D]�\}}}|j|d��z|��|� �|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� copyright�credits)�name�z full text was not foundrz1.0z1.end�z2.0z2.endN)rZ py_licenser&Z py_copyrightr'Z py_creditsr(�subTest�_Printer__setup�invoke�_current_textview� viewframe� textframe�text�get�_Printer__lines�lenZfailrr)rr�button_sources�buttonZprinterr)r3�linesrrr�test_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 ��|��|� |����|dd��WdQRX|j��WdQRXq4WdS)z Test buttons that display files.z README.txt�readmezNEWS.txtZnewsz CREDITS.txtr()r)�idlelib)Zsubdirzutf-8)�encodingz1.0z1.endz3.0z3.endN)rr:� idle_news� idle_creditsr,r.rr/r0r1r2r3�openr�readline�stripr) rrr6r7�filenamer)r$r3�frrr�test_file_buttonsFs   $z LiveDialogTest.test_file_buttonsN) �__name__� __module__� __qualname__�__doc__� classmethodrrrrr%r9rDrrrrr s  r c@s0eZdZdZedd��Zedd��Zdd�ZdS) �DefaultTitleTestzTest default title.cCs.td�t�|_|j��t|jdd�|_dS)Nr T)r )rrrrrr)rrrrr\s zDefaultTitleTest.setUpClasscCs |`|j��|j��|`dS)N)rrrr)rrrrrcs  zDefaultTitleTest.tearDownClasscCs*|�|j��dt��dt���d��dS)zTest about dialog titlez About IDLE z (z bit)N)rrrr rr)rrrrrjs z"DefaultTitleTest.test_dialog_titleN)rErFrGrHrIrrrrrrrrJYs  rJc@s0eZdZdZedd��Zedd��Zdd�ZdS) � CloseTestz%Simulate user clicking [Close] buttoncCs0td�t�|_|j��t|jddd�|_dS)Nr z About IDLET)r )rrrrrr)rrrrrts zCloseTest.setUpClasscCs |`|j��|j��|`dS)N)rrrr)rrrrr{s  zCloseTest.tearDownClassc CsB|�|j��d�|jj��|�t��|j��WdQRXdS)NZToplevel)rrZ winfo_classZ button_okr.Z assertRaisesr)rrrr� test_close�s  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 rrrrrM�s rMc@s6eZdZdZe�Zedd��Zedd��Zdd�Z dS) �DisplayFileTestz�Test 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_viewr�errorr�view)rrrrr�s zDisplayFileTest.setUpClasscCs|jt_|jt_dS)N)rQr rPrSrR)rrrrr�szDisplayFileTest.tearDownClassc Csrxl|jj|jj|jjfD]R}d|j_d|j_|j|d��,|�|� |jjd�|� |jjd�WdQRXqWdS)N�F)�handlerT) rr>rNr=rT�messagerUZcalledr,r)rrWrrr�test_file_display�sz!DisplayFileTest.test_file_displayN) rErFrGrHrMrrIrrrYrrrrrO�s  rO�__main__r*)� verbosity)rHr;rZunittestZ test.supportrrZtkinterrrZidlelib.idle_test.mock_idlerZidlelib.idle_test.mock_tkrr Zos.pathr �platformr Z AboutDialogrZTestCaser rJrKrMrOrE�mainrrrr�s"     F "