<!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 ddlmZ ddl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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G dd dejZedkr"ejddd dS ) a  Test query, coverage 91%).

Non-gui tests for Query, SectionName, ModuleName, and HelpSource use
dummy versions that extract the non-gui methods and add other needed
attributes.  GUI tests create an instance of each class and simulate
entries and button clicks.  Subclass tests only target the new code in
the subclass definition.

The appearance of the widgets is checked by the Query and
HelpSource htests.  These are run by running query.py.
    )queryN)requires)Tk)mock)Varc               @   sF   e Zd ZdZG dd dZdd Zdd Zdd	 Zd
d Zdd Z	dS )	QueryTestzTest Query base class.c               @   sF   e Zd ZejjZejjZejjZe Z	i Z
dd Zdd Zdd ZdS )zQueryTest.Dummy_Queryc             C   s&   | j j| d| jd< d | _d| _d S )N textF)entrysetentry_errorresult	destroyed)selfdummy_entry r   A/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_query.py__init__#   s    
zQueryTest.Dummy_Query.__init__c             C   s   || j d< d S )Nr	   )r   )r   messager   r   r   	showerror(   s    zQueryTest.Dummy_Query.showerrorc             C   s
   d| _ d S )NT)r   )r   r   r   r   destroy*   s    zQueryTest.Dummy_Query.destroyN)__name__
__module____qualname__r   Queryentry_okokcancelr   r
   r   r   r   r   r   r   r   r   Dummy_Query   s   r   c             C   sD   | j d}| j|j d  | j|j|jfd | jd|jd  d S )N Fz
blank liner	   )NF)r   assertEqualr   r   r   assertInr   )r   dialogr   r   r   test_entry_ok_blank-   s    
zQueryTest.test_entry_ok_blankc             C   sD   | j d}| j}||j d ||j|jfd ||jd d d S )Nz  good goodFr	   r   )NF)r   r    r   r   r   r   )r   r"   Equalr   r   r   test_entry_ok_good3   s
    
zQueryTest.test_entry_ok_goodc             C   sT   | j d}tj |j_| j|j d  | j|jjj |j`| j|j	|j
fd d S )Nr   F)NF)r   r   Mockr
   Z	focus_setr    r   
assertTruecalledr   r   )r   r"   r   r   r   test_ok_blank:   s    
zQueryTest.test_ok_blankc             C   s2   | j d}| j|j d  | j|j|jfd d S )Nr$   T)r$   T)r   r    r   r   r   )r   r"   r   r   r   test_ok_goodB   s    
zQueryTest.test_ok_goodc             C   s2   | j d}| j|j d  | j|j|jfd d S )Nzdoes not matterT)NT)r   r    r   r   r   )r   r"   r   r   r   test_cancelG   s    
zQueryTest.test_cancelN)
r   r   r   __doc__r   r#   r&   r*   r+   r,   r   r   r   r   r      s   r   c               @   s>   e Zd ZdZG dd dZdd Zdd Zdd	 Zd
d ZdS )SectionNameTestz#Test SectionName subclass of Query.c               @   s4   e Zd ZejjZdgZe Zi Z	dd Z
dd ZdS )z!SectionNameTest.Dummy_SectionNameusedc             C   s   | j j| d| jd< d S )Nr   r	   )r
   r   r   )r   r   r   r   r   r   U   s    z*SectionNameTest.Dummy_SectionName.__init__c             C   s   || j d< d S )Nr	   )r   )r   r   r   r   r   r   X   s    z+SectionNameTest.Dummy_SectionName.showerrorN)r   r   r   r   SectionNamer   
used_namesr   r
   r   r   r   r   r   r   r   Dummy_SectionNameP   s   r2   c             C   s0   | j d}| j|j d  | jd|jd  d S )Nr   zno namer	   )r2   r    r   r!   r   )r   r"   r   r   r   test_blank_section_name[   s    
z'SectionNameTest.test_blank_section_namec             C   s0   | j d}| j|j d  | jd|jd  d S )Nr/   Zuser	   )r2   r    r   r!   r   )r   r"   r   r   r   test_used_section_name`   s    
z&SectionNameTest.test_used_section_namec             C   s4   | j dd }| j|j d  | jd|jd  d S )Nr$      zlonger than 30r	   )r2   r    r   r!   r   )r   r"   r   r   r   test_long_section_namee   s    z&SectionNameTest.test_long_section_namec             C   s0   | j d}| j|j d | j|jd d d S )Nz  good r$   r	   r   )r2   r    r   r   )r   r"   r   r   r   test_good_section_namej   s    
z&SectionNameTest.test_good_section_nameN)	r   r   r   r-   r2   r3   r4   r6   r7   r   r   r   r   r.   M   s   r.   c               @   s>   e Zd ZdZG dd dZdd Zdd Zdd	 Zd
d ZdS )ModuleNameTestz"Test ModuleName subclass of Query.c               @   s2   e Zd ZejjZdZe Zi Z	dd Z
dd ZdS )zModuleNameTest.Dummy_ModuleNamer   c             C   s   | j j| d| jd< d S )Nr   r	   )r
   r   r   )r   r   r   r   r   r   x   s    z(ModuleNameTest.Dummy_ModuleName.__init__c             C   s   || j d< d S )Nr	   )r   )r   r   r   r   r   r   {   s    z)ModuleNameTest.Dummy_ModuleName.showerrorN)r   r   r   r   
