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.10/idlelib/idle_test/__pycache__/test_sidebar.cpython-310.pyc
o

�i�g�@sdZddlmZddlZddlmZddlZddlZddlm	Z	m
Z
ddlmZddl
ZddlmZddlmZdd	lmZdd
lmZddlZddlmZmZmZddlmZddlZdd
lmZm Z Gdd�d�Z!Gdd�dej"�Z#Gdd�dej"�Z$e%dkr�ej&dd�dSdS)zTest sidebar, coverage 85%�)�dedentN)�chain)�requires�	swap_attr)�support)�run_in_tk_mainloop)�	Delegator)�
fixwordbreaks)�
Percolator)�
fix_x11_paste�PyShell�PyShellFileList)�fix_scaling)�get_end_linenumber�
get_linenoc@s$eZdZdd�Zdd�Zdd�ZdS)�
Dummy_editwincCs4||_|jj|_t|�|_t�|_|j�|j�dS�N)�textZmaster�
text_framer
�perrZundoZinsertfilter)�selfr�r�;/usr/local/lib/python3.10/idlelib/idle_test/test_sidebar.py�__init__s


zDummy_editwin.__init__cCsdSrr)r�name�valuerrr�setvar�zDummy_editwin.setvarcCstt|j�|���Sr)�int�floatr�index)rr rrr�	getlineno"�zDummy_editwin.getlinenoN)�__name__�
__module__�__qualname__rrr!rrrrrsrc@s�eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Ze�d!�d"d#��Zd$d%�Ze�d!�d&d'��Ze�d!�d(d)��Zd*d+�Zd,d-�Zd.d/�Zd0S)1�LineNumbersTestcCs�td�t��|_|j��t�|j�|_|jjtjtj	dd�|jj
ddd�|jjddd�tj|jddtj
d�|_|jjddtjd	�t|j�|_t�|j�|j_dS)
N�guiT)Zside�fill�expand�)Zweight�P�)�widthZheight�wrap)�row�columnZsticky)r�tk�Tk�root�withdrawZFramer�packZLEFTZBOTHZrowconfigureZcolumnconfigureZText�NONErZgridZNSEWr�editwinZ	ScrollbarZvbar��clsrrr�
setUpClass(s

zLineNumbersTest.setUpClasscCs4|jj��|j��|j��|`|`|`|`dSr)r7r�closer3�update�destroyrrr8rrr�
tearDownClass9s

zLineNumbersTest.tearDownClasscs�tj��j��_ddd��_tjjj���fdd�}tj	j
�tjjd|�}|����
|j�d�_�fdd	�}tj	j
�tjjd
|�}|����
|j�dS)N�#abcdef�#123456��
background�
foregroundcs|dkr�jS�||�S)N�
linenumber)�
highlight_cfg�Ztheme�element��orig_idleConf_GetHighlightrrr�mock_idleconf_GetHighlightFs
z9LineNumbersTest.setUp.<locals>.mock_idleconf_GetHighlight�GetHighlightZTkFixedFontcs�jSr)�
font_override�r3Z
configType�section�rrr�mock_idleconf_GetFontPsz4LineNumbersTest.setUp.<locals>.mock_idleconf_GetFont�GetFont)�idlelib�sidebarZLineNumbersr7rDrE�idleConfrK�unittest�mock�patch�object�start�
addCleanup�stoprL)rrJ�GetHighlight_patcherrP�GetFont_patcherrrHr�setUp@s$�

�
�zLineNumbersTest.setUpcCs|j�dd�dS�N�1.0�end)r�deleterOrrr�tearDownW�zLineNumbersTest.tearDowncCsttt|j�d���S)N�sel)�tuple�map�strrZ
tag_rangesrOrrr�
get_selectionZ�zLineNumbersTest.get_selectioncCs4|jj�|�d��}|dd}|dd}||fS)Nz.end -1cr�r*)rD�sidebar_text�bbox)r�linerm�x�yrrr�get_line_screen_position]sz(LineNumbersTest.get_line_screen_positioncCs&|jj��d}|�|dtj�dS)N�state���)rDrl�config�assertEqualr1ZDISABLED)rrrrrr�assert_state_disabledcsz%LineNumbersTest.assert_state_disabledcCs|jj�dtj�S)Nr`)rDrl�getr1ZENDrOrrr�get_sidebar_text_contentsgrdz)LineNumbersTest.get_sidebar_text_contentsc	Cs6d�ttttd|d��dg��}|�|��|�dS)N�
r*�)�joinrrgrh�rangerurx)rZn_lines�expectedrrr�assert_sidebar_n_linesjs"z&LineNumbersTest.assert_sidebar_n_linescCs|�|j�dd�|�Sr_)rurrw)rr}rrr�assert_text_equalsnrjz"LineNumbersTest.assert_text_equalscCs|�d�dS�Nr*)r~rOrrr�test_init_emptyqszLineNumbersTest.test_init_emptycCs&|j�dd�|�d�|�d�dS)N�insertzfoo bar
foo bar
foo bar
zfoo bar
foo bar
foo bar

�)rr�rr~rOrrr�test_init_not_emptyts
z#LineNumbersTest.test_init_not_emptycCs�|�|jjd�|j��|�|jjd�|j��|�|jjd�|j��|�|jjd�|j��|�|jjd�|j��|�|jjd�dS)NFT)rurDZis_shown�show_sidebar�hide_sidebarrOrrr�test_toggle_linenumberingys




z)LineNumbersTest.test_toggle_linenumberingcCs�|j�dd�|�d�|�d�|��|j�dd�|�d�|�d�|��|j�dd�|�d	�|�d
�|��|j�dd�|�d�|�d
�|��dS)Nr��foobar�foobar
r*z
foozfoobar
foo
rkzhello
hello
zfoobar
foohello
hello

r�z
worldzfoobar
foohello
hello

world
�)rr�rr~rvrOrrr�test_insert�s 







zLineNumbersTest.test_insertcCs�|j�dd�|�d�|j�dd�|�d�|�d�|��|j�dd�|�d	�|�d
�|��|j�dd�|�d
�|�d
�|��|j�dd�|�d�|�d�|��|j�dd�|�d�|�d�|��dS)Nr�r�r�z1.1z1.3zfbar
r*zfoo
foo
z
fbarfoo
foo

��2.0z2.endz
fbarfoo


razfba
r`ry)rr�rrbr~rvrOrrr�test_delete�s,










zLineNumbersTest.test_deletecs<�fdd�}��d���|�d��j�dd���d���|�d��j�dd���d���|�d��j�dd���d	���|�d
��j�dd���d���|�d
��j�dd
���d	���|�d
��j�dd
���d���|�d��j�dd���d���|�d
��j�dd���d���|�d��j�dd���d���|�d��j�dd
���d���|�d��j�dd
���d���|�d
��j�dd���d���|�d
��j�dd���d���|�d��j�dd���d���|�d�dS)zY
        Test that linenumber text widget is always at the minimum
        width
        cs�jj��ddS)Nr-rs)rDrlrtrrOrr�	get_width�r"z:LineNumbersTest.test_sidebar_text_width.<locals>.get_widthr*r�Zfooz foo
foo
foo
foo
foo
foo
foo
foo
�	zfoo
�
rk�zinsert -1l linestartzinsert linestartahfoo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
�c�dr��ez50.0 -1czend -1c�1z5.0 -1cr�r`N)r~rurr�rb)rr�rrOr�test_sidebar_text_width�sZ














z'LineNumbersTest.test_sidebar_text_widthz
test disabledcCsn|j��|j�dd�|j��|�d�\}}|jjjd||d�|jj��|j��|�	|�
�d�dS)Nr`zone
two
three
four
rk�
<Button-1>�rorp)r�z3.0)rDr�rr�r3r<rqrl�event_generateruri)rrorprrr�test_click_selections


z$LineNumbersTest.test_click_selectionc
	Cs�|�|�\}}|�|�\}}|jjjd||d�|j��dd�}ttt|||dd��tt|||dd���D]\}}	|jjjd||	d�|j��q6|jjjd||d�|j��dS)	Nr�r�css:�|d}t|�D]}|||||||Vq	dS)z;linearly interpolate from a to b (inclusive) in equal stepsr*N)r|)�a�b�stepsZ	last_step�irrr�lerps
