
W                 @   s   d  Z  d d l Z d d l m Z d d l m Z m Z d d l m Z Gd d   d  Z	 Gd d	   d	 e j
  Z e d
 k r e j d d  d S)z!Unit tests for idlelib.AutoExpand    N)requires)TextTk)
AutoExpandc               @   s   e  Z d  Z d d   Z d S)Dummy_Editwinc             C   s   | |  _  d  S)N)text)selfr    r	   D/afs/.cs/s/python-3.5.2/amd64_ubu14/lib/python3.5/test_autoexpand.py__init__   s    zDummy_Editwin.__init__N)__name__
__module____qualname__r   r	   r	   r	   r
   r   	   s   r   c               @   s|   e  Z d  Z e d d    Z e d d    Z d d   Z d d   Z d	 d
   Z d d   Z	 d d   Z
 d d   Z d S)AutoExpandTestc             C   se   d t  t  k r= t d  t   |  _ t |  j  |  _ n t   |  _ t t |  j   |  _ d  S)NtkinterZgui)	strr   r   r   tkr   r   r   auto_expand)clsr	   r	   r
   
setUpClass   s    
zAutoExpandTest.setUpClassc             C   s2   |  `  |  ` t |  d  r. |  j j   |  ` d  S)Nr   )r   r   hasattrr   Zdestroy)r   r	   r	   r
   tearDownClass   s    zAutoExpandTest.tearDownClassc             C   s   |  j  j d d  d  S)Nz1.0end)r   delete)r   r	   r	   r
   tearDown!   s    zAutoExpandTest.tearDownc             C   s  |  j  } |  j j } |  j } | |   d  | j d d  | |   d  | j d d  | |   d  | j d d  | |   d  | j d d  | |   d  | j d d  | |   d	  | j d
 d  | |   d  | j d d  | |   d  d  S)N inserttZhisthis isz
sample
stringstringz3.0z1.0r   )r   r   getprevwordassertEqualr   r   )r   r   previousequalr	   r	   r
   test_get_prevword$   s$    		z AutoExpandTest.test_get_prevwordc             C   s   |  j  j } |  j  j } |  j } |  j j d d  | |  j  j   d d d d g  | d  | |   d  | d  | |   d  | d  | |   d  | d  | |   d  d  S)Nr   zab ac bx ad ab aabadacaevent)r   r"   expand_word_eventr#   r   r   getwords)r   r$   expandr%   r	   r	   r
   test_before_only@   s    	"



zAutoExpandTest.test_before_onlyc             C   s   |  j  } |  j j } |  j j } |  j } | j d d  | j d d  | |  j j   d d d d g  | d  | |   d  | d  | |   d  | d  | |   d  | d  | |   d  d  S)	Nr   z a, [ab] ac: () bx"" cd ac= ad yaz1.1r'   r)   r(   r*   r+   )r   r   r"   r,   r#   r   mark_setr-   )r   r   r$   r.   r%   r	   r	   r
   test_after_onlyP   s    		"



zAutoExpandTest.test_after_onlyc             C   s   |  j  } |  j j } |  j j } |  j } | j d d  | j d d  | j d d  | |  j j   d d d g  | d  | |   d  | d  | |   d  | d  | |   d  d  S)	Nr   z	ab xy yz
z
a ac by acz2.1r'   r)   r*   r+   )r   r   r"   r,   r#   r   r0   r-   )r   r   r$   r.   r%   r	   r	   r
   test_both_before_afterc   s    		


z%AutoExpandTest.test_both_before_afterc             C   s   |  j  } |  j j } |  j } | |  j j   g   | | d  d  | j d d  | |  j j   g   | j d d  | j d d  | d  |  j j } | j d d  | d  |  j j } |  j | |  d  S)Nr+   breakr   z
bx cy dz azac xy a ac ad az1.7z1.end)	r   r   r,   r#   r-   r   r0   stateZassertNotEqual)r   r   r.   r%   Zinitial_stateZ	new_stater	   r	   r
   test_other_expand_casesu   s    		

z&AutoExpandTest.test_other_expand_casesN)r   r   r   classmethodr   r   r   r&   r/   r1   r2   r5   r	   r	   r	   r
   r      s   
r   __main__	verbosity   )__doc__ZunittestZtest.supportr   r   r   r   Zidlelib.AutoExpandr   r   ZTestCaser   r   mainr	   r	   r	   r
   <module>   s   ~