ModuleNamer   text0r   r
   r   r   r   r   r   r   r   Dummy_ModuleNames   s   r;   c             C   s0   | j d}| j|j d  | jd|jd  d S )Nr   zno namer	   )r;   r    r   r!   r   )r   r"   r   r   r   test_blank_module_name~   s    
z%ModuleNameTest.test_blank_module_namec             C   s0   | j d}| j|j d  | jd|jd  d S )NZ __name_xyz123_should_not_exist__z	not foundr	   )r;   r    r   r!   r   )r   r"   r   r   r   test_bogus_module_name   s    
z%ModuleNameTest.test_bogus_module_namec             C   s0   | j d}| j|j d  | jd|jd  d S )N	itertoolszsource-basedr	   )r;   r    r   r!   r   )r   r"   r   r   r   test_c_source_name   s    
z!ModuleNameTest.test_c_source_namec             C   s4   | j d}| j|j jd | j|jd d d S )Nidlelibz__init__.pyr	   r   )r;   r(   r   endswithr    r   )r   r"   r   r   r   test_good_module_name   s    
z$ModuleNameTest.test_good_module_nameN)	r   r   r   r-   r;   r<   r=   r?   rB   r   r   r   r   r8   p   s   r8   c               @   s&   e Zd ZdZG dd dZdd ZdS )HelpsourceBrowsefileTestz8Test browse_file method of ModuleName subclass of Query.c               @   s   e Zd ZejjZe ZdS )z)HelpsourceBrowsefileTest.Dummy_HelpSourceN)r   r   r   r   
HelpSourcebrowse_filer   pathvarr   r   r   r   Dummy_HelpSource   s   rG   c             C   s   | j  }xddd dfddd tfddd dfddd tffD ]J\}}}| j 2 |jj| ||_|j  | j|jj | W d Q R X q>W d S )Nr   c             S   s   dS )Nr   r   )abcr   r   r   <lambda>   s    zBHelpsourceBrowsefileTest.test_file_replaces_path.<locals>.<lambda>c             S   s   t S )N)__file__)rH   rI   rJ   r   r   r   rK      s    Zhtestc             S   s   dS )Nr   r   )rH   rI   rJ   r   r   r   rK      s    c             S   s   t S )N)rL   )rH   rI   rJ   r   r   r   rK      s    )	rG   rL   subTestrF   r   ZaskfilenamerE   r    get)r   r"   pathfuncr   r   r   r   test_file_replaces_path   s    
z0HelpsourceBrowsefileTest.test_file_replaces_pathN)r   r   r   r-   rG   rQ   r   r   r   r   rC      s   rC   c               @   sJ   e Zd ZdZG dd dZedd Zdd Zdd	 Zd
d Z	dd Z
dS )HelpsourcePathokTestz4Test path_ok method of HelpSource subclass of Query.c               @   s0   e Zd ZejjZe Zi Zdd Z	dddZ
dS )z%HelpsourcePathokTest.Dummy_HelpSourcec             C   s   | j j| d| jd< d S )Nr   r	   )rO   r   
path_error)r   Z
dummy_pathr   r   r   r      s    z.HelpsourcePathokTest.Dummy_HelpSource.__init__Nc             C   s   || j d< d S )Nr	   )rS   )r   r   Zwidgetr   r   r   r      s    z/HelpsourcePathokTest.Dummy_HelpSource.showerror)N)r   r   r   r   rD   path_okr   rO   rS   r   r   r   r   r   r   rG      s
   rG   c             C   s
   t t_d S )N)orig_platformr   platform)clsr   r   r   tearDownClass   s    z"HelpsourcePathokTest.tearDownClassc             C   s0   | j d}| j|j d  | jd|jd  d S )Nr   zno help filer	   )rG   r    rT   r!   rS   )r   r"   r   r   r   test_path_ok_blank   s    
