HEX
Server: Apache
System: Linux p3plzcpnl506847.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: slfopp7cb1df (5698090)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/python38/lib/python3.8/idlelib/idle_test/__pycache__/test_codecontext.cpython-38.pyc
U

�i�_�>�@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�A/opt/python38/lib/python3.8/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)NZgui�1.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)Nr$�end)�usercfgrr0r1r.r�deleterrZupdate_idletasks�destroy)r2rrr�
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)Ztheme�element�Zorig_idleConf_GetHighlightrrr�mock_idleconf_GetHighlightVsz9CodeContextTest.setUp.<locals>.mock_idleconf_GetHighlight�GetHighlightcs�jSr)�
font_override)rZ
configType�section�rrr�mock_idleconf_GetFont`sz4CodeContextTest.setUp.<locals>.mock_idleconf_GetFontZGetFont)r�yviewr�CodeContextr.�ccr>r0rB�unittestr	�patch�object�startZ
addCleanup�stoprC)rrAZGetHighlight_patcherrFZGetFont_patcherrr@r�setUpNs0
���zCodeContextTest.setUpcCs,|jjr|jj��|j��|j`|`dSr)rIr=r7�__del__rErrr�tearDowngs
zCodeContextTest.tearDowncCsz|j}|j}|j}||j|�||j|j�||jd|jd�|�|j�||jdg�||jd�|�|jj	�dS)Nr9�r���rFr&)
�assertEqualr.rI�editwinr�assertIsNoner=�info�
topvisible�t1)r�eqZedrIrrr�	test_initnszCodeContextTest.test_initcCs|j��dSr)rIrPrErrr�test_del{szCodeContextTest.test_delc	Csb|j�ddd��}|j_|j��|�t��}|jj�	dd|�W5QRX|�
dt|j��dS)Ni'cSsdSrrrrrr�<lambda>�z5CodeContextTest.test_del_with_timer.<locals>.<lambda>�afterrWz
doesn't exist)
rr_rIrYrP�assertRaisesrr�tk�callZassertIn�str�	exception)r�timer�cmrrr�test_del_with_timer~s

z#CodeContextTest.test_del_with_timercCstj��|�|jjd�dS)N�)rrH�reloadrTrI�
context_depthrErrr�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)Nr9Zfgr<�bgr;r$�end-1crzHide Code Contextr_rWr&rezShow Code Context�
css|]}|dVqdS)�Nr)�.0�xrrr�	<genexpr>�szACodeContextTest.test_toggle_code_context_event.<locals>.<genexpr>�r)rTrI�toggle_code_context_eventr=ZassertIsNotNonerr>�getrUrrrarbrYrV�join�get_contextrG)rrZrIZtoggleZline11_contextrrr�test_toggle_code_context_event�s0 z.CodeContextTest.test_toggle_code_context_eventc	Cs.|j}|jj}|�t��|ddd�W5QRX||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��ror�class C1():�class���r}r}�    def __init__(self, a, b):�def�
��r}z    def compare(self):r���r��        if a > b:�ifrs�r�r�z        elif a < b:�elifror�)Z
stopindent)rTrIrwr`�AssertionError)rrZ�gcrrr�test_get_context�sj
��
��
������������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)NrRr&ror$rmrrzryr{r}rr~z)class C1():
    def __init__(self, a, b):rsr�r�r��zHclass C1():
    def compare(self):
        if a > b:
        elif a < b:�r�)rTrIr=rtrV�update_code_contextrWrXrrGrurj)rrZrIrrr�test_update_code_context�st����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.0ror+z1.5r&z12.0r�z3.0r�r$z5.0Zselr~)rTrIZ
jumptoliner=rtrrGr�rXZmark_setrjZtag_add)rrZrIZjumprrr�test_jumptoline.s<zCodeContextTest.test_jumptoliner�cCsD|jjr|j��|j��|��|j��|j��|��dSr)rIr=rtZtimer_eventZassert_not_calledZ
assert_called)rZmock_updaterrr�test_timer_eventWs



z CodeContextTest.test_timer_eventcCs�|j}|j}|jd}d}|�||�|jdk	r8|��||_|��|��||jd|�||_|��||jd|�dS)Nr9Z
TkTextFont)rTrIrZassertNotEqualr=rtrCZupdate_font)rrZrIZ	orig_font�	test_fontrrrr�ds

zCodeContextTest.test_fontcs�|j�|j�t|j�}ddd�}��fdd�}�jr<���||_������||����||�||_���||�dS)Nz#222222z#ffff00r:cs,��jd|d���jd|d�dS)Nr;r<)r=)Zcolors�rIrZrr�assert_colors_are_equal�szFCodeContextTest.test_highlight_colors.<locals>.assert_colors_are_equal)rTrI�dictr>r=rtZupdate_highlight_colors)rZorig_colorsZtest_colorsr�rr�r�test_highlight_colors}s 

z%CodeContextTest.test_highlight_colorsN)r r!r"�classmethodr3r8rOrQr[r\rgrkrxr�r�r�r	rKrLrrHr�r�r�rrrrr#5s$



$0Q)
r#c@seZdZdd�Zdd�ZdS)�HelperFunctionTextcCsFtj}d}|D]\}}|�||�|�q|�|dt�d�d�d�dS)N))z    first word)�    �first)z	first word)�	r�)u
  ᧔᧒: )z  u᧔᧒)z	no spaces)r�no)r�rr)z# TEST COMMENTr�)�    (continuation))r�rr�z^(\s*)([^\s]*))�c)r�z(continuation))rZget_spaces_firstwordrT�re�compile)rruZ
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&)rr{r|roz    # Class comment.ry)r}r�r�r�)r�r�r��	if a == b:)r&r�r�)rTrZ
get_line_infor,�
splitlinesZINFINITY)rrZZgli�linesrrr�test_get_line_info�sz%HelperFunctionText.test_get_line_infoN)r r!r"r�r�rrrrr��sr��__main__ro)�	verbosity)�__doc__ZidlelibrrJZ
unittest.mockZtest.supportr�tkinterrrrrrr	r�r
r0r1r5ZIdleUserConfParserr/r,rZTestCaser#r�r rrrrr�<module>s,�k(