<!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>
B
     f;                 @   s~  d Z ddlmZ ddlZddlmZ ddlmZ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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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rzejd'd(d) dS )*a  Test query, coverage 93%).

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END)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               @   s<   e Zd ZejjZejjZejjZdd Zdd Z	dd Z
dS )zQueryTest.Dummy_Queryc             C   s&   t |d| _ddi| _d | _d| _d S )N)valuetext F)r   entryentry_errorresult	destroyed)selfdummy_entry r   A/opt/alt/python37/lib64/python3.7/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   Dummy_Query   s   r   c             C   sD   |  d}| | d  | |j|jfd | d|jd  d S )N )NFz
blank liner
   )r   assertEqualr   r   r   assertInr   )r   dialogr   r   r   test_entry_ok_blank+   s    
zQueryTest.test_entry_ok_blankc             C   sD   |  d}| j}|| d ||j|jfd ||jd d d S )Nz  good good)NFr
   r   )r   r!   r   r   r   r   )r   r#   Equalr   r   r   test_entry_ok_good1   s
    
zQueryTest.test_entry_ok_goodc             C   sT   |  d}t |j_| | d  | |jjj |j`| |j	|j
fd d S )Nr   )NF)r   r   Mockr   Z	focus_setr!   r   
assertTruecalledr   r   )r   r#   r   r   r   test_ok_blank8   s    
zQueryTest.test_ok_blankc             C   s2   |  d}| | d  | |j|jfd d S )Nr%   )r%   T)r   r!   r   r   r   )r   r#   r   r   r   test_ok_good@   s    
zQueryTest.test_ok_goodc             C   s2   |  d}| | d  | |j|jfd d S )Nzdoes not matter)NT)r   r!   r   r   r   )r   r#   r   r   r   test_cancelE   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               @   s*   e Zd ZejjZdgZdd Zdd ZdS )z!SectionNameTest.Dummy_SectionNameusedc             C   s   t |d| _ddi| _d S )N)r	   r
   r   )r   r   r   )r   r   r   r   r   r   Q   s    z*SectionNameTest.Dummy_SectionName.__init__c             C   s   || j d< d S )Nr
   )r   )r   r   r   r   r   r   T   s    z+SectionNameTest.Dummy_SectionName.showerrorN)	r   r   r   r   SectionNamer   
used_namesr   r   r   r   r   r   Dummy_SectionNameN   s   r3   c             C   s0   |  d}| | d  | d|jd  d S )Nr    zno namer
   )r3   r!   r   r"   r   )r   r#   r   r   r   test_blank_section_nameW   s    
z'SectionNameTest.test_blank_section_namec             C   s0   |  d}| | d  | d|jd  d S )Nr0   Zuser
   )r3   r!   r   r"   r   )r   r#   r   r   r   test_used_section_name\   s    
z&SectionNameTest.test_used_section_namec             C   s0   |  d}| | d  | d|jd  d S )NZ goodgoodgoodgoodgoodgoodgoodgoodzlonger than 30r
   )r3   r!   r   r"   r   )r   r#   r   r   r   test_long_section_namea   s    
z&SectionNameTest.test_long_section_namec             C   s0   |  d}| | d | |jd d d S )Nz  good r%   r
   r   )r3   r!   r   r   )r   r#   r   r   r   test_good_section_namef   s    
z&SectionNameTest.test_good_section_nameN)	r   r   r   r.   r3   r4   r5   r6   r7   r   r   r   r   r/   K   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               @   s(   e Zd ZejjZdZdd Zdd ZdS )zModuleNameTest.Dummy_ModuleNamer   c             C   s   t |d| _ddi| _d S )N)r	   r
   r   )r   r   r   )r   r   r   r   r   r   r   s    z(ModuleNameTest.Dummy_ModuleName.__init__c             C   s   || j d< d S )Nr
   )r   )r   r   r   r   r   r   u   s    z)ModuleNameTest.Dummy_ModuleName.showerrorN)	r   r   r   r   
ModuleNamer   text0r   r   r   r   r   r   Dummy_ModuleNameo   s   r;   c             C   s0   |  d}| | d  | d|jd  d S )Nr    zno namer
   )r;   r!   r   r"   r   )r   r#   r   r   r   test_blank_module_namex   s    
z%ModuleNameTest.test_blank_module_namec             C   s0   |  d}| | d  | 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   |  d}| | d  | 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   |  d}| | d | |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   l   s   	r8   c               @   s6   e Zd ZdZG dd dZdd Zdd Zdd	 Zd
S )GotoTestzTest Goto subclass of Query.c               @   s$   e Zd ZejjZdd Zdd ZdS )zGotoTest.Dummy_ModuleNamec             C   s   t |d| _ddi| _d S )N)r	   r
   r   )r   r   r   )r   r   r   r   r   r      s    z"GotoTest.Dummy_ModuleName.__init__c             C   s   || j d< d S )Nr
   )r   )r   r   r   r   r   r      s    z#GotoTest.Dummy_ModuleName.showerrorN)r   r   r   r   Gotor   r   r   r   r   r   r   r;      s   r;   c             C   s0   |  d}| | d  | d|jd  d S )Naznot a base 10 integerr
   )r;   r!   r   r"   r   )r   r#   r   r   r   test_bogus_goto   s    
zGotoTest.test_bogus_gotoc             C   s0   |  d}| | d  | d|jd  d S )N0znot a positive integerr
   )r;   r!   r   r"   r   )r   r#   r   r   r   test_bad_goto   s    
zGotoTest.test_bad_gotoc             C   s0   |  d}| | d | |jd d d S )N1   r
   r   )r;   r!   r   r   )r   r#   r   r   r   test_good_goto   s    
zGotoTest.test_good_gotoN)r   r   r   r.   r;   rF   rH   rK   r   r   r   r   rC      s
   rC   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   rP   c          
   C   s   |   }xddd dfddd tfddd dfddd tffD ]J\}}}|  2 |j| ||_|  | |j | W d Q R X q>W d S )Nr   c             S   s   dS )Nr   r   )rE   bcr   r   r   <lambda>       zBHelpsourceBrowsefileTest.test_file_replaces_path.<locals>.<lambda>c             S   s   t S )N)__file__)rE   rQ   rR   r   r   r   rS      rT   Zhtestc             S   s   dS )Nr   r   )rE   rQ   rR   r   r   r   rS      rT   c             S   s   t S )N)rU   )rE   rQ   rR   r   r   r   rS      rT   )	rP   rU   subTestrO   setZaskfilenamerN   r!   get)r   r#   pathfuncr   r   r   r   test_file_replaces_path   s    
z0HelpsourceBrowsefileTest.test_file_replaces_pathN)r   r   r   r.   rP   r[   r   r   r   r   rL      s   rL   c               @   sP   e Zd ZdZG dd dZej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               @   s&   e Zd ZejjZdd ZdddZdS )z%HelpsourcePathokTest.Dummy_HelpSourcec             C   s   t |d| _ddi| _d S )N)r	   r
   r   )r   rY   
path_error)r   Z
dummy_pathr   r   r   r      s    z.HelpsourcePathokTest.Dummy_HelpSource.__init__Nc             C   s   || j d< d S )Nr
   )r]   )r   r   Zwidgetr   r   r   r      s    z/HelpsourcePathokTest.Dummy_HelpSource.showerror)N)r   r   r   r   rM   path_okr   r   r   r   r   r   rP      s   rP   c             C   s   | j t_d S )N)orig_platformr   platform)clsr   r   r   tearDownClass   s    z"HelpsourcePathokTest.tearDownClassc             C   s0   |  d}| | d  | d|jd  d S )Nr    zno help filer
   )rP   r!   r^   r"   r]   )r   r#   r   r   r   test_path_ok_blank   s    
z'HelpsourcePathokTest.test_path_ok_blankc             C   s4   |  td }| | d  | d|jd  d S )Nzbad-bad-badz	not existr
   )rP   rU   r!   r^   r"   r]   )r   r#   r   r   r   test_path_ok_bad   s    z%HelpsourcePathokTest.test_path_ok_badc          
   C   sd   |  d}| j}xNdD ]F}|  4 |j| | | | | |jd d W d Q R X qW d S )Nr   )z
www.py.orgzhttp://py.orgr
   )rP   r!   rV   rY   rW   r^   r]   )r   r#   r&   Zurlr   r   r   test_path_ok_web   s    


z%HelpsourcePathokTest.test_path_ok_webc          
   C   sl   |  d}x\dD ]T\}}|  > |t_|jt | | |t  | |j	d d W d Q R X qW d S )Nr   ))darwinzfile://)otherr   r
   )
rP   rV   r   r`   rY   rW   rU   r!   r^   r]   )r   r#   r`   prefixr   r   r   test_path_ok_file   s    

