
    6bh%                         d Z ddlmZ ddl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       yy)zTest outwin, coverage 76%.    )outwinN)requires)TkText)	Mbox_func)Func)mockc                   V    e Zd Zed        Zed        Zd Zd Zd Zd Z	d Z
d Zd	 Zy
)OutputWindowTestc                 :   t        d       t               x}| _        |j                          t	        j
                  d d d |      x}| _        t        |      x| _        |_        t        j                  dk(  r&| j                  j                  | j                  _        y y )Nguidarwin)r   r   rootwithdrawr   OutputWindowwindowr   textsysplatformupdate_idletasksupdate)clsr   ws      G/opt/python-3.12.12/usr/lib/python3.12/idlelib/idle_test/test_outwin.py
setUpClasszOutputWindowTest.setUpClass   su    $sx,,T4tDDCJ J&16<<8#!hh77CHHO $    c                 x    | j                   j                          | `| ` | j                  j	                          | `y N)r   closer   r   destroyr   s    r   tearDownClasszOutputWindowTest.tearDownClass   s0    

HcjHr   c                 <    | j                   j                  dd       y )N1.0end)r   deleteselfs    r   setUpzOutputWindowTest.setUp"   s    		&r   c                     | j                   }| j                  |j                  d             | j                  |j                  t                     y )Nztest.txt)r   assertFalseispythonsource__file__)r(   r   s     r   test_ispythonsourcez$OutputWindowTest.test_ispythonsource%   s=    KK))*56))(34r   c                 l    | j                  | j                  j                  j                         d       y )NOutput)assertEqualr   toptitler'   s    r   test_window_titlez"OutputWindowTest.test_window_title+   s#    ..0(;r   c                 j   | j                   }| j                  }t               |_        d|j                  _         ||j                         d        ||j                  j                  d       d|j                  _         ||j                         d        ||j                  j                  d       |`y )NFno   Tyes   )r   r1   r   	get_savedresult	maybesavecalled)r(   r   eqs      r   test_maybesavezOutputWindowTest.test_maybesave.   s    KKf"
1;;=$
1;;q!!
1;;=% 
1;;q!Kr   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      |j                  d              | |d
d      |j                  d             y )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
)r1   r   r&   getr   writelenrstrip)r(   r>   r&   rM   rN   	test_text
test_text2s          r   
test_writezOutputWindowTest.test_write<   s   !!iimm!! 	ue	
5S^,
3ug,
3!#34kB 	ue!	
5S^,
3ug,
3!#34b9 	ue'	
5S^,
3ug,
3ug)
3!#34h? 	ue!	

5)3y>:
5+.J@
3}l+Y7
3 "23Z@
3ug	 0 0 67
3ug
 1 1$ 78r   c                    | j                   }| j                  j                  }| j                  j                  } |d        | |dd      d        | |dd      d        | |dd	      d
        | |dd      d       y )N)zLine 1
rH   zLine 3
r$   rA   zLine 1rE   rF   rG   z3.0z3.endzLine 3rB   rC   rD   )r1   r   rM   r   
writelines)r(   r>   rM   rU   s       r   test_writelinesz OutputWindowTest.test_writelinesc   sx    iimm[[++
78
3ug)
3ug)
3ug)
3!#34b9r   c                    | j                   }| j                  }| j                  }t        j                         |_        t               x}|j
                  _        t               x}|_	        |j                  d       | j                  |j                                 ||j                  d        ||j                  d       |j                  t        t                d       |j                  t        t                d       | j                  |j                                 ||j"                  t        t               df       |j%                  dd       |j                  t        t                d       |j                  d       | j                  |j                                 ||j"                  t        t               d	f       |j
                  `|`	y )
NzNot a file liner   zNo special linez: 42: spam
z
: 21: spam   r$   r%   *   )r1   r   r   r	   Mockflistr   gotofileliner   	showerrorrN   assertIsNonegoto_file_liner=   r3   strr-   argsr&   )r(   r>   r   r   gflr]   s         r   test_goto_file_linez$OutputWindowTest.test_goto_file_linen   s^   KKyy))+%)V+agg""++-	AK 	
!"!**,-
3::q
9??-. 	
3x=/./	3x=/,-!**,-
388c(mR() 	E5!	3x=/./	!"!**,-
388c(mR()GG !+r   N)__name__
__module____qualname__classmethodr   r"   r)   r.   r4   r?   rS   rV   rc    r   r   r   r      sL    8 8  '5<%9N	:.r   r   c                   R    e Zd Zed        Zd Z ej                  d      d        Zy)ModuleFunctionTestc                     d t         _        y r   )r   file_line_progsr!   s    r   r)   zModuleFunctionTest.setUp   s
    !%r   c                     t        j                          t        t         j                  t         j                        D ]!  \  }}| j                  |j                  |       # y r   )r   compile_progszipfile_line_patsrl   r1   pattern)r(   patregexs      r   test_compile_progsz%ModuleFunctionTest.test_compile_progs   sD    f33V5K5KLJCU]]C0 Mr   zbuiltins.openc                     t         j                  }d}|D ]4  \  }}| j                   ||      |       |s!|j                  |d          6 y )N))z"foo file "testfile1", line 42, bar)	testfile1rY   )zfoo testfile2(21) bar)	testfile2rX   )z  testfile3  : 42: foo bar\n)z  testfile3  rY   )zfoo testfile4.py :1: )zfoo testfile4.py r7   )u   testfile5: ᧔᧒: )	testfile5rY   )ztestfile6: 42N)ztestfile7 42 textNr   )r   file_line_helperr1   assert_called_with)r(   	mock_openflh
test_lineslineexpected_outputs         r   test_file_line_helperz(ModuleFunctionTest.test_file_line_helper   sO    %%
 &0!D/SY8,,_Q-?@ &0r   N)	rd   re   rf   rg   r)   rt   r	   patchr   rh   r   r   rj   rj      s:    & &1
 TZZ A !Ar   rj   __main__r9   )	verbosity)__doc__idlelibr   r   unittesttest.supportr   tkinterr   r   idlelib.idle_test.mock_tkr   idlelib.idle_test.mock_idler   r	   TestCaser   rj   rd   mainrh   r   r   <module>r      sf      
  !  / , }.x(( }.@A** A: zHMMA r   