z'HelpsourcePathokTest.test_path_ok_blankc             C   s4   | j td }| j|j d  | jd|jd  d S )Nzbad-bad-badz	not existr	   )rG   rL   r    rT   r!   rS   )r   r"   r   r   r   test_path_ok_bad   s    z%HelpsourcePathokTest.test_path_ok_badc             C   sd   | j d}| j}xNdD ]F}| j 4 |jj| | j|j | | j|jd d W d Q R X qW d S )Nr   
www.py.orghttp://py.orgr	   )r[   r\   )rG   r    rM   rO   r   rT   rS   )r   r"   r%   Zurlr   r   r   test_path_ok_web   s    


z%HelpsourcePathokTest.test_path_ok_webc             C   sl   | j d}x\dD ]T\}}| j > |t_|jjt | j|j |t  | j|j	d d W d Q R X qW d S )	Nr   darwinfile://otherr	   r^   r_   r`   r   )ra   rb   )
rG   rM   r   rV   rO   r   rL   r    rT   rS   )r   r"   rV   prefixr   r   r   test_path_ok_file   s    

z&HelpsourcePathokTest.test_path_ok_fileN)r   r   r   r-   rG   classmethodrX   rY   rZ   r]   rd   r   r   r   r   rR      s   
	rR   c               @   s&   e Zd ZdZG dd dZdd ZdS )HelpsourceEntryokTestz5Test entry_ok method of HelpSource subclass of Query.c               @   s,   e Zd ZejjZi Zi Zdd Zdd Z	dS )z&HelpsourceEntryokTest.Dummy_HelpSourcec             C   s   | j S )N)name)r   r   r   r   item_ok   s    z.HelpsourceEntryokTest.Dummy_HelpSource.item_okc             C   s   | j S )N)rO   )r   r   r   r   rT      s    z.HelpsourceEntryokTest.Dummy_HelpSource.path_okN)
r   r   r   r   rD   r   r   rS   rh   rT   r   r   r   r   rG      s
   rG   c             C   sR   | j  }xDdD ]<\}}}| j $ || |_|_| j|j | W d Q R X qW d S )	Ndoc.txtdocNNNNri   Nrj   NNrj   ri   rj   ri   rn   )rk   rl   rm   ro   )rG   rM   rg   rO   r    r   )r   r"   rg   rO   r   r   r   r   test_entry_ok_helpsource   s      
z.HelpsourceEntryokTest.test_entry_ok_helpsourceN)r   r   r   r-   rG   rp   r   r   r   r   rf      s   	rf   c               @   sD   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S )QueryGuiTestc             C   sB   t d t  | _}| jj  tj|dddd| _tj | j_	d S )NguiZTESTZtestT)_utest)
r   r   rootwithdrawr   r   r"   r   r'   r   )rW   rt   r   r   r   
setUpClass   s
    