� �z+LineNumbersTest.simulate_drag.<locals>.lerpr�)r�z<B1-Motion>z<ButtonRelease-1>)	rqrDrlr�r3r<�ziprgr)
rZ
start_lineZend_lineZstart_xZstart_yZend_xZend_yr�rorprrr�
simulate_drags"
�
�
�zLineNumbersTest.simulate_dragcC�B|j��|j�dd�|j��|�dd�|�|��d�dS)Nr`�one
two
three
four
five
rkr��r�z5.0�	rDr�rr�r3r<r�rurirOrrr�test_drag_selection_down+�


z(LineNumbersTest.test_drag_selection_downcCr�)Nr`r�r�rkr�r�rOrrr�test_drag_selection_up5r�z&LineNumbersTest.test_drag_selection_upcCs�|j��|j�dd�|j��|j�dd�|j��|�|j�d�d�|�|jj	�d�d�|jj	j
ddddd	�|j��|�|j�d�d�|�|jj	�d�d�dS)
Nr`a�line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
line
r�Zunit�@0,0z11.0�<MouseWheel>r�rorp�delta)rDr�rr�r3r<Zyview_scrollrur rlr��assertNotEqualrOrrr�test_scroll?s



�
zLineNumbersTest.test_scrollcCst|j}|jd}d}|�||�|��||_|��|��|�|jd|�||_|��|�|jd|�dS)N�font�
TkTextFont)rDrlr�r�rL�update_fontr�ru)r�lnZ	orig_font�	test_fontrrrr�Ts
zLineNumbersTest.test_fontcsx�j�t�j�}ddd�}��fdd�}���|�_������||����||�|�_���||�dS)Nz#222222z#ffff00rAcs0���jd|d����jd|d�dS)NrBrC)rurl)Zcolors�r�rrr�assert_colors_are_equalqszFLineNumbersTest.test_highlight_colors.<locals>.assert_colors_are_equal)rD�dictrEr��
update_colorsr�)rZorig_colors�test_colorsr�rr�r�test_highlight_colorsks

z%LineNumbersTest.test_highlight_colorsN)r#r$r%�classmethodr:r>r^rcrirqrvrxr~rr�r�r�r�r�r�rU�skipr�r�r�r�r�r�r�rrrrr&&s:


K


	
	r&c@s<eZdZUdZejed<dZeed<e	dd��Z
e	dd��Ze	dd	��Ze	d
d��Z
dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Ze�dd��Ze�d d!��Ze�d"d#��Ze�d$d%��Ze�d&d'��Ze�d(d)��Ze�d*d+��Zd,d-�Zd.d/�Z e�d0d1��Z!e�d2d3��Z"e�d4d5��Z#dS)6�ShellSidebarTestNr3�shellcCsXtd�t��|_}|��t|�t|�t|�t|�|_	}|�
�|��dS)Nr')rr1r2r3r4rr	rr
�flist�update_idletasks�
init_shell)r9r3r�rrrr:�szShellSidebarTest.setUpClasscCsF|jdurd|j_|j��d|_d|_|j��|j��d|_dS)NF)r�Z	executingr;r�r3r�r=r8rrrr>�s




zShellSidebarTest.tearDownClasscCs6|j��|_d|j_|j��t|jjd�d|_dS)Nr��end-1cr*)	r�Z
open_shellr�Zpollintervalr3r<rr�n_preface_linesr8rrrr��s
zShellSidebarTest.init_shellcCs8|jjj�|jd�d�d�|jj��|j��dS)Nr*�.0r�)	r�rZbottomrbr��
shell_sidebar�update_sidebarr3r<r8rrr�reset_shell�szShellSidebarTest.reset_shellcCs2d|_tj|jjkrtj|_|jjt_|��dSr)�
_saved_stdout�sys�stdoutr�r�rOrrrr^�s

zShellSidebarTest.setUpcCs|jdur|jt_dSdSr)r�r�r�rOrrrrc�s
�zShellSidebarTest.tearDowncsF|jjj�t��tj��}�fdd�|D��|��}�fdd�|D�S)Ncs$i|]}��|�d��|d��qS)r*r)rm�itemcget��.0r��canvasrr�
<dictcomp>�s��z6ShellSidebarTest.get_sidebar_lines.<locals>.<dictcomp>csg|]}��|d��qSr)rw)r�rp)�texts_by_y_coordsrr�
<listcomp>��z6ShellSidebarTest.get_sidebar_lines.<locals>.<listcomp>)r�r�r��list�findr1�ALL�get_shell_line_y_coords)r�textsZ
line_y_coordsr)r�r�r�get_sidebar_lines�s

�z"ShellSidebarTest.get_sidebar_linescCs.|jj��|�|��t|�d�|�dSr)r�r�r�rur��len)rZexpected_linesrrr�assert_sidebar_lines_end_with�s
�z.ShellSidebarTest.assert_sidebar_lines_end_withcCs�|jj}g}|�d�}|�dd�ddkr|�|�d��}|�|�}dur>|�|d�|�|�d��}|�|�}dus&|S)Nr��.r*�0z +1line linestartz +1line)r�rr �split�	dlineinfo�append)rrZy_coordsr Zlineinforrrr��s
�z(ShellSidebarTest.get_shell_line_y_coordscs@|jjj�t��tj��}|j�fdd�d��fdd�|D�S)Ncs��|�dSr��rm)rr�rr�<lambda>�sz<ShellSidebarTest.get_sidebar_line_y_coords.<locals>.<lambda>)�keycsg|]	}��|�d�qS)r*r�r�r�rrr��sz>ShellSidebarTest.get_sidebar_line_y_coords.<locals>.<listcomp>)r�r�r�r�r�r1r��sort)rr�rr�r�get_sidebar_line_y_coords�s
z*ShellSidebarTest.get_sidebar_line_y_coordscCs |�t|���t|����dSr)ZassertLessEqual�setr�r�rOrrr�assert_sidebar_lines_synced�s

�z,ShellSidebarTest.assert_sidebar_lines_syncedcCsH|j}|j}t|�d��D]\}}|dkr|�d�|�d|d�q
dS)Nryr�<<newline-and-indent>>r��stdin)r�r�	enumerater�r�r�)r�inputr�rZ
line_indexrnrrr�do_input�s
�zShellSidebarTest.do_inputcCs4|��}|�|dgt|�ddg�|��dS)Nr*�>>>)r�rur�r�)rZ
sidebar_linesrrr�test_initial_state�s�z#ShellSidebarTest.test_initial_stateccs$�|�d�dV|�ddg�dS)Nryr��r�r�rOrrr�test_single_empty_input���
z(ShellSidebarTest.test_single_empty_inputccs$�|�d�dV|�gd��dS)Nz1
�r�Nr�r�rOrrr�test_single_line_statementr�z+ShellSidebarTest.test_single_line_statementccs(�|�td��dV|�gd��dS)N�7            if True:
            print(1)

            �r��...r�r�Nr�)r�rr�rOrrr�test_multi_line_statements�z*ShellSidebarTest.test_multi_line_statementccs,�|�d�dV|�gd��|��dS)Nz�11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
r�)r�r�r�rOrrr�test_single_long_line_wrapss
�
z,ShellSidebarTest.test_single_long_line_wrapsccs��|j}|j}|�d�dV|�gd��|�dd�|�d�dV|�gd��|��|jjd�	�dV|�gd��|��dS)Nzprint("a\nb\nc")
)r�NNNr�r�zinsert -1line linestartz<<squeeze-current-text>>r�r)
r�rr�r��mark_setr�r��squeezerZexpandingbuttonsr))rr�rrrr�test_squeeze_multi_line_output$s�

z/ShellSidebarTest.test_squeeze_multi_line_outputccs�|jj}|��}|�td��dV|�gd��|��}|�||�|�d�dV|�gd��|�d�|�d�dV|�gd��|�d|�	d��|�d	�dV|�d
�dV|�dg�|�d�dV|�dd
g�|�d	�|�d	�dV|�gd��dS)Nz6            if True:
            print(1)
            )r�r�r�z<<interrupt-execution>>)r�r�r�Nr�z<<history-previous>>)r�r�Nr�r�z
insert -2lr�z<<undo>>r�z<<redo>>r�r�)
r�rr�r�rr�r�r�r�r )rrZinitial_sidebar_linesZwith_block_sidebar_linesrrr�test_interrupt_recall_undo_redo8s<�







�z0ShellSidebarTest.test_interrupt_recall_undo_redoc	cs��t�d��?t|jdd��|�dddd�dV|�|��dg�Wd�n1s0wYWd�dSWd�dS1sHwYdS)Nig+r�zx = �1i'ryr�)rZadjust_int_max_str_digitsrr�r�rur�rOrrr�test_very_long_wrapped_linefs��P�z,ShellSidebarTest.test_very_long_wrapped_linecs��jj�d��fdd�}tjj�tjjd|����	���fdd�}��
|���fdd�}��|��������
|���dS)	Nr�cs�SrrrM)r�rrrPsrz9ShellSidebarTest.test_font.<locals>.mock_idleconf_GetFontrQc�������dSr)r[r�r)r]rSrr�cleanupx�z+ShellSidebarTest.test_font.<locals>.cleanupcsD�j�t��tj��}�fdd�|D�}��t|�d�tt|��S)Nc�h|]}��|d��qS)r��r�r�r�rr�	<setcomp>�r�zGShellSidebarTest.test_font.<locals>.get_sidebar_font.<locals>.<setcomp>r*)	r�r�r�r1r�rur��next�iter)r�Zfonts�rrSr�r�get_sidebar_font}s
z4ShellSidebarTest.test_font.<locals>.get_sidebar_font)r�r�rUrVrWrXrRrSrTrYrZr�r�ru)rrPrrr)r]rrSr�rr�ns
�
zShellSidebarTest.test_fontcs��jj�ddd��tjjj���fdd�}tjj�	tjjd|����
���fdd�}��|���fd	d
�}��|�����
���|���dS)Nr?r@rAcs|dvr�S�||�S)N)rDZconsolerrF)rIr�rrrJ�s
zJShellSidebarTest.test_highlight_colors.<locals>.mock_idleconf_GetHighlightrKcr�r)r[r�r)r\rSrrr�rz7ShellSidebarTest.test_highlight_colors.<locals>.cleanupcsX�j�t��tj��}�fdd�|D�}��t|�d�tt|��}��	d�}||d�S)Ncr)r(rr�r�rrr�r�zUShellSidebarTest.test_highlight_colors.<locals>.get_sidebar_colors.<locals>.<setcomp>r*rBrA)
r�r�r�r1r�rur�rrZcget)r�ZfgsZfg�bgrr�r�get_sidebar_colors�s

zBShellSidebarTest.test_highlight_colors.<locals>.get_sidebar_colors)r�r�rRrSrTrKrUrVrWrXrYrZr�r�ru)rrJrr
r)r\rIrrSr�rr��s

�
	z&ShellSidebarTest.test_highlight_colorsccs��|jj}|jj}|�d�dV|�t|d�d�t|�}|�|�|�	|�d����t
jdkr3dnd}|jj
dd	d	|d
�dV|�|�|�	|�d����|jj
dd	d	d�dV|�|�|�	|�d����dS)
Nzox = """



































































































"""
r�r*r��darwinrs�xr�rr�z
<Button-5>r�)r�r�rr�Z
assertGreaterrrZassertIsNotNoner�r r��platformr�r�ZassertIsNone)rrSrZlast_linenor�rrr�test_mousewheel�s�
 z ShellSidebarTest.test_mousewheelccs��|jj}|jj}t|�}|�td��dV|�d|�d�d�|�dd�}|�|�	d��|�
d|�|�d	�|�|j
�|��}|�||�dS)
Nr�rer�r��	sel.first�sel.lastz	if True:
z
1
z<<copy>>)r�r�rrr�r�tag_addrw�
assertTrue�
startswithZassertInr�rZ�clipboard_clear�
clipboard_getru)rrSr�
first_line�
selected_text�copied_textrrr�	test_copy�s�
zShellSidebarTest.test_copyc
cs��|jj}|jj}t|�}|�td��dV|�d|�d�d�|�dd�}|�|�	d��|�dd�}|�
d	�}|��d
gdgt|�ddg}d	�
d
d�t||dd�D��d	}|�d�|�|j�|��}	|�|	|�dS)Nz;            if True:
                print(1)

            rez.3r�rrzTrue:
zsel.first linestartryr�r�rkcss,�|]\}}|dur|n|d|VqdS)N� r)r��promptrnrrr�	<genexpr>�s
��
�z:ShellSidebarTest.test_copy_with_prompts.<locals>.<genexpr>T)�strictz<<copy-with-prompts>>)r�r�rrr�rrrwrrr��popr�r{r�r�rZrrru)
rrSrrrZselected_lines_textZselected_linesZexpected_promptsZselected_text_with_promptsrrrr�test_copy_with_prompts�s4�
�
���
z'ShellSidebarTest.test_copy_with_prompts)$r#r$r%r3r1r2�__annotations__r�rr�r:r>r�r�r^rcr�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�rrrrrrrr��sT












-
 

r��__main__rk)�	verbosity)'�__doc__�textwraprr��	itertoolsrrUZ
unittest.mockZtest.supportrr�testr�tkinterr1Z'idlelib.idle_test.tkinter_testing_utilsrZidlelib.delegatorrZidlelib.editorr	Zidlelib.percolatorr
Zidlelib.pyshellrRrrr
Zidlelib.runrZidlelib.sidebarrrrZTestCaser&r�r#�mainrrrr�<module>s8fw