£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>
B
    YI~d<\                 @   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m	Z	 d dl
mZ d dlmZ G dd	 d	ejZG d
d dejZG dd dejZG dd dejZG dd dejZG dd dZG dd dZG dd dejZG dd dZG dd dejZG dd dejZG dd dejZed kr8ejd!d!d" dS )#    )formatN)mock)requires)TkText)EditorWindow)Editorc               @   s8   e Zd ZdZdZdZdZdZdd Zdd	 Z	d
d Z
dS )Is_Get_Testz# This is a commentzThis is not a commentz# This is a comment   z    # This is a commentz    This is not a commentc             C   s6   |  td |  td | t| j d S )N z	
)Z
assertTrueftZis_all_whiteZassertFalsetest_comment)self r   B/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_format.pytest_is_all_white   s    zIs_Get_Test.test_is_all_whitec             C   sR   | j }|t| jd |t| jd |t| jd |t| jd d S )Nr
   z    )assertEqualr   Z
get_indentr   trailingws_commentleadingws_commentleadingws_nocomment)r   Equalr   r   r   test_get_indent   s
    zIs_Get_Test.test_get_indentc             C   sd   | j }|t| jd |t| jd |t| jd |t| jd |t| jd d S )N#z    #z    r
   )r   r   Zget_comment_headerr   r   r   r   test_nocomment)r   r   r   r   r   test_get_comment_header    s    z#Is_Get_Test.test_get_comment_headerN)__name__
__module____qualname__r   r   r   r   r   r   r   r   r   r   r   r   r	      s   r	   c               @   s0   e Zd Zedd Zdd Zdd Zdd Zd	S )
FindTestc             C   s   ddl m} | | _d S )Nr   )r   )Zidlelib.idle_test.mock_tkr   text)clsr   r   r   r   
setUpClass5   s    zFindTest.setUpClassc       	      C   s   | j }|d| xftd|D ]X}t|d| dd }x6d|d |fD ]$}d||f }| t||| qNW qW |	dd d S )	Nz1.0   z%d.end.r      z%d.%dend)
r   insertrangeintindexsplitr   r   Zfind_paragraphdelete)	r   Z
inserttextZstoplineexpectedr   lineZ
linelengthcolZ	tempindexr   r   r   runcase:   s    zFindTest.runcasec          
   C   s  d}|  |dddd|dd f d}|  |d	d
dd|dd f d}|  |d	d
dd|dd f d}|  |dd
dd|dd f d}|  |dd
dd|dd f d}|  |dd
dd|dd f d}|  |dd
dd|dd f d}|  |dd
dd|dd f d S )Nz;# Comment block with no blank lines before
# Comment line

   z1.0z3.0r   r   :   zG
# Comment block with whitespace line before and after
# Comment line

   z2.0z4.0r!   F   zS
    # Indented comment block with whitespace before and after
    # Comment line

z    #R   z
# Single line comment

   z4
    # Single line comment with leading whitespace

3   z0
# Comment immediately followed by code
x = 42

(   z=
    # Indented comment immediately followed by code
x = 42

5   z=
# Comment immediately followed by indented code
    x = 42

1   )r.   )r   commentr   r   r   test_find_commentG   s     zFindTest.test_find_commentc          
   C   s   d}|  |dddd|dd f d}|  |d	d
dd|dd f d}|  |d	d
dd|dd f d}|  |dd
dd|dd f d}|  |dd
dd|dd f d S )Nz6"""String with no blank lines before
String line
"""

r1   z1.0z4.0r
   r   r7   zC
"""String with whitespace line before and after
String line.
"""

   z2.0z5.0r!   B   zV
    """Indented string with whitespace before and after
    Comment string.
    """

z    U   z
"""Single line string."""

r/   z3.0   z8
    """Single line string with leading whitespace."""

