a
    	3jc                     @   s   d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 ejZG dd dejZG d	d
 d
ejZdd ZG dd dejZG dd dejZedkrejdd dS )    )editorN)
namedtuple)requires)Tk)Funcc                   @   s,   e Zd Zedd Zedd Zdd ZdS )EditorWindowTestc                 C   s   t d t | _| j  d S )Ngui)r   r   rootwithdrawcls r   Y/www/server/python_manager/versions/3.9.10/lib/python3.9/idlelib/idle_test/test_editor.py
setUpClass   s    zEditorWindowTest.setUpClassc                 C   s>   | j   | j jddD ]}| j | q| j   | ` d S NZafterinfo)r	   update_idletaskstkcallafter_canceldestroyr   idr   r   r   tearDownClass   s
    

zEditorWindowTest.tearDownClassc                 C   s(   t | jd}| |j| j |  d S )Nr	   )Editorr	   assertEqual_close)selfer   r   r   	test_init   s    zEditorWindowTest.test_initN)__name__
__module____qualname__classmethodr   r   r    r   r   r   r   r      s
   

r   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )TestGetLineIndentc              
   C   s\   dD ]R}dD ]H}| j ||d& | tj||dd W d    q1 sJ0    Y  qqd S )N)               ) 
)linetabwidthr.   r   r   subTestr   r   Zget_line_indent)r   r.   r-   r   r   r   test_empty_lines$   s    z"TestGetLineIndent.test_empty_linesc              	   C   sX   d}|D ]J\}}| j |d& | tj|dd| W d    q1 sH0    Y  qd S )N)z	no spacesr0   )z    space test)r(   r(   )		tab test)r&   r(   )		double tabs test)r'   r*   )z    	mixed test   r*   )z  	  mixed test)r8   r)   )z	    mixed testr7   )  	mixed test)   r(   ) 	 mixed test)r:   r8   )	  mixed test)r:   r)   z
newline testr0   r-   r(   r/   r1   r   testsr-   expectedr   r   r   test_tabwidth_4-   s    z!TestGetLineIndent.test_tabwidth_4c              	   C   sX   d}|D ]J\}}| j |d& | tj|dd| W d    q1 sH0    Y  qd S )N)r4   )z        space test)r*   r*   )r5   )r&   r*   )r6   )r'      )z        	mixed test	   rC   )z      	  mixed test)rE   
   )z	        mixed testrD   )r9   )r:   r*   )r;   )r:   rE   )r<   )r:   rF   r=   r>   r*   r/   r1   r?   r   r   r   test_tabwidth_8F   s    z!TestGetLineIndent.test_tabwidth_8N)r!   r"   r#   r3   rB   rG   r   r   r   r   r%   #   s   	r%   c                 C   s$   |  dd | d| |   d S )N1.0end)deleteinsertupdate)textstringr   r   r   rK   `   s    rK   c                   @   s,   e Zd Zedd Zedd Zdd ZdS )IndentAndNewlineTestc                 C   s<   t d t | _| j  t| jd| _d| j_d| j_d S )Nr   r   r'   )r   r   r	   r
   r   windowZindentwidthr.   r   r   r   r   r   h   s    
zIndentAndNewlineTest.setUpClassc                 C   sL   | j   | ` | j  | jjddD ]}| j| q(| j  | `d S r   rP   r   r	   r   r   r   r   r   r   r   r   r   r   q   s    


z"IndentAndNewlineTest.tearDownClassc           	      C   sz  | 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 |_|D ]j}| j|jd!F t	||j |
d"|j |d d# ||d$d%|j W d    q1 s0    Y  qt	|d& |d'd(d |d  ||d$d%d) d*|_t	|d+ |
d"d, |d  ||d$d%d- d S ).NZTests)labelrM   rA   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
  
r+   )rR   rK   )eventrH   rI   z&  def f1(self, a, b):
    return a + bZselz1.17z-  def f1(self, a,
         
    return a + b
z>>> z	>>> 		a =z1.5z	>>> 
a =
)r   rP   rM   getZnewline_and_indent_eventr   Zprompt_last_liner2   rR   rK   Zmark_setrS   rA   Ztag_add)	r   eqwrM   rU   nlZTestInfor@   testr   r   r   test_indent_and_newline_event{   s    &
4

z2IndentAndNewlineTest.test_indent_and_newline_eventN)r!   r"   r#   r$   r   r   rZ   r   r   r   r   rO   f   s
   

	rO   c                   @   s:   e Zd Zedd Zedd ZG dd dZdd Zd	S )
	RMenuTestc                 C   s,   t d t | _| j  t| jd| _d S )Nr   r   )r   r   r	   r
   r   rP   r   r   r   r   r      s    
zRMenuTest.setUpClassc                 C   sL   | j   | ` | j  | jjddD ]}| j| q(| j  | `d S r   rQ   r   r   r   r   r      s    


zRMenuTest.tearDownClassc                   @   s   e Zd Zdd ZdS )zRMenuTest.DummyRMenuc                 C   s   d S Nr   )xyr   r   r   tk_popup       zRMenuTest.DummyRMenu.tk_popupN)r!   r"   r#   r_   r   r   r   r   
DummyRMenu   s   ra   c                 C   s   d S r\   r   )r   r   r   r   test_rclick   s    zRMenuTest.test_rclickN)r!   r"   r#   r$   r   r   ra   rb   r   r   r   r   r[      s   

	r[   __main__r'   )	verbosity)Zidlelibr   Zunittestcollectionsr   Ztest.supportr   tkinterr   Zidlelib.idle_test.mock_idler   ZEditorWindowr   ZTestCaser   r%   rK   rO   r[   r!   mainr   r   r   r   <module>   s   =[