
    z%i                     d   	 d dl mZ d dlZd dlmZ d dlmZ d dlmZm	Z	 ej                  Z G d dej                        Z G d d	ej                        Zd
 Z G d dej                        Z G d dej                        Z G d dej                        Zedk(  r ej(                  d       yy)    )editorN)
namedtuple)requires)TkTextc                   2    e Zd Zed        Zed        Zd Zy)EditorWindowTestc                 l    t        d       t               | _        | j                  j                          y Ngui)r   r   rootwithdrawclss    Q/home/uftp/.pyenv/versions/3.12.0/lib/python3.12/idlelib/idle_test/test_editor.py
setUpClasszEditorWindowTest.setUpClass   s"    4    c                     | j                   j                          | j                   j                  j                  dd      D ]  }| j                   j	                  |        | j                   j                          | ` y Nafterinfo)r   update_idletaskstkcallafter_canceldestroyr   ids     r   tearDownClasszEditorWindowTest.tearDownClass   s]    !!#((++""7F3 	&BHH!!"%	&Hr   c                     t        | j                        }| j                  |j                  | j                         |j                          y )Nr   )Editorr   assertEqual_close)selfes     r   	test_initzEditorWindowTest.test_init   s1    		"+	
r   N)__name__
__module____qualname__classmethodr   r   r'    r   r   r	   r	      s-     
  r   r	   c                       e Zd Zd Zd Zd Zy)GetLineIndentTestc           	          dD ]L  }dD ]E  }| j                  ||      5  | j                  t        j                  ||      d       d d d        G N y # 1 sw Y   TxY w)N)               ) 
)linetabwidthr8   r   r   subTestr#   r   get_line_indent)r%   r8   r7   s      r   test_empty_linesz"GetLineIndentTest.test_empty_lines#   sk    ' 	H" \\th\? $$..thG 	 s   (AAc                     d}|D ]G  \  }}| j                  |      5  | j                  t        j                  |d      |       d d d        I y # 1 sw Y   TxY w)N)z	no spacesr:   )z    space test)r2   r2   )		tab test)r0   r2   )		double tabs test)r1   r4   )z    	mixed test   r4   )z  	  mixed test)rD   r3   )z	    mixed testrC   )  	mixed test)   r2   ) 	 mixed test)rF   rD   )	  mixed test)rF   r3   z
newline testr:   r7   r2   r9   r;   r%   testsr7   expecteds       r   test_tabwidth_4z!GetLineIndentTest.test_tabwidth_4,   g    -  $ 	ND(4(   **4!< 	    (AA	c                     d}|D ]G  \  }}| j                  |      5  | j                  t        j                  |d      |       d d d        I y # 1 sw Y   TxY w)N)r@   )z        space test)r4   r4   )rA   )r0   r4   )rB   )r1      )z        	mixed test	   rR   )z      	  mixed test)rT   
   )z	        mixed testrS   )rE   )rF   r4   )rG   )rF   rT   )rH   )rF   rU   rI   rJ   r4   r9   r;   rK   s       r   test_tabwidth_8z!GetLineIndentTest.test_tabwidth_8E   rO   rP   N)r(   r)   r*   r>   rN   rV   r,   r   r   r.   r.   "   s    2r   r.   c                 l    | j                  dd       | j                  d|       | j                          y )N1.0end)deleteinsertupdate)textstrings     r   r[   r[   _   s'    KKuKKvKKMr   c                   2    e Zd Zed        Zed        Zd Zy)IndentAndNewlineTestc                     t        d       t               | _        | j                  j                          t	        | j                        | _        d| j
                  _        d| j
                  _        y )Nr   r!   r1   )r   r   r   r   r"   windowindentwidthr8   r   s    r   r   zIndentAndNewlineTest.setUpClassg   sJ    4*
!"



r   c                 4   | j                   j                          | ` | j                  j                          | j                  j                  j                  dd      D ]  }| j                  j                  |        | j                  j                          | `y r   rb   r$   r   r   r   r   r   r   r   s     r   r   z"IndentAndNewlineTest.tearDownClassp   r    

J!!#((++""7F3 	&BHH!!"%	&Hr   c                    | j                   }| j                  }|j                  }|j                  }|j                  }t        dg d      } |dddd       |ddd	d
       |ddd	d       |dddd       |dddd       |dddd       |dddd       |dddd       |dddd      f	}|D ]|  }| j                  |j                         5  t        ||j                         |j                  d!|j                          |d "        | |d#d$      |j                         d d d        ~ t        |d%       |j                  d&d'd        |d         | |d#d$      d(       y # 1 sw Y   xY w))NTests)labelr]   rM   markz"Empty line inserts with no indent.z  
  def __init__(self):z
  
  def __init__(self):
