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_config.cpython-310.opt-2.pyc
o

�i.}�@sN	ddlmZddlZddlZddlZddlmZmZddlZddlm	Z	ddlZddl
mZejZej
ZiZe�d�Zed<e�d�Zed<e�d�Zed	<e�d�Zed
<dd�Zd
d�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zedkr�ejdd�dSdS)�)�configN)�captured_stderr�findfile)�mock)�Func��main�	highlight�keys�
extensionscC�tt_dt_dS)NT)�testcfg�idleConf�userCfg�idlelib�testing�rr�:/usr/local/lib/python3.10/idlelib/idle_test/test_config.py�setUpModule�
rcCr)NF)�usercfgrrrrrrrr�tearDownModule!rrc@s2eZdZ	dZdd�Zdd�Zdd�Zdd	�Zd
S)�IdleConfParserTestz�
        [one]
        one = false
        two = true
        three = 10

        [two]
        one = a string
        two = true
        three = false
    cCs�t�d�}|�|j�|j}|�|jdddd�d�|�|jdddd�d�||jddd	d�d
�||�dd�d�|�|jdddd�d�|�|jdddd�d�||�dd�d�||�dd�d
�|�|�dd��||jdddd�d�dS)Nr�one�bool��typeF�twoT�three�int�
za string�true�false�notZexistZDEFAULT��default)r�IdleConfParser�read_string�assertEqualZassertIs�GetZassertIsNone)�self�parser�eqrrr�test_get5s
zIdleConfParserTest.test_getcCsXt�d�}|�|j�|j}|�|d�gd��|�|d�gd��|�|d�g�dS)Nrr)rrrrz	not exist)rr&r'�
GetOptionList�assertCountEqualr()r*r+Zget_listrrr�test_get_option_listJs
z'IdleConfParserTest.test_get_option_listcCs&t�d�}|��|�|��g�dS)Nr)rr&�Loadr(�sections�r*r+rrr�test_load_nothingRs
z$IdleConfParserTest.test_load_nothingcCsFtd�}t�|�}|��|�|�dd�d�|�|�d�dg�dS)N�cfgparser.1�Foo Bar�foo�newbar)rrr&r1r(r)r.)r*�config_pathr+rrr�test_load_fileWs

z!IdleConfParserTest.test_load_fileN)�__name__�
__module__�__qualname__rr-r0r4r:rrrrr&src@sHeZdZ	ddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�IdleUserConfParserTestrcCs
t�|�S�N)r�IdleUserConfParser)r*�pathrrr�
new_parserds
z!IdleUserConfParserTest.new_parsercCs�|��}|�d�|�|�ddd��|�|�ddd��|�|�ddd��|�|�dd�d�|�|�ddd��|�|��ddg�|�|�dd�d�dS)N�Foo�barr!r"�Bar)	rB�add_section�
assertTrue�	SetOption�assertFalser(r)r/r2r3rrr�test_set_optiongs
z&IdleUserConfParserTest.test_set_optioncCsZ|��}|�d�|�ddd�|�|�dd��|�|�dd��|�|�dd��dS)NrCrDr!ZNotZExist)rB�
AddSectionrHrGZRemoveOptionrIr3rrr�test_remove_optionws
z)IdleUserConfParserTest.test_remove_optioncCsN|��}|�|��g�|�d�|�d�|�d�|�|��ddg�dS)NrCrE)rBr(r2rKr/r3rrr�test_add_section�s


z'IdleUserConfParserTest.test_add_sectioncCs\|��}|�d�|�d�|�ddd�|�|��gd��|��|�|��dg�dS)NrCrE�Idle�name�val)rErCrN)rBrKrHr/r2ZRemoveEmptySectionsr(r3rrr�test_remove_empty_sections�s

z1IdleUserConfParserTest.test_remove_empty_sectionscCsv|��}|�d�|�d�|�|���|�|��g�|�ddd�|�d�|�|���|�|��dg�dS)NrCrErDr")	rBrKrGZIsEmptyr(r2rHrIr/r3rrr�
test_is_empty�s


z$IdleUserConfParserTest.test_is_emptycCs�t���I}tj�|d�}|�|�}|�d�|�ddd�|�tj�	|��|�
�|�tj�	|��|�d�|�
�|�tj�	|��Wd�dS1sPwYdS)Nztest.cfgrCrDr!)
�tempfile�TemporaryDirectory�osrA�joinrBrKrHrI�existsZSaverG�remove_section)r*ZtdirrAr+rrr�	test_save�s



