Your IP : 18.117.105.184


Current Path : /opt/alt/python36/lib64/python3.6/idlelib/idle_test/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/idle_test/__pycache__/test_searchengine.cpython-36.pyc

3

� f-�@sdZddlmZddlZddlmZmZmZddl	j
Zddlm
Z
mZddlmZddlZdd�Zd	d
�ZGdd�d�ZGd
d�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedk�rejdd�dS)z Test searchengine, coverage 99%.�)�searchengineN)�
BooleanVar�	StringVar�TclError)�Var�Mbox)�TextcCstt_tt_tt_dS)N)r�serrr�tkMessageBox�rr�H/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_searchengine.py�setUpModulesr
cCstt_tt_tt_dS)N)rr	rr
rrrr�tearDownModulesrc@seZdZdd�ZdS)�MockcOsdS)Nr)�self�args�kwargsrrr�__init__ sz
Mock.__init__N)�__name__�
__module__�__qualname__rrrrrrsrc@seZdZdd�ZdS)�GetTestcCs\tj}tt_zBt�}tj|�}|j|tj�|j|j|�|jtj|�|�Wd|t_XdS)N)r	�SearchEnginer�getZassertIsInstanceZassertIsZ
_searchengine)rZsaved_Engine�root�enginerrr�test_get$s
zGetTest.test_getN)rrrrrrrrr"src@seZdZdd�ZdS)�GetLineColTestcCsH|jtjd�d�|jtjd�d	�|jttjd�|jttjd�dS)
Nz1.0�rz1.11�z1.0 lineend�end)rr)rr)�assertEqualr	Zget_line_colZassertRaises�
ValueError)rrrr�test_get_line_col2sz GetLineColTest.test_get_line_colN)rrrr#rrrrr0src@seZdZdd�ZdS)�GetSelectionTestcCsVt�}|jdd�dd�}||_|jtj|�d	�dd�}||_|jtj|�d
�dS)N�1.0zHello World!cSs |dkrdS|dkrdSt�dS)Nz	sel.firstz1.0zsel.lastz1.12)r)�srrr�selLs
z0GetSelectionTest.test_get_selection.<locals>.sel�1.12cSs|dkrdSt�dS)N�insertz1.5)r)r&rrr�markTsz1GetSelectionTest.test_get_selection.<locals>.mark�1.5)r%r()r+r+)�mockTextr)�indexr!r	Z
get_selection)r�textr'r*rrr�test_get_selectionFsz#GetSelectionTest.test_get_selectionN)rrrr/rrrrr$9s
r$c@seZdZdd�ZdS)�ReverseSearchTestcCs�|j}d}tjd�}|tj||t|��j�d	�|tj||d�j�d
�|tj||d�j�d�|tj||d�j�d�|tj||d�d�dS)
NzHere is an 'is' test text.�is���
���)r2r3)r2r3)r5r6)r5r6)r!�re�compiler	Zsearch_reverse�len�span)r�Equal�line�progrrr�test_search_reverse^s
z%ReverseSearchTest.test_search_reverseN)rrrr?rrrrr0\sr0c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�SearchEngineTestcCstjdd�|_dS)N)r)r	rr)rrrr�setUplszSearchEngineTest.setUpcCs�|j}|j}||j�d�|jd�||j�d�||j�d�|jjd�||j�d�||j�d�|jjd�||j�d�||j	�d�|j
jd�||j	�d�||j�d�|jjd�||j�d�||j
�d�|jjd�||j
�d�dS)N��helloFrTr)rr!�getpat�setpatZisre�revar�setZiscase�casevarZisword�wordvarZiswrap�wrapvarZisback�backvar)rrr<rrr�test_is_getqs(
zSearchEngineTest.test_is_getcCsJ|j}|jd�|j|j�d�|jjd�|jd�|j|j�d�dS)Nz\srz\\s)rZsetcookedpatr!rDrFrG)rrrrr�test_setcookedpat�s

z"SearchEngineTest.test_setcookedpatcCs�|j}|j}||j�d�|jd�||j�d�|jjd�||j�d�|jjd�|jd�||j�d�|jjd�||j�d�dS)NrBrCTz	\bhello\bFz\sz\\s)rr!ZgetcookedpatrErIrGrF)rrr<rrr�test_getcookedpat�s