z1.endz+Inside bracket before space, deletes space.z  def f1(self, a, b):z  def f1(self,
         a, b):
z1.14z*Inside bracket after space, deletes space.z1.15z(Inside string with one line - no indent.z  """Docstring."""z  """Docstring.
"""
z&Inside string with more than one line.z%  """Docstring.
  Docstring Line 2"""z)  """Docstring.
  Docstring Line 2
  """
z2.18zBackslash with one line.za =\za =\
  
z"Backslash with more than one line.za =\
          multiline\z%a =\
          multiline\
          
z2.endz Block opener - indents +1 level.z  def f1(self):
    passz  def f1(self):
    
    pass
z Block closer - dedents -1 level.z  def f1(self):
    pass
  
)ri   r[   )eventrX   rY   z&  def f1(self, a, b):
    return a + bselz1.17z-  def f1(self, a,
         
    return a + b
)r#   rb   r]   getnewline_and_indent_eventr   r<   ri   r[   mark_setrj   rM   tag_add)	r%   eqwr]   rm   nlTestInforL   tests	            r   test_indent_and_newline_eventz2IndentAndNewlineTest.test_indent_and_newline_eventz   s   KKvvhh''g'LM>59!# G1= " F1= " D.2 " BBH " 4!'!# >8F!# <5=!# <5;!#A$L  	5DDJJ/ 5tTYY'h		23ue$dmm4	5 5	5 	t>?UFG,
4
3uePQ5 5s   AE  E)	N)r(   r)   r*   r+   r   r   rv   r,   r   r   r`   r`   e   s.         ;Rr   r`   c                   2    e Zd Zed        Zed        Zd Zy)IndentSearcherTestc                     t        d       t               | _        | j                  j                          t	        | j                        | _        y r   )r   r   r   r   r   r]   r   s    r   r   zIndentSearcherTest.setUpClass   s1    4>r   c                 <    | j                   j                          | ` y N)r   r   r   s    r   r   z IndentSearcherTest.tearDownClass   s    Hr   c                    | j                   }| j                   }d}|D ]a  \  }}| j                  |      5  t        ||       t        j                  |      j                         }| j                  ||       d d d        c y # 1 sw Y   nxY w)N))r5   NN)z[1,r}   )if 1:
)r~   N)zif 1:
  2
  3
)r~   z  2
)code)r]   r<   r[   r   IndentSearcherrunr#   )r%   r]   searcher	test_infor   expected_pairactual_pairs          r   test_searcherz IndentSearcherTest.test_searcher   s    yyII	 $- 	=D-4( =tT"$33D9==?  m<= =	== =s   ABB	N)r(   r)   r*   r+   r   r   r   r,   r   r   rx   rx      s-    " "  =r   rx   c                   F    e Zd Zed        Zed        Z G d d      Zd Zy)	RMenuTestc                     t        d       t               | _        | j                  j                          t	        | j                        | _        y )Nr   r!   )r   r   r   r   r"   rb   r   s    r   r   zRMenuTest.setUpClass   s2    4*
r   c                 4   | j                   j                          | ` | j                  j                          | j                  j                  j                  dd      D ]  }| j                  j                  |        | j                  j                          | `y r   re   r   s     r   r   zRMenuTest.tearDownClass   rf   r   c                       e Zd Zd Zy)RMenuTest.DummyRMenuc                      y r{   r,   )xys     r   tk_popupzRMenuTest.DummyRMenu.tk_popup   s    r   N)r(   r)   r*   r   r,   r   r   
DummyRMenur      s     r   r   c                      y r{   r,   )r%   s    r   test_rclickzRMenuTest.test_rclick   s    r   N)r(   r)   r*   r+   r   r   r   r   r,   r   r   r   r      s7    + +  ! !r   r   __main__r1   )	verbosity)idlelibr   unittestcollectionsr   test.supportr   tkinterr   r   EditorWindowr"   TestCaser	   r.   r[   r`   rx   r   r(   mainr,   r   r   <module>r      s       " ! 			x(( ,:)) :zPR8,, PRf=** =<!! 4 zHMMA r   