HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/idlelib/idle_test/__pycache__/test_codecontext.cpython-37.pyc
B

!��g�>�@s�dZddlmZddlZddlZddlmZddlmZm	Z	m
Z
mZmZddlm
Z
ddlZddlmZejjZe�d�e�d�e�d�e�d�d	�Zd
ZGdd�d�ZGd
d�dej�ZGdd�dej�Zedkr�ejdd�dS)zTest codecontext, coverage 100%�)�codecontextN)�requires)�NSEW�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@s$eZdZdd�Zdd�Zdd�ZdS)�DummyEditwincCs"||_||_||_||_d|_dS)Nr)�root�topZ
text_frame�text�label)�selfr�framer�r�>/usr/local/lib/python3.7/idlelib/idle_test/test_codecontext.py�__init__'s
zDummyEditwin.__init__cCstt|j�|���S)N)�int�floatr�index)rrrrr�	getlineno.szDummyEditwin.getlinenocKs|d|_dS)Nr)r)r�kwargsrrr�update_menu_label1szDummyEditwin.update_menu_labelN)�__name__�
__module__�__qualname__rrrrrrrr&src@s�eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zej�ejd�dd��Zdd�Zdd�Zd S)!�CodeContextTestcCs~td�t�}|_|��t|�}|_t|�}|_|�dt	�|j
dddd�|jddtd�t
|||�|_ttj_dS)NZguiz1.0�leftZboth�)Zside�fill�expand)�row�columnZsticky)rrrZwithdrawrrrr�insert�code_sample�packZgridrr�editor�testcfgr�idleConf�userCfg)�clsrrrrrr�
setUpClass7szCodeContextTest.setUpClasscCs@ttj_|jj�dd�|`|`|`|j�	�|j�
�|`dS)Nz1.0�end)�usercfgrr.r/r,r�deleterrZupdate_idletasks�destroy)r0rrr�
tearDownClassEs

