£Á°è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
     f                 @   s  d Z ddlmZ ddlmZ ed ddlZddlZddlm	Z	m
Z
mZmZmZ ddlmZ ddlmZ dd	lmZ d
d Zdd 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ejZG dd dejZedkrej dd dS )a  Test textview, coverage 100%.

Since all methods and functions create (or destroy) a ViewWindow, which
is a widget containing a widget, etcetera, all tests must be gui tests.
Using mock Text would not change this.  Other mocks are used to retrieve
information about calls.
    )textview)requiresZguiN)TkTclErrorCHARNONEWORD)Button)Func)	Mbox_funcc               C   s   t  at  d S )N)r   rootwithdraw r   r   D/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_textview.pysetUpModule   s    r   c               C   s   t   t   b d S )N)r   update_idletasksdestroyr   r   r   r   tearDownModule   s    r   c               @   s   e Zd Ze Ze Ze ZdS )VWN)__name__
__module____qualname__r
   	transientgrab_setwait_windowr   r   r   r   r   #   s   r   c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
ViewWindowTestc             C   s"   t j  t j  t j  d S )N)r   r   __init__r   r   )selfr   r   r   setUp,   s    

zViewWindowTest.setUpc             C   sB   t tdd}| t jj | t jj | t jj |  d S )NTitlez	test text)r   r   
assertTruer   calledr   r   ok)r   viewr   r   r   test_init_modal1   s
    zViewWindowTest.test_init_modalc             C   sF   t tdddd}| t jj | t jj | t jj |  d S )Nr   z	test textF)modal)r   r   ZassertFalser   r!   r   r   r"   )r   r#   r   r   r   test_init_nonmodal8   s
    z!ViewWindowTest.test_init_nonmodalc             C   s>   t tdddd}t |_|  | |jj |`|  d S )Nr   z	test textF)r%   )r   r   r
   r   r"   r    r!   )r   r#   r   r   r   test_ok?   s    zViewWindowTest.test_okN)r   r   r   r   r$   r&   r'   r   r   r   r   r   *   s   r   c               @   s   e Zd Zdd ZdS )AutoHideScrollbarTestc             C   s*   t t}| t|j | t|j d S )N)tvZAutoHideScrollbarr   ZassertRaisesr   ZpackZplace)r   Zscrollr   r   r   test_forbidden_geometryJ   s    
z-AutoHideScrollbarTest.test_forbidden_geometryN)r   r   r   r*   r   r   r   r   r(   H   s   r(   c               @   s@   e Zd Zedd Zedd ZefddZdd Zd	d
 Z	dS )ScrollableTextFrameTestc             C   s   t   | _}|  d S )N)r   r   r   )clsr   r   r   r   
setUpClassR   s    z"ScrollableTextFrameTest.setUpClassc             C   s   | j   | j   | ` d S )N)r   r   r   )r,   r   r   r   tearDownClassW   s    

z%ScrollableTextFrameTest.tearDownClassc                s2   t j| jfd|i|  fdd}| |  S )Nwrapc                  s          d S )N)r   r   r   )framer   r   cleanup_frame_   s    z9ScrollableTextFrameTest.make_frame.<locals>.cleanup_frame)r)   ZScrollableTextFramer   
addCleanup)r   r/   kwargsr1   r   )r0   r   
make_frame]   s    
z"ScrollableTextFrameTest.make_framec             C   s0   |   }|jdd | |jddd d S )Nz1.0z	test textz1.end)r4   textinsertassertEqualget)r   r0   r   r   r   
test_line1e   s    z"ScrollableTextFrameTest.test_line1c          
   C   s   | j td}| |jdt | |j xTttgD ]H}| j	|d2 | j |d}| |jd| | 
|j W d Q R X q6W d S )N)r/   r/   )r4   r   r7   r5   cgetZassertIsNotNoneZxscrollr   r   ZsubTestassertIsNone)r   r0   r/   r   r   r   test_horiz_scrollbarj   s    z,ScrollableTextFrameTest.test_horiz_scrollbarN)
r   r   r   classmethodr-   r.   r   r4   r9   r<   r   r   r   r   r+   P   s
   r+   c               @   s,   e Zd Zedd Zedd Zdd ZdS )ViewFrameTestc             C   s&   t   | _}|  t|d| _d S )Nz	test text)r   r   r   r)   	ViewFramer0   )r,   r   r   r   r   r-   ~   s    zViewFrameTest.setUpClassc             C   s    | ` | j  | j  | `d S )N)r0   r   r   r   )r,   r   r   r   r.      s    

