B
    \d
                 @   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G dd dZ	e	 Z
G dd	 d	Ze 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    !Changing this line will break Test_findfile.test_found!
Non-gui unit tests for grep.GrepDialog methods.
dummy_command calls grep_it calls findfiles.
An exception raised in one method will fail callers.
Otherwise, tests are mostly independent.
Currently only test grep_it, coverage 51%.
    )
GrepDialogN)captured_stdout)Varc               @   s   e Zd ZdZdd ZdS )Dummy_searchenginezGrepDialog.__init__ calls parent SearchDiabolBase which attaches the
    passed in SearchEngine instance as attribute 'engine'. Only a few of the
    many possible self.engine.x attributes are needed here.
    c             C   s   | j S )N)_pat)self r   ,lib/python3.7/idlelib/idle_test/test_grep.pygetpat   s    zDummy_searchengine.getpatN)__name__
__module____qualname____doc__r
   r   r   r   r	   r      s   r   c               @   s,   e Zd ZejZejZedZeZ	dd Z
dS )
Dummy_grepFc             C   s   d S )Nr   )r   r   r   r	   close"   s    zDummy_grep.closeN)r   r   r   r   grep_itZ	findfilesr   Zrecvarsearchengineenginer   r   r   r   r	   r      s
   r   c               @   s   e Zd ZdS )FindfilesTestN)r   r   r   r   r   r   r	   r   (   s   r   c               @   s$   e Zd Zdd Zdd Zdd ZdS )Grep_itTestc          	   C   sF   |t j_t }t t|t W d Q R X | 	d}|
  |S )N
)grepr   r   r   r   recompile__file__getvaluesplitpop)r   patslinesr   r   r	   report5   s    zGrep_itTest.reportc             C   sB   d}|  |}| t|d | ||d  | |d d d S )Nzxyz*xyz*xyz*xyz*xyz*xyz*xyz*   r      zNo hits.)r!   assertEquallenassertIn)r   r   r    r   r   r	   test_unfound=   s
    
zGrep_itTest.test_unfoundc             C   sf   d}|  |}| t|d | ||d  | d|d  | d|d  | |d d	 d S )
Nz<""" !Changing this line will break Test_findfile.test_found!   r   zpy: 1:r#   2      z(Hint:)r!   r$   r%   r&   Z
assertTrue
startswith)r   r   r    r   r   r	   
test_foundD   s    
zGrep_itTest.test_foundN)r   r   r   r!   r'   r-   r   r   r   r	   r   0   s   r   c               @   s   e Zd ZdS )Default_commandTestN)r   r   r   r   r   r   r	   r.   O   s   r.   __main__r"   )	verbosity)r   Zidlelib.grepr   ZunittestZtest.supportr   Zidlelib.idle_test.mock_tkr   r   r   r   r   r   ZTestCaser   r   r.   r   mainr   r   r   r	   <module>   s   