zCodeContextTest.tearDownClasscs��j�d�d�jd<t��j��_ddd��_tjj���fdd�}t	j
j�tjd	|�}|�
���|j�d�_�fd
d�}t	j
j�tjd|�}|�
���|j�dS)
NrZTkFixedFont�fontz#abcdefz#123456)�
background�
foregroundcs|dkr�jS�||�S)N�context)�
highlight_cfg)ZthemeZelement)�orig_idleConf_GetHighlightrrr�mock_idleconf_GetHighlightVsz9CodeContextTest.setUp.<locals>.mock_idleconf_GetHighlight�GetHighlightcs�jS)N)�
font_override)rZ
configType�section)rrr�mock_idleconf_GetFont`sz4CodeContextTest.setUp.<locals>.mock_idleconf_GetFontZGetFont)r�yviewr�CodeContextr,�ccr;r.r>�unittestr	�patch�object�startZ
addCleanup�stopr?)rr=ZGetHighlight_patcherrAZGetFont_patcherr)r<rr�setUpNs"

zCodeContextTest.setUpcCs,|jjr|jj��|j��|j`|`dS)N)rDr:r5�__del__)rrrr�tearDowngs
zCodeContextTest.tearDowncCsz|j}|j}|j}||j|�||j|j�||jd|jd�|�|j�||jdg�||jd�|�|jj	�dS)Nr7)r���rFr$)
�assertEqualr,rD�editwinr�assertIsNoner:�info�
topvisible�t1)r�eqZedrDrrr�	test_initnszCodeContextTest.test_initcCs|j��dS)N)rDrK)rrrr�test_del{szCodeContextTest.test_delc	Csb|j�ddd��}|j_|j��|�t��}|jj�	dd|�WdQRX|�
dt|j��dS)Ni'cSsdS)Nrrrrr�<lambda>�z5CodeContextTest.test_del_with_timer.<locals>.<lambda>�afterrQz
doesn't exist)
rrYrDrSrK�assertRaisesrr�tk�callZassertIn�strZ	exception)r�timer�cmrrr�test_del_with_timer~s

z#CodeContextTest.test_del_with_timercCstj��|�|jjd�dS)N�)rrC�reloadrNrD�
context_depth)rrrr�test_reload�s
zCodeContextTest.test_reloadcCsJ|j}|j}|j}|jr|�|�|�|j�||jd|jd�||jd|jd�||jd|jd�||j�dd�d�||jj	d	�||j
j�d
d|jj
�dd
�|�|�|j�||jj	d�|�|jj
�d�dd�|�d�dD��}|j�d�|�||j�dd�|�|�|�||j�dd�|�dS)Nr7Zfgr9�bgr8z1.0zend-1crzHide Code ContextrYrQr$r^zShow Code Context�
css|]}|dVqdS)�Nr)�.0�xrrr�	<genexpr>�szACodeContextTest.test_toggle_code_context_event.<locals>.<genexpr>�r)rNrD�toggle_code_context_eventr:ZassertIsNotNonerr;�getrOrrr[r\rSrP�join�get_contextrB)rrTrDZtoggleZline11_contextrrr�test_toggle_code_context_event�s0 z.CodeContextTest.test_toggle_code_context_eventc	Cs.|j}|jj}|�t��|ddd�WdQRX||d�dgdf�||d�dgdf�||d�ddgdf�||d	�dd
dgdf�||d�dd
dd
gdf�||ddd�dd
dd
gdf�||ddd�d
dd
gdf�||ddd�dd
gdf�||ddd�d
dd
gdf�||ddd�dd
gdf�dS)Nr$r)Zstopline�)rgrzclass C1():�class��)rsrsz    def __init__(self, a, b):�def�
)�rsz    def compare(self):ru)�rxz        if a > b:�ifrk)rvrxz        elif a < b:�elifrgrx)Z
stopindent)rNrDrorZ�AssertionError)rrTZgcrrr�test_get_context�s:


z CodeContextTest.test_get_contextcCs*|j}|j}|js|��|�|���||jdg�||jd�|j�	d�|��||jdg�||jd�||j�
dd�d�|j�	d�|��||jddg�||jd�||j�
dd�d	�|j�	d�|��||jddg�||jd
�||j�
dd�d	�|j�	d
�|��||jdddg�||jd�||j�
dd�d
�|j�	d�|��||jdddddg�||jd�||j�
dd�d�|��d|_||jdddddg�||jd�||j�
dd�d�|j�	d�|��||jdddg�||jd�||j�
dd�d�dS)N)rrMrFr$rgz1.0zend-1cr)rgrzclass C1():rrrqzclass C1():rs)rsrsz    def __init__(self, a, b):rurtz)class C1():
    def __init__(self, a, b):rk)rwrsz    def compare(self):ru)rxrxz        if a > b:ry)rvrxz        elif a < b:rz�zHclass C1():
    def compare(self):
        if a > b:
        elif a < b:�z    def __init__(self, a, b):)rNrDr:rlrP�update_code_contextrQrRrrBrmrc)rrTrDrrr�test_update_code_context�slz(CodeContextTest.test_update_code_contextcCs.|j}|j}|j}|js |��|j�d�|��||jd�|j�	dd�|�||jd�|j�d�|��||jd�|j�	dd�|�||jd	�d|_
|j�d�|��||jd�|j�	dd
�|�||jd	�|j�d�|��|j�dd
d�|j�	dd
�|�||jd
�dS)Nz2.0rgr)z1.5r$z12.0r}z3.0rxz1.0z5.0Zselrt)rNrDZ
jumptoliner:rlrrBrrRZmark_setrcZtag_add)rrTrDZjumprrr�test_jumptoline.s<zCodeContextTest.test_jumptolinercCsD|jjr|j��|j��|��|j��|j��|��dS)N)rDr:rlZtimer_eventZassert_not_calledZ
assert_called)rZmock_updaterrr�test_timer_eventWs



z CodeContextTest.test_timer_eventcCs�|j}|j}|jd}d}|�||�|jdk	r8|��||_|��|��||jd|�||_|��||jd|�dS)Nr7Z
TkTextFont)rNrDrZassertNotEqualr:rlr?Zupdate_font)rrTrDZ	orig_font�	test_fontrrrr�ds

zCodeContextTest.test_fontcs�|j�|j�t|j�}ddd�}��fdd�}�jr<���||_������||����||�||_���||�dS)Nz#222222z#ffff00)r8r9cs,��jd|d���jd|d�dS)Nr8r9)r:)Zcolors)rDrTrr�assert_colors_are_equal�szFCodeContextTest.test_highlight_colors.<locals>.assert_colors_are_equal)rNrD�dictr;r:rlZupdate_highlight_colors)rZorig_colorsZtest_colorsr�r)rDrTr�test_highlight_colors}s 

z%CodeContextTest.test_highlight_colorsN)rr r!�classmethodr1r6rJrLrUrVr`rdrpr|r�r�r	rFrGrrCr�r�r�rrrrr"5s	
$0Q)
r"c@seZdZdd�Zdd�ZdS)�HelperFunctionTextcCsJtj}d}x |D]\}}|�||�|�qW|�|dt�d�d�d�dS)N))z    first word)z    �first)z	first word)�	r�)u
  ᧔᧒: )z  u᧔᧒)z	no spaces)r�no)r)rr)z# TEST COMMENT)rr)z    (continuation))z    rz    (continuation)z^(\s*)([^\s]*))�c)z    z(continuation))rZget_spaces_firstwordrN�re�compile)rrmZ
test_lines�lineZexpected_outputrrr�test_get_spaces_firstword�sz,HelperFunctionText.test_get_spaces_firstwordcCs�|j}tj}t��}|||d�tjddf�|||d�d�|||d�tjddf�|||d�d	�|||d
�d�||d�d
�dS)NrrFr$)rzclass C1():rrrgz    # Class comment.rq)rsz    def __init__(self, a, b):rurw)rxz        if a > b:ryz	if a == b:)r$z	if a == b:ry)rNrZ
get_line_infor*�
splitlinesZINFINITY)rrTZgli�linesrrr�test_get_line_info�sz%HelperFunctionText.test_get_line_infoN)rr r!r�r�rrrrr��sr��__main__rg)�	verbosity)�__doc__ZidlelibrrEZ
unittest.mockZtest.supportrZtkinterrrrrrr	r�r
r.r/r3ZIdleUserConfParserr-r*rZTestCaser"r�rrrrrr�<module>s*k(