z&HelpsourcePathokTest.test_path_ok_fileN)r   r   r   r.   rP   r   r`   r_   classmethodrb   rc   rd   re   ri   r   r   r   r   r\      s   	r\   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)rY   )r   r   r   r   r^      s    z.HelpsourceEntryokTest.Dummy_HelpSource.path_okN)
r   r   r   r   rM   r   r   r]   rm   r^   r   r   r   r   rP      s
   rP   c          
   C   sR   |   }xDdD ]<\}}}|  $ || |_|_| | | W d Q R X qW d S )N))NNN)Nzdoc.txtN)docNN)rn   zdoc.txt)rn   zdoc.txt)rP   rV   rl   rY   r!   r   )r   r#   rl   rY   r   r   r   r   test_entry_ok_helpsource   s
    
z.HelpsourceEntryokTest.test_entry_ok_helpsourceN)r   r   r   r.   rP   ro   r   r   r   r   rk      s   	rk   c               @   s6   e Zd ZdZG dd dZdd Zdd Zdd	 Zd
S )CustomRunCLIargsokTestz6Test cli_ok method of the CustomRun subclass of Query.c               @   s$   e Zd ZejjZdd Zdd ZdS )z&CustomRunCLIargsokTest.Dummy_CustomRunc             C   s   t |d| _ddi| _d S )N)r	   r
   r   )r   r   r   )r   r   r   r   r   r     s    z/CustomRunCLIargsokTest.Dummy_CustomRun.__init__c             C   s   || j d< d S )Nr
   )r   )r   r   r   r   r   r     s    z0CustomRunCLIargsokTest.Dummy_CustomRun.showerrorN)r   r   r   r   	CustomRuncli_args_okr   r   r   r   r   r   Dummy_CustomRun  s   rs   c             C   s   |  d}| | g  d S )Nr    )rs   r!   rr   )r   r#   r   r   r   test_blank_args  s    
z&CustomRunCLIargsokTest.test_blank_argsc             C   s0   |  d}| | d  | d|jd  d S )Nz'no-closing-quotez
No closingr
   )rs   r!   rr   r"   r   )r   r#   r   r   r   test_invalid_args  s    
z(CustomRunCLIargsokTest.test_invalid_argsc             C   sP   ddddddg}|  d|d }| | |d	g  | |jd
 d d S )Nz-nZ10z	--verbosez-pz/pathz--namer    z
 "my name"zmy namer
   r   )rs   joinr!   rr   r   )r   argsr#   r   r   r   test_good_args  s    z%CustomRunCLIargsokTest.test_good_argsN)r   r   r   r.   rs   rt   ru   rx   r   r   r   r   rp   	  s
   rp   c               @   s&   e Zd ZdZG dd dZdd ZdS )CustomRunEntryokTestz8Test entry_ok method of the CustomRun subclass of Query.c               @   s&   e Zd ZejjZi Ze Zdd Z	dS )z$CustomRunEntryokTest.Dummy_CustomRunc             C   s   | j S )N)cli_args)r   r   r   r   rr   +  s    z0CustomRunEntryokTest.Dummy_CustomRun.cli_args_okN)
r   r   r   r   rq   r   r   r   
restartvarrr   r   r   r   r   rs   '  s   rs   c             C   sx   |   }xjdD ]b}|j| xPddgdg|fffD ]8\}}| j||d ||_| | | W d Q R X q4W qW d S )N>   FT)NNzmy arg)restartrz   )rs   r{   rW   rV   rz   r!   r   )r   r#   r|   rz   r   r   r   r   test_entry_ok_customrun.  s    
z,CustomRunEntryokTest.test_entry_ok_customrunN)r   r   r   r.   rs   r}   r   r   r   r   ry   $  s   ry   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  tj|dddd| _t | j_	d S )NguiZTESTZtestT)_utest)
r   r   rootwithdrawr   r   r#   r   r(   r   )ra   r   r   r   r   
setUpClass=  s
    
zQueryGuiTest.setUpClassc             C   s   | j `| ` | j  | `d S )N)r#   r   r   )ra   r   r   r   rb   E  s    
zQueryGuiTest.tearDownClassc             C   s(   | j jdd d | j _| j j  d S )Nr   end)r#   r   deleter   r   Z
reset_mock)r   r   r   r   setUpL  s    zQueryGuiTest.setUpc             C   s>   | j }|jdd |j  | |jd | |jj	 d S )Nr   abc)
r#   r   insert	button_okinvoker!   r   r)   r   r*   )r   r#   r   r   r   test_click_okQ  s
    
