
    ch                     h   d Z ddlmZ ddlZddlmZmZ ddlmZm	Z	 ddl
mZ ddlmZ ddlmZ ddlZdd	lmZ ej        Z G d
 dej                  Z G d dej                  Z G d dej                  Z G d d          Z G d dej                  Zedk    r ej        d           dS dS )zTest 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                   \    e Zd ZdZed             Zed             Zd Zd Zd Z	d Z
d Zd	S )
LiveDialogTestzmSimulate user clicking buttons other than [Close].

    Test that invoked textview has text from source.
    c                     t          d           t                      | _        | j                                         t	          | j        dd          | _        d S Ngui
About IDLET_utestr   r   rootwithdrawAboutdialogclss    3lib/python3.11/idlelib/idle_test/test_help_about.py
setUpClasszLiveDialogTest.setUpClass   H    4438\$???


    c                 r    | ` | j                                         | j                                         | `d S Nr   r   update_idletasksdestroyr   s    r   tearDownClasszLiveDialogTest.tearDownClass   8    J!!###HHHr   c                 F    |                      t          j        d           d S )N)3264)assertInr   bitsselfs    r   test_build_bitszLiveDialogTest.test_build_bits&   s    jo|44444r   c                 `    |                      | j                                        d           dS )Test about dialog titler   N)assertEqualr   titler+   s    r   test_dialog_titlez LiveDialogTest.test_dialog_title)   s,    **,,l;;;;;r   c                     t           j                            | j        j        d                   \  }}t           j                            |          \  }}|                     |d           dS )zTest about dialog logo.fileidle_48N)ospathsplitr   