"�z IdleUserConfParserTest.test_saveN)r)
r;r<r=rBrJrLrMrQrRrYrrrrr>as
	

r>c@s*eZdZ	edd��Zedd��Zd@dd�Zdd	�Ze�	e
j�d
�d�dd
��Z
e�	e
j�d
�d�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!d7d8�Z"d9d:�Z#d;d<�Z$d=d>�Z%d?S)A�IdleConfTestc	Cs�i|_tjdd�}tdkrtj�t�}n	tj�t	jd�}|j
D]'}tj�|d|�}t|d��}|�
�|j|<Wd�n1sBwYq tj|_t�t_dS)NT��_utest�__main__rz../config-%s.def�r)�
config_stringr�IdleConfr;rUrA�dirname�__file__�abspath�sys�config_typesrV�open�read�_warn�	orig_warnr)�cls�conf�idle_dir�ctyper9�frrr�
setUpClass�s
��zIdleConfTest.setUpClasscCs|jt_dSr?)rirrh)rjrrr�
tearDownClass�szIdleConfTest.tearDownClassFcCstj|d�S)Nr[)rr`)r*r\rrr�
new_config�szIdleConfTest.new_configcCsj	tjdd�}|jD](}t�d�|j|<|j|�|j|�t�d�|j|<|j|�|j|�q
|S)NTr[r)	rr`rer&�
defaultCfgr'r_r@r)r*rkrmrrr�mock_config�s
zIdleConfTest.mock_config�winzthis is test for unix systemc
C�|jdd�}tjddd��'tjddd��|�|��d�Wd�n1s(wYWd�n1s7wYtjddd��<tjd	d
d��%t�d��|�|��d�Wd�n1sdwYWd�n1sswYWd�n1s�wYtjd
dd��?|�t��!|�t��|��Wd�n1s�wYWd�n1s�wYWd�dSWd�dS1s�wYdS)NTr[�os.path.expanduser�	/home/foo�Zreturn_value�os.path.existsz/home/foo/.idlerc�~�	os.getcwdz/home/foo/cpython�os.mkdirz/home/foo/cpython/.idlerc�os.path.join�/path/not/exists�rqr�patchr(Z
GetUserCfgDir�assertRaises�
SystemExit�FileNotFoundError�r*rkrrr�test_get_user_cfg_dir_unix��8���
������
����"�z'IdleConfTest.test_get_user_cfg_dir_unixzthis is test for Windows systemc
Cru)NTr[rvzC:\foorxryzC:\foo\.idlercrzr{zC:\foo\cpythonr|zC:\foo\cpython\.idlercr}r~rr�rrr�test_get_user_cfg_dir_windows�r�z*IdleConfTest.test_get_user_cfg_dir_windowsc
CsL|jdd�}d}tj�ddi��#tjd|d��|��Wd�n1s'wYWd�n1s6wY|�|j��|j�|�|j	��|j�|j�
�D]	}|�|tj
�qT|j	�
�D]	}|�|tj�qc|j��D]\}}|�|jtj�|d|�d	���qr|j	��D]\}}|�|jtj�|jp�d
d|�d���q�dS)NTr[rwr;Z__foo__zos.path.dirnamerxzconfig-z.def�#z.cfg)rqrr��dictZCreateConfigHandlersr/rrr
rer�valuesZassertIsInstancerr&r@�itemsr(�filerUrArVZuserdir)r*rkrlZdefault_parserZuser_parserZcfg_typer+rrr�test_create_config_handlerss.
������z(IdleConfTest.test_create_config_handlerscCs�|jdd�}td�}t�|�|jd<t�|�|jd<|��|j}||jd�	dd�d�||jd�
d�dg�||jd�	dd�d�||jd�
d�dg�dS)NTr[r5r7r6r8)rqrrr&rrr@rZLoadCfgFilesr(r)r.)r*rkr9r,rrr�test_load_cfg_files&sz IdleConfTest.test_load_cfg_filescCsT|��}t�d��}|��|�|jt|j��Wd�dS1s#wYdS)Nz&idlelib.config.IdleUserConfParser.Save)rsrr�ZSaveUserCfgFilesr(�
call_count�lenr)r*rk�mrrr�test_save_user_cfg_files;s
"�z%IdleConfTest.test_save_user_cfg_filescCs�|��}|j}||�ddd�d�||jddddd�d�t�d��1}||jddd	dd�d�||�ddd
�d�||jddd
dd�d�||jd
�Wd�dS1sVwYdS)Nr�EditorWindow�widthZ80rr�P�idlelib.config._warnZfont�	NotExistsZNEr$�)rsr(�	GetOptionrr�r�)r*rkr,rhrrr�test_get_optionBs"�zIdleConfTest.test_get_optioncCs2|��}|�dddd�|�|�ddd�d�dS)NrrCrDr8)rsrHr(r�r�rrrrJNszIdleConfTest.test_set_optioncCs�|��}|�|�dd�gd��|�|�dd�gd��|�tj��|�dd�Wd�n1s3wY|�tj��|�dd�Wd�dS1sPwYdS)Nr%r)ZGeneralr�ZPyShell�Indent�Theme�KeysZHistory�	HelpFiles�userZfoobarZ	notexists)rsr/�GetSectionListr�r�InvalidConfigSetZInvalidConfigTyper�rrr�test_get_section_listTs
�
��"�z"IdleConfTest.test_get_section_listcCs�|��}|j}||�dd�ddd��||�dd�ddd��|�dd	d
d�|�dd	dd
�t�d��||�d	d�dd
d��Wd�dS1sLwYdS)N�IDLE ClassicZnormalz#000000z#ffffff)Z
foregroundZ
backgroundZcursorZblackr	�Foobarznormal-foregroundz#747474znormal-backgroundz#171717r�)rsr(ZGetHighlightrHrr��r*rkr,rrr�test_get_highlightes��
�"�zIdleConfTest.test_get_highlightcCsb|��}|�|�dd�|�dd��|�tj��|�dd�Wd�dS1s*wYdS)Nr%r�r��bad)rsr(ZGetThemeDictr�rZInvalidThemer�rrr�test_get_theme_dictws