zViewFrameTest.tearDownClassc             C   s    | j jj}| |ddd d S )Nz1.0z1.endz	test text)r0   r5   r8   r7   )r   r8   r   r   r   r9      s    
zViewFrameTest.test_line1N)r   r   r   r=   r-   r.   r9   r   r   r   r   r>   |   s   r>   c               @   sL   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S )ViewFunctionTestc             C   s   t j| _t t _d S )N)r)   	showerror
orig_errorr   )r,   r   r   r   r-      s    zViewFunctionTest.setUpClassc             C   s   | j t_| ` d S )N)rB   r)   rA   )r,   r   r   r   r.      s    zViewFunctionTest.tearDownClassc             C   s>   t jtdddd}| |t j | |jt j |j  d S )Nr   z	test textF)r%   )r)   	view_textr   assertIsInstance
ViewWindow	viewframer?   r"   )r   r#   r   r   r   test_view_text   s    zViewFunctionTest.test_view_textc             C   s\   t jtdtddd}| |t j | |jt j |jjj	j
}| d|dd |  d S )Nr   asciiF)r%   ZTestz1.0z1.end)r)   	view_filer   __file__rD   rE   rF   r?   	textframer5   r8   ZassertInr"   )r   r#   r8   r   r   r   test_view_file   s    zViewFunctionTest.test_view_filec             C   s2   t jtddddd}| | | t jjd d S )Nr   zabc.xyzrH   F)r%   zFile Load Error)r)   rI   r   r;   r7   rA   title)r   r#   r   r   r   test_bad_file   s    
zViewFunctionTest.test_bad_filec             C   sR   t j}|||tdd}tjtd|ddd}| 	| | 
tjjd d S )Nz..zCREDITS.txtr   rH   F)r%   zUnicode Decode Error)ospathabspathjoindirnamerJ   r)   rI   r   r;   r7   rA   rM   )r   pfnr#   r   r   r   test_bad_encoding   s
    
z"ViewFunctionTest.test_bad_encodingc             C   s4   t jtddddd}|jjj}| |dd d S )Nr   ZtestFZnone)r%   r/   r/   )r)   rC   r   rF   rK   r5   r7   r:   )r   r#   Ztext_widgetr   r   r   test_nowrap   s    
zViewFunctionTest.test_nowrapN)r   r   r   r=   r-   r.   rG   rL   rN   rV   rW   r   r   r   r   r@      s   r@   c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
ButtonClickTestc             C   s   d | _ d| _d S )NF)r#   r!   )r   r   r   r   r      s    zButtonClickTest.setUpc             C   s   | j r| j   d S )N)r#   r   )r   r   r   r   tearDown   s    zButtonClickTest.tearDownc                sn    fdd}t td|d}|   |j   jd   j d   jj	j
jddd	 d S )
Nc                  s   d _ tjtdddd _d S )NT
TITLE_TEXTCOMMAND)_utest)r!   r)   rC   r   r#   r   )r   r   r   _command   s    zAButtonClickTest.test_view_text_bind_with_button.<locals>._commandBUTTON)r5   commandTrZ   z1.0z1.endr[   )r	   r   invoker2   r   r7   r!   r#   rM   rF   rK   r5   r8   )r   r]   buttonr   )r   r   test_view_text_bind_with_button   s    z/ButtonClickTest.test_view_text_bind_with_buttonc          	      s    fdd}t td|d}|   |j   jd   j d  jj	j
jj}ttB} |dd|   |   |d	d
|   W d Q R X d S )Nc                  s    d _ tjtdtddd _d S )NT
TITLE_FILErH   )encodingr\   )r!   r)   rI   r   rJ   r#   r   )r   r   r   r]      s    
zAButtonClickTest.test_view_file_bind_with_button.<locals>._commandr^   )r5   r_   Trc   z1.0z1.endz3.0z3.end)r	   r   r`   r2   r   r7   r!   r#   rM   rF   rK   r5   r8   openrJ   readlinestrip)r   r]   ra   r8   fr   )r   r   test_view_file_bind_with_button   s    
z/ButtonClickTest.test_view_file_bind_with_buttonN)r   r   r   r   rY   rb   ri   r   r   r   r   rX      s   rX   __main__   )	verbosity)!__doc__Zidlelibr   r)   Ztest.supportr   rO   ZunittestZtkinterr   r   r   r   r   Ztkinter.ttkr	   Zidlelib.idle_test.mock_idler
   Zidlelib.idle_test.mock_tkr   r   r   rE   r   ZTestCaser   r(   r+   r>   r@   rX   r   mainr   r   r   r   <module>   s(   ,.)
