Your IP : 18.220.110.45


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_codecontext.cpython-36.pyc

3

� f�8�@s�dZddlmZddlZddlmZddlmZmZm	Z	m
Z
ddlmZddlZddlm
Z
ejjZe
jd�e
jd�e
jd�e
jd�d	�Zd
ZGdd�d�ZGd
d�dej�ZGdd�dej�Zedkr�ejdd�dS)zTest codecontext, coverage 100%�)�codecontextN)�requires)�Tk�Frame�Text�TclError)�mock)�config�)�mainZ	highlight�keys�
extensionsz�
class C1():
    # Class comment.
    def __init__(self, a, b):
        self.a = a
        self.b = b
    def compare(self):
        if a > b:
            return a
        elif a < b:
            return b
        else:
            return None
c@seZdZdd�ZdS)�DummyEditwincCs||_||_||_||_dS)N)�root�topZ
text_frame�text)�selfr�framer�r�G/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_codecontext.py�__init__&szDummyEditwin.__init__N)�__name__�
__module__�__qualname__rrrrrr%src@s�eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zejjejd�dd��Zdd�ZdS)�CodeContextTestcCs~td�t�}|_|j�t|�}|_t|�}|_|jdt	�|j
dddd�|j
dddd�t|||�|_t
tj_dS)NZguiz1.0�leftZboth�)ZsideZfill�expandr)rrrZwithdrawrrrr�insert�code_sampleZpackr�editor�testcfgr�idleConf�userCfg)�clsrrrrrr�
setUpClass/szCodeContextTest.setUpClasscCs@ttj_|jjjdd�|`|`|`|jj	�|jj
�|`dS)Nz1.0�end)�usercfgrr"r#r r�deleterrZupdate_idletasks�destroy)r$rrr�
tearDownClass=s

zCodeContextTest.tearDownClasscCs|jjd�tj|j�|_dS)Nr)r�yviewr�CodeContextr �cc)rrrr�setUpFszCodeContextTest.setUpcCs,|jjr|jjj�|jj�|j`|`dS)N)r-�contextr)�__del__)rrrr�tearDownJs
zCodeContextTest.tearDowncCs�|j}|j}|j}||j|�||j|j�||j|jd�|j|j�||jd
g�||j	d�||j
jjdd|jj
�dd�||j
jjdd|jj�dd�dS)N�fontrrr
F�after�infoZtimer���)rr5r
F)�assertEqualr r-Zeditwinr�textfont�assertIsNoner/r4�
topvisibler�tk�call�t1�t2)r�eqZedr-rrr�	test_initQs zCodeContextTest.test_initcCs�|jj�|jt��(}|jjjdd|jj�|jd|�WdQRX|jt��(}|jjjdd|jj	�|jd|�WdQRX|j`|j`	|jj�dS)Nr3r4z
doesn't exist)
r-r0�assertRaisesrrr:r;r<ZassertInr=)r�msgrrr�test_del_s
zCodeContextTest.test_delcCs4tjj�|j|jjddd��|j|jjd�dS)NZ	lightgrayz#000000)�
background�
foreground�)rr,�reloadr6r-�colors�
context_depth)rrrr�test_reloadls

zCodeContextTest.test_reloadcCs�|j}|j}|j}|jr|�||�d�|j|j�||jd|j�||jd|jd�||jd|jd�||jjdd�d	�||�d�|j|j�dS)
N�breakr2ZfgrDZbgrCz1.0zend-1cr
)	r6r-�toggle_code_context_eventr/ZassertIsNotNoner7rG�getr8)rr>r-Ztogglerrr�test_toggle_code_context_eventrsz.CodeContextTest.test_toggle_code_context_eventcCs.|j}|jj}|jt��|ddd�WdQRX||d�dgdf�||d�dgdf�||d	�ddgdf�||d�dddgdf�||d�dddd gdf�||ddd�d!d"d#d$gdf�||ddd�d%d&d'gdf�||ddd�d(d)gdf�||ddd�d*d+d,gdf�||ddd�d-d.gdf�dS)/Nrr)Zstopline���class C1():�class���    def __init__(self, a, b):�def�
��    def compare(self):��        if a > b:�if��        elif a < b:�elif)Z
stopindent)rOrrPrQ)rOrrPrQ)rOrrPrQ)rRrRrTrU)rOrrPrQ)rWrRrXrU)rYrYrZr[)rOrrPrQ)rWrRrXrU)rYrYrZr[)rVrYr]r^)rOrrPrQ)rWrRrXrU)rYrYrZr[)rVrYr]r^)rWrRrXrU)rYrYrZr[)rVrYr]r^)rYrYrZr[)rVrYr]r^)rWrRrXrU)rYrYrZr[)rVrYr]r^)rYrYrZr[)rVrYr]r^)r6r-Zget_contextr@�AssertionError)rr>�gcrrr�test_get_context�s:


z CodeContextTest.test_get_contextc
Cs*|j}|j}|js|j�|j|j��||jdg�||jd�|jj	d�|j�||jdg�||jd�||jj
dd�d�|jj	d�|j�||jd!d"g�||jd
�||jj
dd�d�|jj	d
�|j�||jd$d%g�||jd�||jj
dd�d�|jj	d�|j�||jd'd(d)g�||jd�||jj
dd�d�|jj	d�|j�||jd+d,d-d.d/g�||jd�||jj
dd�d�|j�d|_||jd1d2d3d4d5g�||jd�||jj
dd�d�|jj	d�|j�||jd7d8d9g�||jd�||jj
dd�d�dS):Nrrr
FrOz1.0zend-1c�class C1():rQrNrR�    def __init__(self, a, b):rUrSz)class C1():
    def __init__(self, a, b):r\rW�    def compare(self):rY�        if a > b:r[rV�        elif a < b:r^�zHclass C1():
    def compare(self):
        if a > b:
        elif a < b:�r5)rr5r
Fr5)rr5r
Fr5)rr5r
F)rOrrbrQr5)rr5r
F)rOrrbrQr5)rr5r
F)rOrrbrQ)rRrRrcrUr5)rr5r
F)rOrrbrQ)rWrRrdrU)rYrYrer[)rVrYrfr^r5)rr5r
F)rOrrbrQ)rWrRrdrU)rYrYrer[)rVrYrfr^r5)rr5r
F)rOrrbrQ)rRrRrcrU)r6r-r/rKr8�update_code_contextr4r9rr+rLrH)rr>r-rrr�test_update_code_context�slz(CodeContextTest.test_update_code_contextcCs�|j}|j}|j}|js |j�|jjd�d��|j�||jd�|jj	dd�|�||jd�|jjd�d��|j�||jd�|jj	dd�|�||jd�d|_
|jjd�d��|j�||jd�|jj	dd	�|�||jd�dS)
NrOz.0rz1.5rrgz3.0rYz1.0)r6r-Z
jumptoliner/rKrr+rir9Zmark_setrH)rr>r-Zjumprrr�test_jumptolines0zCodeContextTest.test_jumptolinericCsD|jjr|jj�|jj�|j�|jj�|jj�|j�dS)N)r-r/rKZtimer_eventZassert_not_calledZ
assert_called)rZmock_updaterrr�test_timer_event)s



z CodeContextTest.test_timer_eventcCs�|j}|j}|jd}tjj}d}ddd�}|jr:|j�||jd<|tj_|j�||j	|�||j
|�|j�||jd<|tj_|j�||j	|�||j
|�||jd|�||jd|d�||jd|d�||jd<|j�||j	|�||j
|�||jd|�||jd|d�||jd|d�||jd<|tj_|j�||j	|�||j
|�||jd|�||jd|d�||jd|d�|tj_|j�dS)Nr2ZFakeFontz#222222z#ffff00)rCrDrCrD)r6r-rrr,rGr/rKZconfig_timer_eventr7Z
contextcolors)rr>r-Z	save_fontZsave_colorsZ	test_fontZtest_colorsrrr�test_config_timer_event6sN





z'CodeContextTest.test_config_timer_eventN)rrr�classmethodr%r*r.r1r?rBrIrMrarjrkrZpatch�objectrr,rlrmrrrrr-s	
0Q!
rc@seZdZdd�Zdd�ZdS)�HelperFunctionTextc	CsJtj}d}x |D]\}}|j||�|�qW|j|d
tjd�d�d �dS)!N�    first word�    �first�	first word�	�
  ᧔᧒: �  �᧔᧒�	no spacesr
�no�# TEST COMMENT�    (continuation)z^(\s*)([^\s]*))�c�(continuation)�rrrs�rqr�rurs�rtr��rwrx�rvr��r
rz�ryr��r
r
�r
r��r
r
�r{r��rrr
�r|r�)r�r�r�r�r�r�r�)rrr~)rZget_spaces_firstwordr6�re�compile)rrLZ
test_lines�lineZexpected_outputrrr�test_get_spaces_firstwordlsz,HelperFunctionText.test_get_spaces_firstwordcCs�|j}tj}tj�}|||d�tjddf�|||d�d�|||d�tjddf�|||d	�d�|||d
�d�||d�d�dS)Nrr
Fr�class C1():rQrOz    # Class comment.rNrR�    def __init__(self, a, b):rUrWrY�        if a > b:r[�	if a == b:)rr�rQ)rRr�rU)rYr�r[)rr�r[)r6rZ
get_line_infor�
splitlinesZINFINITY)rr>Zgli�linesrrr�test_get_line_infosz%HelperFunctionText.test_get_line_infoN)rrrr�r�rrrrrpjsrp�__main__rO)�	verbosity)�__doc__ZidlelibrZunittestZtest.supportrZtkinterrrrrrr�r	r"r#r'ZIdleUserConfParserr!rrZTestCaserrprrrrrr�<module>s(?(

?>