<!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
    YI~d;                 @   sz  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rvejd&d'd( dS ))    )queryN)requires)TkEND)mock)Varc               @   sB   e 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 )	QueryTestc               @   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   r   r$   r'   r+   r,   r-   r   r   r   r   r      s   r   c               @   s:   e Zd ZG dd dZdd Zdd Zdd Zd	d
 ZdS )SectionNameTestc               @   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   r2   c             C   s0   |  d}| | d  | d|jd  d S )Nr    zno namer
   )r2   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 )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   s0   |  d}| | d  | d|jd  d S )NZ goodgoodgoodgoodgoodgoodgoodgoodzlonger than 30r
   )r2   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   )r2   r!   r   r   )r   r#   r   r   r   test_good_section_namef   s    
z&SectionNameTest.test_good_section_nameN)r   r   r   r2   r3   r4   r5   r6   r   r   r   r   r.   K   s
   	r.   c               @   s:   e Zd ZG dd dZdd Zdd Zdd Zd	d
 ZdS )ModuleNameTestc               @   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>   rA   r   r   r   r   r7   l   s
   	r7   c               @   s2   e Zd ZG dd dZdd Zdd Zdd Zd	S )
GotoTestc               @   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:   rE   rG   rJ   r   r   r   r   rB      s   rB   c               @   s"   e Zd ZG dd dZdd ZdS )HelpsourceBrowsefileTestc               @   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   rO   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   )rD   bcr   r   r   <lambda>       zBHelpsourceBrowsefileTest.test_file_replaces_path.<locals>.<lambda>c             S   s   t S )N)__file__)rD   rP   rQ   r   r   r   rR      rS   Zhtestc             S   s   dS )Nr   r   )rD   rP   rQ   r   r   r   rR      rS   c             S   s   t S )N)rT   )rD   rP   rQ   r   r   r   rR      rS   )	rO   rT   subTestrN   setZaskfilenamerM   r!   get)r   r#   pathfuncr   r   r   r   test_file_replaces_path   s    
z0HelpsourceBrowsefileTest.test_file_replaces_pathN)r   r   r   rO   rZ   r   r   r   r   rK      s   rK   c               @   sL   e 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 )HelpsourcePathokTestc               @   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   rX   
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   rL   path_okr   r   r   r   r   r   rO      s   rO   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
   )rO   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
   )rO   rT   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
   )rO   r!   rU   rX   rV   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
   )
rO   rU   r   r_   rX   rV   rT   r!   r]   r\   )r   r#   r_   prefixr   r   r   test_path_ok_file   s    

z&HelpsourcePathokTest.test_path_ok_fileN)r   r   r   rO   r   r_   r^   classmethodra   rb   rc   rd   rh   r   r   r   r   r[      s   	r[   c               @   s"   e Zd ZG dd dZdd ZdS )HelpsourceEntryokTestc               @   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)rX   )r   r   r   r   r]      s    z.HelpsourceEntryokTest.Dummy_HelpSource.path_okN)
r   r   r   r   rL   r   r   r\   rl   r]   r   r   r   r   rO      s
   rO   c          
   C   sR   |   }xDdD ]<\}}}|  $ || |_|_| | | W d Q R X qW d S )N))NNN)Nzdoc.txtN)docNN)rm   zdoc.txt)rm   zdoc.txt)rO   rU   rk   rX   r!   r   )r   r#   rk   rX   r   r   r   r   test_entry_ok_helpsource   s
    
z.HelpsourceEntryokTest.test_entry_ok_helpsourceN)r   r   r   rO   rn   r   r   r   r   rj      s   	rj   c               @   s2   e Zd ZG dd dZdd Zdd Zdd Zd	S )
CustomRunCLIargsokTestc               @   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   rr   c             C   s   |  d}| | g  d S )Nr    )rr   r!   rq   )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
   )rr   r!   rq   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   )rr   joinr!   rq   r   )r   argsr#   r   r   r   test_good_args  s    z%CustomRunCLIargsokTest.test_good_argsN)r   r   r   rr   rs   rt   rw   r   r   r   r   ro   	  s   ro   c               @   s"   e Zd ZG dd dZdd ZdS )CustomRunEntryokTestc               @   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   rq   +  s    z0CustomRunEntryokTest.Dummy_CustomRun.cli_args_okN)
r   r   r   r   rp   r   r   r   
restartvarrq   r   r   r   r   rr   '  s   rr   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)restartry   )rr   rz   rV   rU   ry   r!   r   )r   r#   r{   ry   r   r   r   r   test_entry_ok_customrun.  s    
z,CustomRunEntryokTest.test_entry_ok_customrunN)r   r   r   rr   r|   r   r   r   r   rx   $  s   rx   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   )r`   r   r   r   r   
setUpClass=  s
    
zQueryGuiTest.setUpClassc             C   s   | j `| ` | j  | `d S )N)r#   r   r   )r`   r   r   r   ra   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   ri   r   ra   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   )r`   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   r0   r!   r1   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   ri   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   )r`   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   r8   r!   r9   r   rW   r   r   r)   r   r@   r   )r   r   r#   r   r   r   test_click_module_name~  s    
z(ModulenameGuiTest.test_click_module_nameN)r   r   r   ri   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   )r`   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   rC   r   r   r   r   r!   r   r   )r   r   r#   r   r   r   r     s    
z"GotoGuiTest.test_click_module_nameN)r   r   r   ri   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   )r`   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   re   zfile://r   )r   r   r   rL   rT   r!   r   rW   rX   r   r   sysr_   r   r   )r   r   r#   r&   rg   r   r   r   test_click_help_source  s    


z(HelpsourceGuiTest.test_click_help_sourceN)r   r   r   ri   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   )r`   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TitlerD   zb=1T)ry   r   za b=1z crQ   )r   r   r   rp   r!   r   rW   r   r   r   r   r   r   )r   r   r#   r   r   r   test_click_args  s    
z CustomRunGuiTest.test_click_argsN)r   r   r   ri   r   r   r   r   r   r   r     s   r   __main__   F)	verbosityexit)r?   r   ZunittestZtest.supportr   Ztkinterr   r   r   r   Zidlelib.idle_test.mock_tkr   ZTestCaser   r.   r7   rB   rK   r[   rj   ro   rx   r}   r   r   r   r   r   r   mainr   r   r   r   <module>   s.   3!!-+