zQueryGuiTest.test_click_okc             C   s0   | j }|j  | |jd  | |jj d S )N)r#   r   r   r!   r   ZassertFalser   r*   )r   r#   r   r   r   test_click_blankX  s    
zQueryGuiTest.test_click_blankc             C   s>   | j }|jdd |j  | |jd  | |jj	 d S )Nr   r   )
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   rj   r   rb   r   r   r   r   r   r   r   r   r~   ;  s   r~   c               @   s    e Zd Zedd Zdd ZdS )SectionnameGuiTestc             C   s   t d d S )Nr   )r   )ra   r   r   r   r   h  s    zSectionnameGuiTest.setUpClassc             C   sl   t  }|  tj|dddhdd}| j}| |jdh |jdd |j	  | |j
d |  d S )NTtr   T)r   r   Zokay)r   r   r   r1   r!   r2   r   r   r   r   r   r   )r   r   r#   r&   r   r   r   test_click_section_namel  s    
z*SectionnameGuiTest.test_click_section_nameN)r   r   r   rj   r   r   r   r   r   r   r   f  s   r   c               @   s    e Zd Zedd Zdd ZdS )ModulenameGuiTestc             C   s   t d d S )Nr   )r   )ra   r   r   r   r   z  s    zModulenameGuiTest.setUpClassc             C   sj   t  }|  tj|ddddd}| |jd | |j d |j	  | 
|jd |  d S )Nr   r   r@   T)r   z__init__.py)r   r   r   r9   r!   r:   r   rX   r   r   r)   r   rA   r   )r   r   r#   r   r   r   test_click_module_name~  s    
z(ModulenameGuiTest.test_click_module_nameN)r   r   r   rj   r   r   r   r   r   r   r   x  s   r   c               @   s    e Zd Zedd Zdd ZdS )GotoGuiTestc             C   s   t d d S )Nr   )r   )ra   r   r   r   r     s    zGotoGuiTest.setUpClassc             C   sR   t  }|  tj|dddd}|jdd |j  | |j	d |
  d S )Nr   r   T)r   r   Z22   )r   r   r   rD   r   r   r   r   r!   r   r   )r   r   r#   r   r   r   r     s    