z"SearchEngineTest.test_getcookedpatcCs�|j}|j}|jd�|j�}||jtjdtj�j�|jj	d�|j�}||jtjd�jd�|jd�||j�d�|jd�|j
j	d�||j�d�|jtjj
d�dS)NZHellorrrB�+z1Error: nothing to repeat at position 0
Pattern: +)rr!rEZgetprog�patternr8r9�
IGNORECASErHrGrFr�	showerror�message)rrr<Ztemppatrrr�test_getprog�s



zSearchEngineTest.test_getprogcCs�tj}|j}d}d}||jj||�d�||jd�d|d}||j|�||jj||d�d�||jd�|d7}||j|�dS)Nz[a-zz$unexpected end of regular expressionzRegular expression errorzError: z
Pattern: [a-zr5z

Offset: 5)rrRr!rZreport_error�titlerS)rrRr<�pat�msgZexpected_messagerrr�test_report_error�sz"SearchEngineTest.test_report_errorN)	rrrrArLrMrNrTrXrrrrr@isr@c@s eZdZedd��Zdd�ZdS)�
SearchTestcCsNt�|_d}|jjd|�tjd�|_tjd�|_dd�|j_	dd�|j_
dS)Nz&First line
Line with target
Last line
z1.0�targetcWsd|fS)N�fr)rrrr�<lambda>�sz'SearchTest.setUpClass.<locals>.<lambda>cWsd|fS)N�br)rrrrr\�s)r,r.r)r8r9rVr	rr�search_forward�search_backward)�cls�	test_textrrr�
setUpClass�szSearchTest.setUpClassc	Csx|j}|j}|j}|j}|j}|jjd�|||�d�dd�}||_||||�d||ddddff�|jjd�||||�d||ddddff�|jjd�|j	jd�||||�d||ddddff�|j	jd�d	d
�}||_||||�d||ddddff�||||d�d||dd
ddff�|j	jd�||||�d||dd
ddff�||||d�d||ddddff�dS)NcSs|dkrdSt�dS)Nr)z1.5)r)r&rrrr*�sz$SearchTest.test_search.<locals>.markr[rr5TFr]cSs |dkrdS|dkrdSt�dS)Nz	sel.firstz2.10zsel.lastz2.16)r)r&rrrr'�s
z#SearchTest.test_search.<locals>.sel���
)
r!rZsearch_textr.rVZpatvarrGr-rJrK)rr<r�searchr.rVr*r'rrr�test_search�s.    " zSearchTest.test_searchN)rrr�classmethodrbrgrrrrrY�srYc@s0eZdZedd��Zdd�Zdd�Zdd�Zd	S)
�ForwardBackwardTestcCs`tjd�|_t�|_dd�|j_d}|jjd|�tjd�|_	d|_
tjd	�|_tjd
�|_dS)
NcSsdS)Nz4.0r)r-rrrr\sz0ForwardBackwardTest.setUpClass.<locals>.<lambda>z&First line
Line with target
Last line
z1.0rZrcrerdZxyzz\w*�rerd)rcrj)
r	rrr,r.r-r)r8r9rV�res�failpat�emptypat)r`rarrrrb
szForwardBackwardTest.setUpClasscsd��fdd�	}|S)Nrcs0��j|||||�}|r,|d|dj�fS|S)Nrr)r.r;)rVr=�colZwrap�okrk)�funcrrrrf!sz/ForwardBackwardTest.make_search.<locals>.search)rr)rrprfr)rprr�make_search szForwardBackwardTest.make_searchcCs�|j}|j|jj�}|j}|||ddd�|j�|||ddd�|j�|||ddd�d�|||ddd�|j�|||jddd�d�|||jddddd	�d�|||jddd�|j�dS)NrrT�Frcre�	)ro�rsrs)rcrt)r!rqrr^rVrkrlrm)rr<ZforwardrVrrr�test_search_forward'sz'ForwardBackwardTest.test_search_forwardcCs�|j}|j|jj�}|j}|||ddd�|j�|||ddd�|j�|||ddd�d�|||ddd�|j�|||jddd�d�|||jdd	ddd
�d�|||jddd�d�dS)Nrrr5TrcrFrdrsre)ro�rsrs)rcrv�r5rs)rcrw)r!rqrr_rVrkrlrm)rr<ZbackwardrVrrr�test_search_backward8sz(ForwardBackwardTest.test_search_backwardN)rrrrhrbrqrurxrrrrrisri�__main__rc)�	verbosity)�__doc__Zidlelibrr	ZunittestZtkinterrrrZtkinter.messageboxZ
messageboxr
Zidlelib.idle_test.mock_tkrrrr,r8r
rrZTestCaserrr$r0r@rYrir�mainrrrr�<module>s&
	#
`=C


?>