<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
 f                 @   s   d Z ddlmZ ddlZddlmZ ed ddlZddl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edkre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.
    )textviewN)requiresZgui)Tk)Button)Func)	Mbox_funcc               C   s   t  atj  d S )N)r   rootwithdraw r
   r
   D/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_textview.pysetUpModule   s    r   c               C   s   t j  t j  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j  t jj  t jj  d S )N)r   r   __init__r   r   )selfr
   r
   r   setUp,   s    

zViewWindowTest.setUpc             C   sB   t tdd}| jt jj | jt jj | jt j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}| jt jj | jt jj | jt j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|j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edd Zedd Zdd ZdS )TextFrameTestc             C   s&   t   | _}|j  tj|d| _d S )Nz	test text)r   r   r	   tvZ	TextFrameframe)clsr   r
   r
   r   
setUpClassJ   s    zTextFrameTest.setUpClassc             C   s    | ` | jj  | jj  | `d S )N)r&   r   r   r   )r'   r
   r
   r   tearDownClassP   s    

zTextFrameTest.tearDownClassc             C   s    | j jj}| j|ddd d S )Nz1.0z1.endz	test text)r&   textgetassertEqual)r   r+   r
   r
   r   
test_line1W   s    
zTextFrameTest.test_line1N)r   r   r   classmethodr(   r)   r-   r
   r
   r
   r   r$   H   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)r1   r%   r0   )r'   r
   r
   r   r)   d   s    zViewFunctionTest.tearDownClassc             C   s>   t jtdddd}| j|t j | j|jt j |jj  d S )Nr   z	test textF)r!   )r%   	view_textr   assertIsInstance
ViewWindow	viewframe	ViewFramer   )r   r   r
   r
   r   test_view_texti   s    zViewFunctionTest.test_view_textc             C   s\   t jtdtddd}| j|t j | j|jt j |jjj	j
}| jd|dd |j  d S )Nr   asciiF)r!   ZTestz1.0z1.end)r%   	view_filer   __file__r3   r4   r5   r6   	textframer*   r+   ZassertInr   )r   r   r+   r
   r
   r   test_view_fileo   s    zViewFunctionTest.test_view_filec             C   s2   t jtddddd}| j| | jt jjd d S )Nr   zabc.xyzr8   F)r!   zFile Load Error)r%   r9   r   assertIsNoner,   r0   title)r   r   r
   r
   r   test_bad_filew   s    
zViewFunctionTest.test_bad_filec             C   sR   t j}|j|j|jtdd}tjtd|ddd}| j	| | j
tjjd d S )Nz..zCREDITS.txtr   r8   F)r!   zUnicode Decode Error)ospathabspathjoindirnamer:   r%   r9   r   r=   r,   r0   r>   )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}| j|jdd d S )Nr   ZtestFZnone)r!   wraprH   )r%   r2   r   r5   r;   r*   r,   Zcget)r   r   Ztext_widgetr
   r
   r   test_nowrap   s    
zViewFunctionTest.test_nowrapN)r   r   r   r.   r(   r)   r7   r<   r?   rG   rI   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 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|j  j jd  j jj d  j j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%   r2   r   r   r
   )r   r
   r   _command   s    zAButtonClickTest.test_view_text_bind_with_button.<locals>._commandBUTTON)r*   commandTrL   z1.0z1.endrM   )r   r   invoke
addCleanupr   r,   r   r   r>   r5   r;   r*   r+   )r   rO   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|j  j jd  j jj d  jj	j
jj}ttB} j|dd|j j  |j   j|d	d
|j j  W d Q R X d S )Nc                  s    d _ tjtdtddd _d S )NT
TITLE_FILEr8   )encodingrN   )r   r%   r9   r   r:   r   r
   )r   r
   r   rO      s    
zAButtonClickTest.test_view_file_bind_with_button.<locals>._commandrP   )r*   rQ   TrV   z1.0z1.endz3.0z3.end)r   r   rR   rS   r   r,   r   r   r>   r5   r;   r*   r+   openr:   readlinestrip)r   rO   rT   r+   fr
   )r   r   test_view_file_bind_with_button   s    
z/ButtonClickTest.test_view_file_bind_with_buttonN)r   r   r   r   rK   rU   r\   r
   r
   r
   r   rJ      s   rJ   __main__   )	verbosity)__doc__Zidlelibr   r%   ZunittestZtest.supportr   r@   Ztkinterr   Ztkinter.ttkr   Zidlelib.idle_test.mock_idler   Zidlelib.idle_test.mock_tkr   r   r   r4   r   ZTestCaser   r$   r/   rJ   r   mainr
   r
   r
   r   <module>   s$   .)