
    z%i)                         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       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| _        |_        y )Ngui)	r   r   rootwithdrawr   OutputWindowwindowr   text)clsr   ws      Q/home/uftp/.pyenv/versions/3.12.0/lib/python3.12/idlelib/idle_test/test_outwin.py
setUpClasszOutputWindowTest.setUpClass   sO    $sx,,T4tDDCJ J&16    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   r,   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
)r,   r   r!   getr   writelenrstrip)r#   r9   r!   rH   rI   	test_text
test_text2s          r   
test_writezOutputWindowTest.test_write7   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
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^   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    *   )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^   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)   r/   r:   rN   rQ   r^    r   r   r   r      sL    ' '  '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_patsrg   r,   pattern)r#   patregexs      r   test_compile_progsz%ModuleFunctionTest.test_compile_progs   sH    f33V5K5KL 	1JCU]]C0	1r   zbuiltins.openc                     t         j                  }d}|D ]4  \  }}| j                   ||      |       |s!|j                  |d          6 y )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!D/SY8,,_Q-?@	Ar   N)	r_   r`   ra   rb   r$   ro   r	   patchr{   rc   r   r   re   re      s:    & &1
 TZZ 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      sc       !  / , y.x(( y.xA** A: zHMMA r   