�"�z IdleConfTest.test_get_theme_dictcCs8|��}|�|��|�d��|�|��|�d��dS)Nr�r�)rsr(ZCurrentTheme�current_colors_and_keys�CurrentKeysr�rrr�test_get_current_theme_and_keys�sz,IdleConfTest.test_get_current_theme_and_keyscCs|��}|�|�d�d�dS)Nr�r�)rsr(r�r�rrr�test_current_colors_and_keys�sz)IdleConfTest.test_current_colors_and_keyscCs^tj}|jdd�}dt_|�|��d�dt_|�|��d�dt_|�|��d�|t_dS)	NTr[�win32�IDLE Classic Windows�darwin�IDLE Classic OSX�
some-linux�IDLE Modern Unix)rd�platformrqr(�default_keys�r*Zcurrent_platformrkrrr�test_default_keys�s
zIdleConfTest.test_default_keyscCs�t�d�|j}tj}||dd�g�||�dg�||dd�dg�||dd�ddg�||ddd	�ddg�t�d�t�d�dS)
Nzn
            [ZzDummy]
            enable = True
            [DISABLE]
            enable = False
            T)Z
shell_only�ZzDummy)�editor_onlyF)�active_onlyZDISABLE)r�r�)�userextnr'r(rZ
GetExtensionsrX)r*r,ZiGErrr�test_get_extensions�s

z IdleConfTest.test_get_extensionscCs*|��}|�|�|�dd��gd��dS)Nr%r)ZAutoCompleteZCodeContextZFormatParagraphZ
ParenMatchr�)rsr/ZRemoveKeyBindNamesr�r�rrr�test_remove_key_bind_names�s
�z'IdleConfTest.test_remove_key_bind_namescCs>t�d�|j}|t�d�d�|t�d�d�t�d�dS)N�=
            [ZzDummy]
            enable = True
            zz-inr�zz-out)r�r'r(rZGetExtnNameForEventrX)r*r,rrr�test_get_extn_name_for_event�s

z)IdleConfTest.test_get_extn_name_for_eventcCs0t�d�|�t�d�ddgi�t�d�dS)Nr�r��<<z-in>>�!<Control-Shift-KeyRelease-Insert>)r�r'r(rZGetExtensionKeysrX�r*rrr�test_get_extension_keys�s

