Your IP : 3.21.12.122


Current Path : /opt/alt/python34/lib64/python3.4/idlelib/idle_test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/idlelib/idle_test/__pycache__/test_searchengine.cpython-34.pyo

�
e f�,�@s�dZddlZddlZddlmZmZmZddljZ	ddl
mZddl
mZmZddl
mZdd�Zd	d
�ZGdd�d�ZGd
d�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedkr~ejdddd�ndS)z9Test functions and SearchEngine class in SearchEngine.py.�N)�
BooleanVar�	StringVar�TclError)�SearchEngine)�Var�Mbox)�TextcCstt_tt_tt_dS)N)r�serrr�tkMessageBox�rr�H/opt/alt/python34/lib64/python3.4/idlelib/idle_test/test_searchengine.py�setUpModules		r
cCstt_tt_tt_dS)N)rr	rr
rrrr�tearDownModules		rc@seZdZdd�ZdS)�MockcOsdS)Nr)�self�args�kwargsrrr�__init__sz
Mock.__init__N)�__name__�
__module__�__qualname__rrrrrrsrc@seZdZdd�ZdS)�GetTestcCs~tj}tt_z[t�}tj|�}|j|tj�|j|j|�|jtj|�|�Wd|t_XdS)N)r	rr�getZassertIsInstanceZassertIsZ
_searchengine)rZsaved_Engine�root�enginerrr�test_get#s			zGetTest.test_getN)rrrrrrrrr!src@seZdZdd�ZdS)�GetLineColTestcCsb|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_col1sz GetLineColTest.test_get_line_colN)rrrr"rrrrr/src@seZdZdd�ZdS)�GetSelectionTestcCsyt�}|jdd�dd�}||_|jtj|�d	�dd�}||_|jtj|�d
�dS)N�1.0zHello World!cSs*|dkrdS|dkr dSt�dS)Nz	sel.firstz1.0zsel.lastz1.12)r)�srrr�selKs
z0GetSelectionTest.test_get_selection.<locals>.sel�1.12cSs|dkrdSt�dS)N�insertz1.5)r)r%rrr�markSsz1GetSelectionTest.test_get_selection.<locals>.mark�1.5)r$r')r*r*)�mockTextr(�indexr r	Z
get_selection)r�textr&r)rrr�test_get_selectionEs			z#GetSelectionTest.test_get_selectionN)rrrr.rrrrr#8s
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���
���)r1r2)r1r2)r4r5)r4r5)r �re�compiler	Zsearch_reverse�len�span)r�Equal�line�progrrr�test_search_reverse]s	("""z%ReverseSearchTest.test_search_reverseN)rrrr>rrrrr/[sr/c@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�SearchEngineTestcCstjdd�|_dS)Nr)r	rr)rrrr�setUpkszSearchEngineTest.setUpcCsW|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_getps(		
zSearchEngineTest.test_is_getcCsc|j}|jd�|j|j�d�|jjd�|jd�|j|j�d�dS)Nz\srz\\s)rZsetcookedpatr rCrErF)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)NrArBTz	\bhello\bFz\sz\\s)rr ZgetcookedpatrDrHrFrE)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)NZHellorrrA�+z#Error: nothing to repeat
Pattern: +)rr rDZgetprog�patternr7r8�
IGNORECASErGrFrEr�	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-zr4z

Offset: 5)rrQr rZreport_error�titlerR)rrQr;�pat�msgZexpected_messagerrr�test_report_error�s		
z"SearchEngineTest.test_report_errorN)	rrrr@rKrLrMrSrWrrrrr?hsr?c@s.eZdZedd��Zdd�ZdS)�
SearchTestcCsqt�|_d}|jjd|�tjd�|_tjd�|_dd�|j_	dd�|j_
dS)Nz&First line
Line with target
Last line
z1.0�targetcWs
d|fS)N�fr)rrrr�<lambda>�sz'SearchTest.setUpClass.<locals>.<lambda>cWs
d|fS)N�br)rrrrr[�s)r+r-r(r7r8rUr	rr�search_forward�search_backward)�cls�	test_textrrr�
setUpClass�szSearchTest.setUpClassc	Cs|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|dkrdSt�dS)Nr(z1.5)r)r%rrrr)�sz$SearchTest.test_search.<locals>.markrZrr4TFr\cSs*|dkrdS|dkr dSt�dS)Nz	sel.firstz2.10zsel.lastz2.16)r)r%rrrr&�s
z#SearchTest.test_search.<locals>.sel���
)
r rZsearch_textr-rUZpatvarrFr,rIrJ)rr;r�searchr-rUr)r&rrr�test_search�s.						...	.1.zSearchTest.test_searchN)rrr�classmethodrarfrrrrrX�srXc@sFeZdZedd��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.0rYrbrdrcZxyzz\w*�rdrc)rbri)
r	rrr+r-r,r(r7r8rU�res�failpat�emptypat)r_r`rrrras	zForwardBackwardTest.setUpClasscsd��fdd�}|S)Nrcs@��j|||||�}|r<|d|dj�fS|S)Nrr)r-r:)rUr<�colZwrap�okrj)�funcrrrre sz/ForwardBackwardTest.make_search.<locals>.searchr)rrorer)rorr�make_searchszForwardBackwardTest.make_searchcCs
|j}|j|jj�}|j}|||ddd�|j�|||ddd�|j�|||ddd�d�|||ddd�|j�|||jddd�d�|||jdddd	d�d�|||jddd�|j�dS)NrrT�Frbrd�	rn�rrrr)rbrs)r rprr]rUrjrkrl)rr;ZforwardrUrrr�test_search_forward&s		%z'ForwardBackwardTest.test_search_forwardcCs|j}|j|jj�}|j}|||ddd�|j�|||ddd�|j�|||ddd�d�|||ddd�|j�|||jddd�d�|||jdd	dd
d�d�|||jddd�d�dS)Nrqr4TrbrFrcrrrdrn�rrrr)rbru�r4rr)rbrv)r rprr^rUrjrkrl)rr;ZbackwardrUrrr�test_search_backward7s		%z(ForwardBackwardTest.test_search_backwardN)rrrrgrarprtrwrrrrrhsrh�__main__�	verbosityrb�exit)�__doc__r7ZunittestZtkinterrrrZtkinter.messageboxZ
messageboxr
Zidlelibrr	Zidlelib.idle_test.mock_tkrrrr+r
rrZTestCaserrr#r/r?rXrhr�mainrrrr�<module>s&	#
`=C

?>