
    ;e)                         d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZ  G d	 d
ej                  Z G d dej                  Zedk    r ej        d           dS dS )zTest outwin, coverage 76%.    )outwinN)requires)TkText)	Mbox_func)Func)mockc                   d    e Zd Zed             Zed             Zd Zd Zd Zd Z	d Z
d Zd	 Zd
S )OutputWindowTestc                     t          d           t                      x}| _        |                                 t	          j        d d d |          x}| _        t          |          x| _        |_        d S )Ngui)	r   r   rootwithdrawr   OutputWindowwindowr   text)clsr   ws      4/usr/lib/python3.11/idlelib/idle_test/test_outwin.py
setUpClasszOutputWindowTest.setUpClass   s_    $$sx,T4tDDDCJ JJ&1666    c                 v    | j                                          | `| ` | j                                         | `d S N)r   closer   r   destroyr   s    r   tearDownClasszOutputWindowTest.tearDownClass   s<    
HcjHHHr   c                 <    | j                             dd           d S )N1.0end)r   deleteselfs    r   setUpzOutputWindowTest.setUp   s     	&&&&&r   c                     | j         }|                     |                    d                     |                     |                    t                               d S )Nztest.txt)r   assertFalseispythonsource__file__)r#   r   s     r   test_ispythonsourcez$OutputWindowTest.test_ispythonsource    sS    K))*55666))(3344444r   c                 j    |                      | j        j                                        d           d S )NOutput)assertEqualr   toptitler"   s    r   test_window_titlez"OutputWindowTest.test_window_title&   s.    ..00(;;;;;r   c                 L   | j         }| j        }t                      |_        d|j        _         ||                                d            ||j        j        d           d|j        _         ||                                d            ||j        j        d           |`d S )NFno   Tyes   )r   r,   r   	get_savedresult	maybesavecalled)r#   r   eqs      r   test_maybesavezOutputWindowTest.test_maybesave)   s    Kff"
1;;==$
1;q!!!!
1;;==%   
1;q!!!KKKr   c                 \   | j         }| j        j        }| j        j        }| j        j        } |dd           d} | ||          t          |                      | |dd          d            | |dd          d            |dd           d} | ||          t          |                      | |dd          d            | |dd          d            |dd           d	} | ||          t          |                      | |dd          d            | |d
d          d            | |dd          d            |dd           d}d} | ||d          t          |                      | ||d          t          |                      | |dd          |            | |dd          |            | |dd          |                    d                      | |d
d          |                    d                     d S )Nr   r    z	test text1.endinsert linestartinsert lineendz
test text
 ztest text
Line 22.02.endLine 2Line 2
mytag)tags	secondtagzmytag.firstz
mytag.lastzsecondtag.firstzsecondtag.last
)r,   r   r!   getr   writelenrstrip)r#   r9   r!   rH   rI   	test_text
test_text2s          r   
test_writezOutputWindowTest.test_write7   s   !im! 	ue	
55S^^,,,
33ug,,,
33!#344kBBB 	ue!	
55S^^,,,
33ug,,,
33!#344b999 	ue'	
55S^^,,,
33ug,,,
33ug)))
33!#344h??? 	ue!	

55)))3y>>:::
55+...J@@@
33}l++Y777
33 "233Z@@@
33ug	 0 0 6 6777
33ug
 1 1$ 7 788888r   c                 
   | j         }| j        j        }| j        j        } |d            | |dd          d            | |dd          d            | |dd	          d
            | |dd          d           d S )N)zLine 1
rC   zLine 3
r   r<   zLine 1r@   rA   rB   z3.0z3.endzLine 3r=   r>   r?   )r,   r   rH   r   
writelines)r#   r9   rH   rP   s       r   test_writelinesz OutputWindowTest.test_writelines^   s    im[+

7888
33ug)))
33ug)))
33ug)))
33!#344b99999r   c                    | j         }| j        }| j        }t          j                    |_        t                      x}|j        _        t                      x}|_	        |
                    d           |                     |                                            ||j        d            ||j        d           |
                    t          t                      d           |
                    t          t                      d           |                     |                                            ||j        t          t                     df           |                    dd           |
                    t          t                      d           |
                    d           |                     |                                            ||j        t          t                     d	f           |j        `|`	d S )
NzNot a file liner   zNo special linez: 42: spam
z
: 21: spam   r   r    *   )r,   r   r   r	   Mockflistr   gotofileliner   	showerrorrI   assertIsNonegoto_file_liner8   r.   strr(   argsr!   )r#   r9   r   r   gflrX   s         r   test_goto_file_linez$OutputWindowTest.test_goto_file_linei   s   Ky)++%)VV+ag""+++-	AK 	
!"""!**,,---
3:q
9?-... 	
3x==...///	3x==,,,---!**,,---
38c(mmR())) 	E5!!!	3x==...///	!"""!**,,---
38c(mmR()))G !+++r   N)__name__
__module____qualname__classmethodr   r   r$   r)   r/   r:   rN   rQ   r^    r   r   r   r      s        ' ' ['   [' ' '5 5 5< < <  %9 %9 %9N	: 	: 	:. . . . .r   r   c                   \    e Zd Zed             Zd Z ej        d          d             ZdS )ModuleFunctionTestc                     d t           _        d S r   )r   file_line_progsr   s    r   r$   zModuleFunctionTest.setUp   s    !%r   c                     t          j                     t          t           j        t           j                  D ] \  }}|                     |j        |           !d S r   )r   compile_progszipfile_line_patsrg   r,   pattern)r#   patregexs      r   test_compile_progsz%ModuleFunctionTest.test_compile_progs   sY    f3V5KLL 	1 	1JCU]C0000	1 	1r   zbuiltins.openc                     t           j        }d}|D ]A\  }}|                      ||          |           |r|                    |d                    Bd S )N))z"foo file "testfile1", line 42, bar)	testfile1rT   )zfoo testfile2(21) bar)	testfile2rS   )z  testfile3  : 42: foo bar\n)z  testfile3  rT   )zfoo testfile4.py :1: )zfoo testfile4.py r2   )u   testfile5: ᧔᧒: )	testfile5rT   )ztestfile6: 42N)ztestfile7 42 textNr   )r   file_line_helperr,   assert_called_with)r#   	mock_openflh
test_lineslineexpected_outputs         r   test_file_line_helperz(ModuleFunctionTest.test_file_line_helper   sv    %
 &0 	A 	A!D/SSYY888 A,,_Q-?@@@	A 	Ar   N)	r_   r`   ra   rb   r$   ro   r	   patchr{   rc   r   r   re   re      si        & & [&1 1 1
 TZ  A A ! A A Ar   re   __main__r4   )	verbosity)__doc__idlelibr   unittesttest.supportr   tkinterr   r   idlelib.idle_test.mock_tkr   idlelib.idle_test.mock_idler   r	   TestCaser   re   r_   mainrc   r   r   <module>r      s!            ! ! ! ! ! !         / / / / / / , , , , , ,      y. y. y. y. y.x( y. y. y.xA A A A A* A A A: zHMA r   