7   )r.   )r   Z
teststringr   r   r   test_find_paragraph}   s    zFindTest.test_find_paragraphN)r   r   r   classmethodr    r.   r:   r@   r   r   r   r   r   +   s   
6r   c               @   s   e Zd Zdd ZdS )ReformatFunctionTestc             C   s   | j }tj}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 S )NzO hello world r!   zHello    world   zHello  worldzO
hello
world      zO hello
world      z
O hello worldz
O
hello
worldz
O hello
world)r   r   Zreformat_paragraph)r   r   ZreformZhwr   r   r   test_reformat_paragraph   s     z,ReformatFunctionTest.test_reformat_paragraphN)r   r   r   rI   r   r   r   r   rB      s   rB   c               @   s   e Zd Zdd ZdS )ReformatCommentTestc             C   sJ   | j }d}t|dd}d}||| d}t|dd}d}||| d S )Nzu    """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""r2   z    zy    """this is a test of a reformat for a triple quoted string will it
    reformat to less than 70 characters for me?"""zm# this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?r   zo# this is a test of a reformat for a triple quoted string will it
# reformat to less than 70 characters for me?)r   r   Zreformat_comment)r   r   test_stringresultr+   r   r   r   r   test_reformat_comment   s    
z)ReformatCommentTest.test_reformat_commentN)r   r   r   rM   r   r   r   r   rJ      s   rJ   c               @   s   e Zd Zdd ZdS )FormatClassTestc             C   s2   t d}| |jd |  | |jd  d S )Neditor)r   FormatParagraphr   Zeditwinclose)r   instancer   r   r   test_init_close   s    
zFormatClassTest.test_init_closeN)r   r   r   rS   r   r   r   r   rN      s   rN   c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TextWrapperc             C   s   t |d| _d S )N)master)r   r   )r   rU   r   r   r   __init__   s    zTextWrapper.__init__c             C   s   t | j|S )N)getattrr   )r   namer   r   r   __getattr__   s    zTextWrapper.__getattr__c             C   s   d S )Nr   )r   r   r   r   undo_block_start       zTextWrapper.undo_block_startc             C   s   d S )Nr   )r   r   r   r   undo_block_stop   r[   zTextWrapper.undo_block_stopN)r   r   r   rV   rY   rZ   r\   r   r   r   r   rT      s   rT   c               @   s   e Zd Zdd ZejZdS )r   c             C   s   t || _d S )N)rT   r   )r   rootr   r   r   rV      s    zEditor.__init__N)r   r   r   rV   r   get_selection_indicesr   r   r   r   r      s   r   c               @   sP   e Zd ZdZdZdZedd Zedd Zdd	 Z	d
d Z
dd Zdd ZdS )FormatEventTestzv    '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?'''
a      '''The first line is under the max width.
    The second line's length is way over the max width. It goes on and on until it is over 100 characters long.
    Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it.
    '''
a,  # The first line is under the max width.
# The second line's length is way over the max width. It goes on and on until it is over 100 characters long.
# Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it.
# The fourth line is short like the first line.c             C   sB   t d t | _| j  t| jd}|jj| _t|j| _	d S )Ngui)r]   )
r   r   r]   withdrawr   r   r   rP   Zformat_paragraph_event	formatter)r   rO   r   r   r   r      s    

zFormatEventTest.setUpClassc             C   s$   | ` | `| j  | j  | `d S )N)r   rb   r]   update_idletasksdestroy)r   r   r   r   tearDownClass  s    

zFormatEventTest.tearDownClassc             C   s@   | j dd | d | | j ddd | j dd d S )Nz1.0zShort line
ZDummyr%   r$   )r   r%   rb   r   getr*   )r   r   r   r   test_short_line   s    
zFormatEventTest.test_short_linec             C   s   | j }|d| j |dd | jddd |dd}d}| || |dd |d| j |dd	d
 | jddd |dd}d}| || |dd d S )Nz1.0r%   ParameterDoesNothingr2   )limitzz    '''this is a test of a reformat for a triple quoted string will it
    reformat to less than 70 characters for me?'''
r$   selz1.11z1.endzv    '''this is a test of a reformat for a triple quoted string will it reformat
 to less than 70 characters for me?''')	r   r%   rK   Zmark_setrb   rf   r   r*   tag_add)r   r   rL   r+   r   r   r   test_long_line&  s    zFormatEventTest.test_long_linec             C   s\   | j }|d| j |ddd | jddd |dd}d	}| || |dd
 d S )Nz1.0rj   z2.0z4.0rh   r2   )ri   r%   z    The second line's length is way over the max width. It goes on and
    on until it is over 100 characters long. Same thing with the third
    line. It is also way over the max width, but FormatParagraph will
    fix it.
r$   )r   r%   multiline_test_stringrk   rb   rf   r   r*   )r   r   rL   r+   r   r   r   test_multiple_linesA  s    z#FormatEventTest.test_multiple_linesc             C   s   | j }|d| j | jddd |dd}d}| || |dd |d| j |dd	d
 | jddd |dd}d}| || |dd d S )Nz1.0rh   r2   )ri   r%   a/  # The first line is under the max width. The second line's length is
# way over the max width. It goes on and on until it is over 100
# characters long. Same thing with the third line. It is also way over
# the max width, but FormatParagraph will fix it. The fourth line is
# short like the first line.
r$   rj   z2.0z3.0z# The first line is under the max width.
# The second line's length is way over the max width. It goes on and
# on until it is over 100 characters long.
)r   r%   multiline_test_commentrb   rf   r   r*   rk   )r   r   rL   r+   r   r   r   test_comment_blockP  s    z"FormatEventTest.test_comment_blockN)r   r   r   rK   rm   ro   rA   r    re   rg   rl   rn   rp   r   r   r   r   r_      s   
r_   c               @   s    e Zd Zdd ZejZejZdS )DummyEditwinc             C   s(   || _ || _d| _d| _d| _d| _d S )Nr1   FT)r]   r   indentwidthZtabwidthusetabsZcontext_use_ps1)r   r]   r   r   r   r   rV   }  s    zDummyEditwin.__init__N)r   r   r   rV   r   Z_make_blanksr^   r   r   r   r   rq   |  s   rq   c               @   s   e Zd Zedd Zedd Zdd Zdd Zd	Zd
d Z	dd Z
dd Zdd Zdd Zdd Zejejddd Zejejddd Zejeddd ZdS )FormatRegionTestc             C   s`   t d t | _| j  t| j| _t | j_t | j_	t
| j| j| _t| j| _d S )Nr`   )r   r   r]   ra   r   r   r   MockrZ   r\   rq   rO   r   FormatRegionrb   )r   r   r   r   r      s    
zFormatRegionTest.setUpClassc             C   s(   | ` | `| `| j  | j  | `d S )N)r   rb   rO   r]   rc   rd   )r   r   r   r   re     s    

zFormatRegionTest.tearDownClassc             C   s   | j d| j d S )Nz1.0)r   r%   code_sample)r   r   r   r   setUp  s    zFormatRegionTest.setUpc             C   s   | j dd d S )Nz1.0r$   )r   r*   )r   r   r   r   tearDown  s    zFormatRegionTest.tearDowna  # WS line needed for test.
class C1():
    # Class comment.
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def compare(self):
        if a > b:
            return a
        elif a < b:
            return b
        else:
            return None
c             C   sr   | j j}| j}| j}|ddd ddddg}|| ddd||f |ddd	 || d
ddddgf d S )Nrj   z7.0z10.0r
   z    def compare(self):z        if a > b:
z1.0r$   z15.0z16.0)rb   
get_regionr   r   rk   join
tag_remove)r   rf   r   eqZexpected_linesr   r   r   test_get_region  s    z FormatRegionTest.test_get_regionc             C   s&  | j j}| j}| j}|j}t |_| j d }| j d }|	ddd | j 
 \}}}	}
||||	|
 |j  ||dd|	 ||dd|	 |ddd	 d
}|d}|dd|	| ||dd| ||dd| ||dd| ||dd| |ddd	 ||_d S )Nr;   	   rj   z6.0z11.0z	sel.firstzsel.lastz1.0r$   zadded line 1



rz   z7.0z10.0z7.0-1cz12.0-1c)rb   
set_regionr   r   Zbellr   ru   rw   
splitlinesrk   r{   Zassert_called_oncerf   r}   r)   )r   Zset_r   r~   Z	save_bellZline6Zline10headtailcharslinesZ	newstringnewlinesr   r   r   test_set_region  s.    


z FormatRegionTest.test_set_regionc             C   s>   | j j}| j}| j}|ddd |  ||ddd d S )Nrj   z7.0z10.0z2
        def compare(self):
            if a > b:
)rb   Zindent_region_eventr   r   rk   rf   )r   indentr   r~   r   r   r   test_indent_region_event  s    z)FormatRegionTest.test_indent_region_eventc             C   s>   | j j}| j}| j}|ddd |  ||ddd d S )Nrj   z7.0z10.0z"
def compare(self):
    if a > b:
)rb   Zdedent_region_eventr   r   rk   rf   )r   dedentr   r~   r   r   r   test_dedent_region_event  s    z)FormatRegionTest.test_dedent_region_eventc             C   s>   | j j}| j}| j}|ddd |  ||ddd d S )Nrj   z7.0z10.0z0##
##    def compare(self):
##        if a > b:
)rb   comment_region_eventr   r   rk   rf   )r   r9   r   r~   r   r   r   test_comment_region_event  s    z*FormatRegionTest.test_comment_region_eventc             C   s   | j j}| j j}| j}| j}|ddd |  |  ||ddd |ddd |ddd |  ||dd	d
 | j dddddg |  ||dd	d d S )Nrj   z7.0z10.0z*
    def compare(self):
        if a > b:
z1.0r$   z3.0z4.0z3.endz    # Class comment.r
   z# Class comment.z Class comment.)	rb   r   Zuncomment_region_eventr   r   rk   rf   r}   r   )r   r9   Z	uncommentr   r~   r   r   r   test_uncomment_region_event  s    z,FormatRegionTest.test_uncomment_region_event_asktabwidthc             C   s\   | j j}| j}| j}|ddd d |_| |  d|_| |  ||ddd d S )Nrj   z7.0z10.0r/   z$
	 def compare(self):
		  if a > b:
)	rb   tabify_region_eventr   r   rk   return_valueassertIsNoneassertIsNotNonerf   )r   r   Ztabifyr   r~   r   r   r   test_tabify_region_event  s    z)FormatRegionTest.test_tabify_region_eventc             C   sl   | j j}| j}| j}|ddd d |_| |  d|_| j   d|_| |  ||	ddd d S )Nrj   z7.0z10.0r#   r/   z0
      def compare(self):
            if a > b:
)
rb   Zuntabify_region_eventr   r   rk   r   r   r   r   rf   )r   r   Zuntabifyr   r~   r   r   r   test_untabify_region_event)  s    
z+FormatRegionTest.test_untabify_region_event
askintegerc             C   s    | j j}d|_| | d d S )N
   )rb   r   r   r   )r   r   Zaskr   r   r   test_ask_tabwidth:  s    z"FormatRegionTest.test_ask_tabwidthN)r   r   r   rA   r    re   rx   ry   rw   r   r   r   r   r   r   r   patchobjectr   rv   r   r   r   r   r   r   r   rt     s   #

	rt   c               @   s8   e Zd Zejeddd Zejeddd ZdS )IndentsTestaskyesnoc             C   sj   t d d }t|}d|_|d  | |jd | |jd |d  | |jd | |jd d S )NT   F)rq   r   Indentsr   Ztoggle_tabs_eventr   rs   rr   )r   r   rO   indentsr   r   r   test_toggle_tabsC  s    



zIndentsTest.test_toggle_tabsr   c             C   sx   t d d }t|}d |_|d  | |jd d|_|d  | |jd d|_d|_|d  | |jd d S )Nr1   r/   r;   T)rq   r   r   r   Zchange_indentwidth_eventr   rr   rs   )r   r   rO   r   r   r   r   test_change_indentwidthQ  s    




z#IndentsTest.test_change_indentwidthN)	r   r   r   r   r   r   r   r   r   r   r   r   r   r   A  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S )
RstripTestc             C   sH   t d t | _| j  t| j| _t| jd| _t	| jj
| _
d S )Nr`   )r   )r   r   r]   ra   r   r   
MockEditorrO   r   ZRstrip	do_rstrip)r   r   r   r   r    f  s    
zRstripTest.setUpClassc             C   s(   | ` | `| `| j  | j  | `d S )N)r   r   rO   r]   rc   rd   )r   r   r   r   re   o  s    

zRstripTest.tearDownClassc             C   s   | j dd d S )Nz1.0zend-1c)r   r*   )r   r   r   r   ry   v  s    zRstripTest.tearDownc             C   s8   d}d}| j d| |   | | j dd| d S )NzLine with an ending tab    
Line ending in 5 spaces     
Linewithnospaces
    indented line
    indented line with trailing space 
    
zyLine with an ending tab
Line ending in 5 spaces
Linewithnospaces
    indented line
    indented line with trailing space
z1.0r%   )r   r%   r   r   rf   )r   Zoriginalstrippedr   r   r   test_rstrip_linesy  s
    zRstripTest.test_rstrip_linesc          
   C   s   | j }xLdD ]D}| j|d. |d| |   | |ddd W d Q R X qW xXdD ]P}| j|d: |dd |d| |   | |ddd W d Q R X qZW d S )N)r
   rz   z


)codez1.0zend-1cr
   )za
za

za


za
)r   ZsubTestr%   r   r   rf   r*   )r   r   r   r   r   r   test_rstrip_end  s    
"
zRstripTest.test_rstrip_endN)	r   r   r   rA   r    re   ry   r   r   r   r   r   r   r   d  s
   	r   __main__r#   )	verbosityexit)Zidlelibr   r   Zunittestr   Ztest.supportr   Ztkinterr   r   Zidlelib.editorr   Zidlelib.idle_test.mock_idler   r   ZTestCaser	   r   rB   rJ   rN   rT   r_   rq   rt   r   r   r   mainr   r   r   r   <module>   s,   w  9#7