icon_imagesplitextr0   )r,   r7   r4   fnexts        r   test_dialog_logozLiveDialogTest.test_dialog_logo-   sX    W]]4;#9&#ABB
d'""4((CY'''''r   c           	         | j         }|j        t          df|j        t          df|j        t          dfg}|D ]\  }}}|                     |          5  |                                 |	                                 |j
        j        j        j        j        }|j        }t!          |          dk     r|                     |dz              |                     |d          |dd	                     |                     |d
          |dd                     |j
                                         ddd           n# 1 swxY w Y   dS )z1Test buttons whose commands use printer function.license	copyrightcreditsname   z full text was not foundr   1.01.end   z2.0z2.endN)r   
py_licenser?   py_copyrightr@   
py_creditsrA   subTest_Printer__setupinvoke_current_textview	viewframe	textframetextget_Printer__lineslenfailr0   r#   )r,   r   button_sourcesbuttonprinterrC   rR   liness           r   test_printer_buttonsz#LiveDialogTest.test_printer_buttons3   s   !,gyA!.	;G!,gyAC &4 
	3 
	3!FGT4(( 	3 	3''))).8BGK/u::>>IId%??@@@  q33ug+>+>???  q33ug+>+>???(00222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3
	3 
	3s   CD::D>	D>	c           
         | j         }| j         j        ddf| j         j        ddf| j         j        ddfg}|D ]S\  }}}|                     |          5  |                                 t          |d	          }|j        j        j	        j
        j        }t          |d
          5 }|                     |                                                                 |dd                     |                                 |                     |                                                                 |dd                     ddd           n# 1 swxY w Y   |j                                         ddd           n# 1 swxY w Y   UdS )z Test buttons that display files.z
README.txtreadmez	News3.txtnewszCREDITS.txtrA   rB   idlelib)subdirzutf-8)encodingrE   rF   z3.0z3.endN)r   r\   	idle_newsidle_creditsrK   rM   r   rN   rO   rP   rQ   rR   openr0   readlinestripr#   )	r,   r   rV   rW   filenamerC   r;   rR   fs	            r   test_file_buttonsz LiveDialogTest.test_file_buttonsF   s   ;-|XF;0+vF;3]INP '5 		3 		3"FHd,,D,)) 3 3hy999.8BGK"w/// P1$$QZZ\\%7%7%9%933ug;N;NOOOJJLLL$$QZZ\\%7%7%9%933ug;N;NOOOP P P P P P P P P P P P P P P (002223 3 3 3 3 3 3 3 3 3 3 3 3 3 3		3 		3s8   AE>%BEE>EE>EE>>F	F	N)__name__
__module____qualname____doc__classmethodr   r$   r-   r2   r=   rZ   rh    r   r   r   r      s          @ @ [@   [5 5 5< < <( ( (3 3 3&3 3 3 3 3r   r   c                   D    e Zd ZdZed             Zed             Zd ZdS )DefaultTitleTestzTest default title.c                     t          d           t                      | _        | j                                         t	          | j        d          | _        d S )Nr   Tr   r   r   s    r   r   zDefaultTitleTest.setUpClass\   sF    4438D111


r   c                 r    | ` | j                                         | j                                         | `d S r    r!   r   s    r   r$   zDefaultTitleTest.tearDownClassc   r%   r   c                     |                      | j                                        dt                       dt          j         d           dS )r/   zAbout IDLE z (z bit)N)r0   r   r1   r   r   r*   r+   s    r   r2   z"DefaultTitleTest.test_dialog_titlej   s_    **,,5~'7'7 5 5(o5 5 5	6 	6 	6 	6 	6r   N)ri   rj   rk   rl   rm   r   r$   r2   rn   r   r   rp   rp   Y   s]        2 2 [2   [6 6 6 6 6r   rp   c                   D    e Zd ZdZed             Zed             Zd ZdS )	CloseTestz%Simulate user clicking [Close] buttonc                     t          d           t                      | _        | j                                         t	          | j        dd          | _        d S r   r   r   s    r   r   zCloseTest.setUpClasst   r   r   c                 r    | ` | j                                         | j                                         | `d S r    r!   r   s    r   r$   zCloseTest.tearDownClass{   r%   r   c                 4   |                      | j                                        d           | j        j                                         |                     t                    5  | j                                         d d d            d S # 1 swxY w Y   d S )NToplevel)r0   r   winfo_class	button_okrM   assertRaisesr   r+   s    r   
test_closezCloseTest.test_close   s    0022J???$$&&&x(( 	& 	&K##%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s   &BBBN)ri   rj   rk   rl   rm   r   r$   r}   rn   r   r   ru   ru   q   s`        //@ @ [@   [& & & & &r   ru   c                   J    e Zd Zej        Zej        Zej        Z	ej
        Z
dZdS )Dummy_about_dialogTN)ri   rj   rk   r   show_idle_creditsrb   show_readmeidle_readmeshow_idle_newsra   display_file_textr   rn   r   r   r   r      s4        *L#K$I/FFFr   r   c                   X    e Zd ZdZ e            Zed             Zed             Zd Z	dS )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.
    c                     t           j        | _        t           j        | _        t                      | _        t                      | _        | j        t           _        | j        t           _        d S r    )	r
   	showerror
orig_error	view_text	orig_viewr	   errorr   viewr   s    r   r   zDisplayFileTest.setUpClass   sF    !+ *KK	66 Y Xr   c                 J    | j         t          _        | j        t          _        d S r    )r   r
   r   r   r   r   s    r   r$   zDisplayFileTest.tearDownClass   s     ^ ]r   c                 r   | j         j        | j         j        | j         j        fD ]}d| j        _        d| j        _        |                     |          5   |             | 	                    | j        j        d           | 	                    | j        j        d           d d d            n# 1 swxY w Y   d S )N F)handlerT)
r   rb   r   ra   r   messager   calledrK   r0   )r,   r   s     r   test_file_displayz!DisplayFileTest.test_file_display   s    0/-/ 	9 	9G "$DJ$DIg.. 9 9			  !3R888  !148889 9 9 9 9 9 9 9 9 9 9 9 9 9 9	9 	9s   AB++B/	2B/	N)
ri   rj   rk   rl   r   r   rm   r   r$   r   rn   r   r   r   r      sq         
  !!F& & [& + + [+	9 	9 	9 	9 	9r   r   __main__rD   )	verbosity)rl   r^   r   unittesttest.supportr   r   tkinterr   r   idlelib.idle_test.mock_idler   idlelib.idle_test.mock_tkr	   r
   os.pathr6   platformr   AboutDialogr   TestCaser   rp   ru   r   r   ri   mainrn   r   r   <module>r      s   
        + + + + + + + +                 , , , , , , / / / / / /        # # # # # #C3 C3 C3 C3 C3X& C3 C3 C3L6 6 6 6 6x( 6 6 60& & & & &! & & &0       9 9 9 9 9h' 9 9 9D zHMA r   