�z$IdleConfTest.test_get_extension_keyscCsNt�d�|j}tj}||d�i�dgdgd�}||d�|�t�d�dS)Nr�r�r�z!<Control-Shift-KeyRelease-Delete>)r�z	<<z-out>>r�)r�r'r(rZGetExtensionBindingsrX)r*r,ZiGEB�expectrrr�test_get_extension_bindings�s
�z(IdleConfTest.test_get_extension_bindingscCs�|��}|j}||�dd�ddg�||�dd�ddg�||�dd�d	d
g�||�dd�dg�||�d
d�dg�||�dd�g�||�dd�g�dS)Nr��<<copy>>z<Control-Shift-Key-C>z<Control-Key-Insert>�IDLE Classic Unixz<Alt-Key-w>z<Meta-Key-w>r�z<Control-Key-c>z<Control-Key-C>zIDLE Classic Mac�<Command-Key-c>r�z
NOT EXISTS)rsr(Z
GetKeyBindingr�rrr�test_get_keybinding�s���z IdleConfTest.test_get_keybindingcCs8tj}|��}dt_|�|��|�|����|t_dS)Nr�)rdr�rsr(ZGetCurrentKeySet�	GetKeySetr�r�rrr�test_get_current_keyset�s

	z$IdleConfTest.test_get_current_keysetcCsj|��}|jd�d�|jd�d�|jd�ddd�|jd�ddd�|�|�d�d	d
�dS)Nrr�ZFoobar_cfgBindings�enable�TrueZnewfooz<Key-F3>r�z
<<newfoo>>r)rsrrrF�setr(r�r�rrr�test_get_keyset�szIdleConfTest.test_get_keysetcCsL|��}|�|�d��|�|�d��|�|�d��|�|�d��dS)N�copyZcutzdel-word-rightz
not-exists)rsrGZ
IsCoreBindingrIr�rrr�test_is_core_bindings
z!IdleConfTest.test_is_core_bindingcCs|��}|�|�d�g�|�|�d�g�|�tj��|�|�d�g�Wd�n1s0wY|�|��|�d�|�d��|jd�	ddd�|jd�	ddd	�|jd�	dd
d�|jd�	ddd
�|�|�d�gd��|�|��|�d�|�d��dS)Nr%r�r�rr��4zPython;https://python.org�3zPython:https://python.org�2z/Pillow;https://pillow.readthedocs.io/en/latest/�1z/IDLE;C:/Programs/Python36/Lib/idlelib/help.html))�IDLEz*C:/Programs/Python36/Lib/idlelib/help.htmlr�)ZPillowz(https://pillow.readthedocs.io/en/latest/r�)�Pythonzhttps://python.orgr�)
rsr(ZGetExtraHelpSourceListr�rr�r/ZGetAllExtraHelpSourcesListrrHr�rrr�test_extra_help_source_lists*����z(IdleConfTest.test_extra_help_source_listcCs�ddlm}ddlm}ddlm}|��}|d�|�}|��|�|dd|d��}|�	|�
|d	d
�|d|ddkr>d
n|d|df�|��~dS)Nr)�requires)�Tk)�FontZguiZTkFixedFontT)rOrW�rootrr��family�sizer Zweight)�test.supportr��tkinterr�Ztkinter.fontr�rsZwithdraw�actualr(ZGetFontZdestroy)r*r�r�r�rkr�rnrrr�
test_get_font*s$�zIdleConfTest.test_get_fontcCs�|��}|j}||��ddg�||��dddg�||��ddg�||�d�dd	d
g�||�d�ddg�||�d
�dddg�||�d�dddg�dS)Nz<<center-insert>>z<Control-l>r�z<Control-c>z<Control-C>z<<history-next>>z<Alt-n>r�z<Control-Key-l>z<Control-Key-L>r�r�r�z<Alt-Key-n>z<Meta-Key-n>r�)rsr(ZGetCoreKeysr�rrr�test_get_core_keys=s���zIdleConfTest.test_get_core_keysN)F)&r;r<r=�classmethodrorprqrs�unittestZskipIfrdr��
startswithr�r�r�r�r�r�rJr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrZ�sF







	rZc@sPeZdZ	ejZdZe��Zdd�Zdd�Z	dd�Z
dd	�Zd
d�Zdd
�Z
dS)�CurrentColorKeysTestr�cCs~|�|�d�|j�t�d�|�|�d�|j�dtdd<|�|�d�d�dtdd<|�|�d�|j�t�d�dS)Nr�z<
            [Theme]
            default = True
            �IDLE NewrO�non-existent)r(�	colorkeys�
default_theme�usermainr'rXr�rrr�test_old_builtin_themeXs
z+CurrentColorKeysTest.test_old_builtin_themecC�ht�d�|�|�d�d�dtdd<|�|�d�d�dtdd<|�|�d�|j�t�d�dS)NzZ
            [Theme]
            default = True
            name2 = IDLE Dark
            r�z	IDLE Darkr�rOr��name2)r�r'r(r�r�rXr�rrr�test_new_builtin_themej�
z+CurrentColorKeysTest.test_new_builtin_themecC�pt�d�|�|�d�|j�t�d�|�|�d�d�dtdd<|�|�d�d�t�d�t�d�dS)Nz\
            [Theme]
            default = False
            name = Custom Dark
            r�z[Custom Dark]
a=bzCustom Darkr�r�)r�r'r(r�r��userhighrXr�rrr�test_user_override_themez�


z-CurrentColorKeysTest.test_user_override_themecCs^|�|�d�|j�t�d�|�|�d�d�dtdd<|�|�d�|j�t�d�dS)Nr�z`
            [Keys]
            default = True
            name = IDLE Classic Unix
            r�r�rO)r(r�r�r�r'rXr�rrr�test_old_builtin_keys�s
z*CurrentColorKeysTest.test_old_builtin_keyscCr�)Nz`
            [Keys]
            default = True
            name2 = IDLE Modern Unix
            r�r�r�rOr�r�)r�r'r(r�r�rXr�rrr�test_new_builtin_keys�r�z*CurrentColorKeysTest.test_new_builtin_keyscCr�)Nz[
            [Keys]
            default = False
            name = Custom Keys
            r�z[Custom Keys]
a=bzCustom Keysr�r�)r�r'r(r�r��userkeysrXr�rrr�test_user_override_keys�r�z,CurrentColorKeysTest.test_user_override_keysN)r;r<r=rr�r�r�r�r�r�r�r�r�r�rrrrr�Msr�c@s�eZdZiiiid�Zdd�Zdddiiddd	iid
ddiiid�Zd
d�Zdd�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS) �ChangesTest)rr	r
rcCs:|j}|�dddd�|�dddd�|�d	d
dd�|S)
Nr�Msec�mitem�mvalr	�Hsec�hitem�hvalr
�Ksec�kitem�kval��changes�
add_option�r*rrrr�load�s
zChangesTest.loadr�r�r�r�r�r�rrrcCst��|_dSr?)rZ
ConfigChangesrr�rrr�setUp�szChangesTest.setUpcCs|�|j|j�dSr?)r(r�emptyr�rrr�	test_init�szChangesTest.test_initcCs8|��}|�||j�|�dddd�|�||j�dS)Nrr�r�r�)rr(�loadedrrrrr�test_add_option�szChangesTest.test_add_optioncCs�|jj}|�|dddd��|�|dddd��|�tddd�|�|dddd��|�tddd�|�|dddd��|�t�dd��t�d�dS)Nrr�Zwhat�0�
use-spacesr�)r�save_optionrGrIr(r��
has_optionrX)r*rrrr�test_save_option�szChangesTest.test_save_optioncCs�|��}|�|���|�tddd�|�tddd�|�tddd	�|�d
ddd�|�|���t�	d�t�	d�t�	d�dS)Nr�r�r�r�r�r�rrrr)
rrG�save_allr(r�r�r�rrIrXrrrr�test_save_added�s

zChangesTest.test_save_addedcCsV|j}|�dddd�|�dddd�|��|�t�dd��|�t�dd��dS)Nrr�r�ZidledocZELDIZcodeldi)rrrrrIr�rrGrrrr�test_save_help�szChangesTest.test_save_helpcCs|j}|�dddd�dS)Nrr�rr�rrrrr�test_save_default�szChangesTest.test_save_defaultc	Cs�|��}|�dd�|�||j�dD]4\}}t|�|dd�|�||�|�t��|||t||Wd�n1sBwYqdS)NrZfake))rr�)r
rrO�value)rZdelete_sectionr(rr
rHr��KeyError)r*rZcfgtype�sectionrrr�test_delete_sections���zChangesTest.test_delete_sectioncCs"|��}|��|�||j�dSr?)r�clearr(r	rrrr�
test_clearszChangesTest.test_clearN)r;r<r=r	rrrr
rrrrrrrrrrrr��s"


�	r�c@seZdZdd�ZdS)�WarningTestcCs�|j}t�t_t��}t�dd�Wd�n1swY|tjdh�||��d�t��}t�dd�Wd�n1sBwY||��d�t��}t�dd�Wd�n1sbwY|tjddh�||��d	�dS)
N�warning�key)rrzwarning
r�warn2�yek)rr zwarn2
)r(r�rZ_warnedrrh�getvalue)r*ZEqual�stderrrrr�	test_warns ���zWarningTest.test_warnN)r;r<r=r#rrrrrsrr]�)�	verbosity) rrrdrUrSr�rrr�rZidlelib.idle_test.mock_idlerrrrr
r@r�r�r�r�rrZTestCaserr>rZr�r�rr;rrrrr�<module>s>;SoV