z"GotoGuiTest.test_click_module_nameN)r   r   r   rj   r   r   r   r   r   r   r     s   r   c               @   s    e Zd Zedd Zdd ZdS )HelpsourceGuiTestc             C   s   t d d S )Nr   )r   )ra   r   r   r   r     s    zHelpsourceGuiTest.setUpClassc             C   s   t  }|  tj|ddtdd}| j}||j d ||j t |j	
  tjdkr`dnd}||jd|t f |  d S )Nr   Z__test__T)Zmenuitemfilepathr   rf   zfile://r   )r   r   r   rM   rU   r!   r   rX   rY   r   r   sysr`   r   r   )r   r   r#   r&   rh   r   r   r   test_click_help_source  s    


z(HelpsourceGuiTest.test_click_help_sourceN)r   r   r   rj   r   r   r   r   r   r   r     s   r   c               @   s    e Zd Zedd Zdd ZdS )CustomRunGuiTestc             C   s   t d d S )Nr   )r   )ra   r   r   r   r     s    zCustomRunGuiTest.setUpClassc             C   sr   t  }|  tj|dddgdd}| |j d |jtd |j	
  | |jdddgdf |  d S )	NZTitlerE   zb=1T)rz   r   za b=1z crR   )r   r   r   rq   r!   r   rX   r   r   r   r   r   r   )r   r   r#   r   r   r   test_click_args  s    
z CustomRunGuiTest.test_click_argsN)r   r   r   rj   r   r   r   r   r   r   r     s   r   __main__   F)	verbosityexit)r.   r@   r   ZunittestZtest.supportr   Ztkinterr   r   r   r   Zidlelib.idle_test.mock_tkr   ZTestCaser   r/   r8   rC   rL   r\   rk   rp   ry   r~   r   r   r   r   r   r   mainr   r   r   r   <module>   s0   3!!-+