zQueryGuiTest.setUpClassc             C   s   | j `| ` | jj  | `d S )N)r"   r   rt   )rW   r   r   r   rX     s    
zQueryGuiTest.tearDownClassc             C   s(   | j jjdd d | j _| j jj  d S )Nr   end)r"   r
   deleter   r   Z
reset_mock)r   r   r   r   setUp  s    zQueryGuiTest.setUpc             C   s>   | j }|jjdd |jj  | j|jd | j|jj	 d S )Nr   abc)
r"   r
   insert	button_okinvoker    r   r(   r   r)   )r   r"   r   r   r   test_click_ok  s
    
zQueryGuiTest.test_click_okc             C   s0   | j }|jj  | j|jd  | j|jj d S )N)r"   r|   r}   r    r   ZassertFalser   r)   )r   r"   r   r   r   test_click_blank  s    
zQueryGuiTest.test_click_blankc             C   s>   | j }|jjdd |jj  | j|jd  | j|jj	 d S )Nr   rz   )
r"   r
   r{   Zbutton_cancelr}   r    r   r(   r   r)   )r   r"   r   r   r   test_click_cancel  s
    
zQueryGuiTest.test_click_cancelN)
r   r   r   re   rv   rX   ry   r~   r   r   r   r   r   r   rq      s   rq   c               @   s    e Zd Zedd Zdd ZdS )SectionnameGuiTestc             C   s   t d d S )Nrr   )r   )rW   r   r   r   rv   $  s    zSectionnameGuiTest.setUpClassc             C   sp   t  }|j  tj|dddhdd}| j}| j|jdh |jjdd |jj	  | j|j
d ~|j  ~d S )NTtrz   T)rs   r   Zokay)r   ru   r   r0   r    r1   r
   r{   r|   r}   r   r   )r   rt   r"   r%   r   r   r   test_click_section_name(  s    
z*SectionnameGuiTest.test_click_section_nameN)r   r   r   re   rv   r   r   r   r   r   r   "  s   r   c               @   s    e Zd Zedd Zdd ZdS )ModulenameGuiTestc             C   s   t d d S )Nrr   )r   )rW   r   r   r   rv   8  s    zModulenameGuiTest.setUpClassc             C   sn   t  }|j  tj|ddddd}| j|jd | j|jj d |jj	  | j
|jjd ~|j  ~d S )Nr   r   r@   T)rs   z__init__.py)r   ru   r   r9   r    r:   r
   rN   r|   r}   r(   r   rA   r   )r   rt   r"   r   r   r   test_click_module_name<  s    
z(ModulenameGuiTest.test_click_module_nameN)r   r   r   re   rv   r   r   r   r   r   r   6  s   r   c               @   s    e Zd Zedd Zdd ZdS )HelpsourceGuiTestc             C   s   t d d S )Nrr   )r   )rW   r   r   r   rv   K  s    zHelpsourceGuiTest.setUpClassc             C   s   t  }|j  tj|ddtdd}| j}||jj d ||jj t |j	j
  tjdkr`dnd}||jd|t f ~|j  ~d S )Nr   Z__test__T)Zmenuitemfilepathrs   r^   zfile://r   )r   ru   r   rD   rL   r    r
   rN   rO   r|   r}   sysrV   r   r   )r   rt   r"   r%   rc   r   r   r   test_click_help_sourceO  s    


z(HelpsourceGuiTest.test_click_help_sourceN)r   r   r   re   rv   r   r   r   r   r   r   I  s   r   __main__   F)	verbosityexit)r-   r@   r   ZunittestZtest.supportr   Ztkinterr   r   r   Zidlelib.idle_test.mock_tkr   ZTestCaser   r.   r8   rV   rU   rC   rR   rf   rq   r   r   r   r   mainr   r   r   r   <module>   s(   5#%.+
