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_config.cpython-38.pyc
U

�i�_.}�@sNdZddlmZddlZddlZddlZddlmZmZddl	Z	ddl	m
Z
ddlZddlmZej
Z
e
jZiZe�d�Zed<e�d�Zed	<e�d�Zed
<e�d�Zed<dd
�Zdd�ZGdd�de	j�ZGdd�de	j�ZGdd�de	j�ZGdd�de	j�ZGdd�de	j�ZGdd�de	j�Zedk�rJe	j dd�dS)z�Test config, coverage 93%.
(100% for IdleConfParser, IdleUserConfParser*, ConfigChanges).
* Exception is OSError clause in Save method.
Much of IdleConf is also exercised by ConfigDialog and test_configdialog.
�)�configN)�captured_stderr�findfile)�mock)�Func��main�	highlight�keys�
extensionscCstt_dt_dS)NT)�testcfg�idleConf�userCfg�idlelib�testing�rr�</opt/python38/lib/python3.8/idlelib/idle_test/test_config.py�setUpModulesrcCstt_dt_dS)NF)�usercfgr
rrrrrrr�tearDownModule!src@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)�IdleConfParserTestzTest that IdleConfParser worksz�
        [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_getcCs\t�d�}|�|j�|j}|�|d�dddg�|�|d�dddg�|�|d�g�dS)Nrrrrz	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$r/r&r'r,)r(�config_pathr)rrr�test_load_fileWs

z!IdleConfParserTest.test_load_fileN)	�__name__�
__module__�__qualname__�__doc__rr+r.r2r8rrrrr&src@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�IdleUserConfParserTestz"Test that IdleUserConfParser worksrcCs
t�|�S�N)r�IdleUserConfParser)r(�pathrrr�
new_parserdsz!IdleUserConfParserTest.new_parsercCs�|��}|�d�|�|�ddd��|�|�ddd��|�|�ddd��|�|�dd�d�|�|�ddd��|�|��ddg�|�|�dd�d�dS)N�Foo�barrr �Bar)	rA�add_section�
assertTrue�	SetOption�assertFalser&r'r-r0r1rrr�test_set_optiongs
z&IdleUserConfParserTest.test_set_optioncCsZ|��}|�d�|�ddd�|�|�dd��|�|�dd��|�|�dd��dS)NrBrCrZNotZExist)rA�
AddSectionrGrFZRemoveOptionrHr1rrr�test_remove_optionws
z)IdleUserConfParserTest.test_remove_optioncCsN|��}|�|��g�|�d�|�d�|�d�|�|��ddg�dS)NrBrD)rAr&r0rJr-r1rrr�test_add_section�s


z'IdleUserConfParserTest.test_add_sectioncCs^|��}|�d�|�d�|�ddd�|�|��dddg�|��|�|��dg�dS)NrBrDZIdle�name�val)rArJrGr-r0ZRemoveEmptySectionsr&r1rrr�test_remove_empty_sections�s

z1IdleUserConfParserTest.test_remove_empty_sectionscCsv|��}|�d�|�d�|�|���|�|��g�|�ddd�|�d�|�|���|�|��dg�dS)NrBrDrCr )	rArJrFZIsEmptyr&r0rGrHr-r1rrr�
test_is_empty�s


z$IdleUserConfParserTest.test_is_emptyc	Cs�t����}tj�|d�}|�|�}|�d�|�ddd�|�tj�	|��|�
�|�tj�	|��|�d�|�
�|�tj�	|��W5QRXdS)Nztest.cfgrBrCr)
�tempfile�TemporaryDirectory�osr@�joinrArJrGrH�existsZSaverF�remove_section)r(Ztdirr@r)rrr�	test_save�s



z IdleUserConfParserTest.test_saveN)r)r9r:r;r<rArIrKrLrOrPrWrrrrr=as
	

r=c@s,eZdZdZedd��Zedd��ZdAdd�Zd	d
�Ze	�
ej�
d�d�d
d��Ze	�
ej�
d�d�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Z d4d5�Z!d6d7�Z"d8d9�Z#d:d;�Z$d<d=�Z%d>d?�Z&d@S)B�IdleConfTestzTest for idleConfc
Cs�i|_tjdd�}tdkr(tj�t�}ntj�t	jd�}|j
D]:}tj�|d|�}t|d��}|�
�|j|<W5QRXq@tj|_t�t_dS)NT��_utest�__main__rz../config-%s.def�r)�
config_stringr�IdleConfr9rSr@�dirname�__file__�abspath�sys�config_typesrT�open�read�_warn�	orig_warnr)�cls�conf�idle_dir�ctyper7�frrr�
setUpClass�s
zIdleConfTest.setUpClasscCs|jt_dSr>)rgrrf)rhrrr�
tearDownClass�szIdleConfTest.tearDownClassFcCstj|d�S)NrY)rr^)r(rZrrr�
new_config�szIdleConfTest.new_configcCshtjdd�}|jD]P}t�d�|j|<|j|�|j|�t�d�|j|<|j|�|j|�q|S)zbReturn a mocked idleConf

        Both default and user config used the same config-*.def
        TrYr)	rr^rcr$�
defaultCfgr%r]r?r)r(rirkrrr�mock_config�s
zIdleConfTest.mock_config�winzthis is test for unix systemcCs�|jdd�}tjddd��0tjddd��|�|��d�W5QRXW5QRXtjddd��Ftjd	d
d��,t�d��|�|��d�W5QRXW5QRXW5QRXtjd
dd��:|�t��$|�t��|��W5QRXW5QRXW5QRXdS)NTrY�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�ror�patchr&Z
GetUserCfgDir�assertRaises�
SystemExit�FileNotFoundError�r(rirrr�test_get_user_cfg_dir_unix�s$
�"z'IdleConfTest.test_get_user_cfg_dir_unixzthis is test for Windows systemcCs�|jdd�}tjddd��0tjddd��|�|��d�W5QRXW5QRXtjddd��Ftjd	d
d��,t�d��|�|��d�W5QRXW5QRXW5QRXtjd
dd��:|�t��$|�t��|��W5QRXW5QRXW5QRXdS)NTrYrszC:\foorurvzC:\foo\.idlercrwrxzC:\foo\cpythonryzC:\foo\cpython\.idlercrzr{r|r�rrr�test_get_user_cfg_dir_windows�s$
�"z*IdleConfTest.test_get_user_cfg_dir_windowsc
Cs&|jdd�}d}tj�ddi��(tjd|d��|��W5QRXW5QRX|�|j��|j�|�|j	��|j�|j�
�D]}|�|tj
�q�|j	�
�D]}|�|tj�q�|j��D](\}}|�|jtj�|d|�d	���q�|j	��D]0\}}|�|jtj�|j�pd
d|�d���q�dS)NTrYrtr9Z__foo__zos.path.dirnameruzconfig-z.def�#z.cfg)rorr}�dictZCreateConfigHandlersr-rpr
rcr�valuesZassertIsInstancerr$r?�itemsr&�filerSr@rTZuserdir)r(rirjZdefault_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)NTrYr3r5r4r6)rorrr$rpr?rZLoadCfgFilesr&r'r,)r(rir7r*rrr�test_load_cfg_files&sz IdleConfTest.test_load_cfg_filesc	Cs>|��}t�d��"}|��|�|jt|j��W5QRXdS)Nz&idlelib.config.IdleUserConfParser.Save)rqrr}ZSaveUserCfgFilesr&�
call_count�lenr)r(ri�mrrr�test_save_user_cfg_files;sz%IdleConfTest.test_save_user_cfg_filesc	Cs�|��}|j}||�ddd�d�||jddddd�d�t�d��V}||jddd	dd�d�||�ddd
�d�||jddd
dd�d�||jd
�W5QRXdS)Nr�EditorWindow�widthZ80rr�P�idlelib.config._warnZfont�	NotExistsZNEr"�)rqr&�	GetOptionrr}r�)r(rir*rfrrr�test_get_optionBszIdleConfTest.test_get_optioncCs2|��}|�dddd�|�|�ddd�d�dS)NrrBrCr6)rqrGr&r�r�rrrrINszIdleConfTest.test_set_optioncCs�|��}|�|�dd�ddddddd	d
g�|�|�dd�ddddddd	d
g�|�tj��|�dd�W5QRX|�tj��|�dd
�W5QRXdS)Nr#rZGeneralr�ZPyShell�Indent�Theme�KeysZHistory�	HelpFiles�userZfoobarZ	notexists)rqr-�GetSectionListr~r�InvalidConfigSetZInvalidConfigTyper�rrr�test_get_section_listTs*

��

��z"IdleConfTest.test_get_section_listc	Cs�|��}|j}||�dd�ddd��||�dd�ddd��|�dd	d
d�|�dd	dd
�t�d��||�d	d�dd
d��W5QRXdS)N�IDLE ClassicZnormalz#000000z#ffffff)Z
foregroundZ
backgroundZcursorZblackr	�Foobarznormal-foregroundz#747474znormal-backgroundz#171717r�)rqr&ZGetHighlightrGrr}�r(rir*rrr�test_get_highlightes���zIdleConfTest.test_get_highlightc	CsL|��}|�|�dd�|�dd��|�tj��|�dd�W5QRXdS)Nr#r�r��bad)rqr&ZGetThemeDictr~rZInvalidThemer�rrr�test_get_theme_dictws

�z IdleConfTest.test_get_theme_dictcCs8|��}|�|��|�d��|�|��|�d��dS)Nr�r�)rqr&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�)rqr&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)	NTrY�win32�IDLE Classic Windows�darwin�IDLE Classic OSX�
some-linux�IDLE Modern Unix)rb�platformror&�default_keys�r(Zcurrent_platformrirrr�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&r
Z
GetExtensionsrV)r(r*ZiGErrr�test_get_extensions�s

z IdleConfTest.test_get_extensionscCs0|��}|�|�|�dd��dddddg�dS)Nr#rZAutoCompleteZCodeContextZFormatParagraphZ
ParenMatchr�)rqr-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&r
ZGetExtnNameForEventrV)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&r
ZGetExtensionKeysrV�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&r
ZGetExtensionBindingsrV)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)rqr&Z
GetKeyBindingr�rrr�test_get_keybinding�s���z IdleConfTest.test_get_keybindingcCs8tj}|��}dt_|�|��|�|����|t_dS)Nr�)rbr�rqr&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)rqrprE�setr&r�r�rrr�test_get_keyset�szIdleConfTest.test_get_keysetcCsL|��}|�|�d��|�|�d��|�|�d��|�|�d��dS)N�copyZcutzdel-word-rightz
not-exists)rqrFZ
IsCoreBindingrHr�rrr�test_is_core_bindings
z!IdleConfTest.test_is_core_bindingc	Cs|��}|�|�d�g�|�|�d�g�|�tj��|�|�d�g�W5QRX|�|��|�d�|�d��|jd�	ddd�|jd�	ddd	�|jd�	dd
d�|jd�	ddd
�|�|�d�dddg�|�|��|�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�)
rqr&ZGetExtraHelpSourceListr~rr�r-ZGetAllExtraHelpSourcesListrrGr�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)rMrU�rootrr��family�sizerZweight)�test.supportr��tkinterr�Ztkinter.fontr�rqZwithdraw�actualr&ZGetFontZdestroy)r(r�r�r�rir�rlrrr�
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�)rqr&ZGetCoreKeysr�rrr�test_get_core_keys=s���zIdleConfTest.test_get_core_keysN)F)'r9r:r;r<�classmethodrmrnrorq�unittestZskipIfrbr��
startswithr�r�r�r�r�r�rIr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrX�sD







	rXc@sReZdZdZejZdZe��Zdd�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
d�ZdS)�CurrentColorKeysTesta Test colorkeys function with user config [Theme] and [Keys] patterns.

        colorkeys = config.IdleConf.current_colors_and_keys
        Test all patterns written by IDLE and some errors
        Item 'default' should really be 'builtin' (versus 'custom).
    r�cCs~|�|�d�|j�t�d�|�|�d�|j�dtdd<|�|�d�d�dtdd<|�|�d�|j�t�d�dS)Nr�z<
            [Theme]
            default = True
            �IDLE NewrM�non-existent)r&�	colorkeys�
default_theme�usermainr%rVr�rrr�test_old_builtin_themeXs
z+CurrentColorKeysTest.test_old_builtin_themecCsht�d�|�|�d�d�dtdd<|�|�d�d�dtdd<|�|�d�|j�t�d�dS)NzZ
            [Theme]
            default = True
            name2 = IDLE Dark
            r�z	IDLE Darkr�rMr��name2)r�r%r&r�r�rVr�rrr�test_new_builtin_themejs
z+CurrentColorKeysTest.test_new_builtin_themecCspt�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��userhighrVr�rrr�test_user_override_themezs


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�rM)r&r�r�r�r%rVr�rrr�test_old_builtin_keys�s
z*CurrentColorKeysTest.test_old_builtin_keyscCsht�d�|�|�d�d�dtdd<|�|�d�d�dtdd<|�|�d�|j�t�d�dS)Nz`
            [Keys]
            default = True
            name2 = IDLE Modern Unix
            r�r�r�rMr�r�)r�r%r&r�r�rVr�rrr�test_new_builtin_keys�s
z*CurrentColorKeysTest.test_new_builtin_keyscCspt�d�|�|�d�|j�t�d�|�|�d�d�dtdd<|�|�d�d�t�d�t�d�dS)Nz[
            [Keys]
            default = False
            name = Custom Keys
            r�z[Custom Keys]
a=bzCustom Keysr�r�)r�r%r&r�r��userkeysrVr�rrr�test_user_override_keys�s


z,CurrentColorKeysTest.test_user_override_keysN)r9r:r;r<r
r�r�r�r�r�r�r�r�r�r�rrrrr�Msr�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(r�rrr�load�s
zChangesTest.loadr�r�r�r�r�r�r�r�r�cCst��|_dSr>)rZ
ConfigChangesr�r�rrr�setUp�szChangesTest.setUpcCs|�|j|j�dSr>)r&r��emptyr�rrr�	test_init�szChangesTest.test_initcCs8|��}|�||j�|�dddd�|�||j�dS)Nrr�r�r�)r�r&�loadedr�r�rrr�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_optionrFrHr&r��
has_optionrV)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�r�r�r�r)
r�rF�save_allr&r�r�r�r�rHrVr�rrr�test_save_added�s

zChangesTest.test_save_addedcCsV|j}|�dddd�|�dddd�|��|�t�dd��|�t�dd��dS)Nrr�r�ZidledocZELDIZcodeldi)r�rr�r
rHr�rrFr�rrr�test_save_help�szChangesTest.test_save_helpcCs|j}|�dddd�dS)Nrr�rr�r�r�rrr�test_save_default�szChangesTest.test_save_defaultc
Cs�|��}|�dd�|�||j�dD]T\}}t|�|dd�|�||�|�t��|||t||W5QRXq&dS)NrZfake))rr�)r
r�rM�value)r�Zdelete_sectionr&rrrGr~�KeyError)r(r�Zcfgtype�sectionrrr�test_delete_sectionszChangesTest.test_delete_sectioncCs"|��}|��|�||j�dSr>)r��clearr&rr�rrr�
test_clearszChangesTest.test_clearN)r9r:r;rr�rrrrr	rrr
rrrrrrr��s 


�	r�c@seZdZdd�ZdS)�WarningTestc	Cs�|j}t�t_t��}t�dd�W5QRX|tjdh�||��d�t��}t�dd�W5QRX||��d�t��}t�dd�W5QRX|tjddh�||��d	�dS)
N�warning�key)rrzwarning
r�warn2�yek)rrzwarn2
)r&r�rZ_warnedrrf�getvalue)r(ZEqual�stderrrrr�	test_warnszWarningTest.test_warnN)r9r:r;rrrrrrsrr[�)�	verbosity)!r<rrrbrSrQr�rrr�rZidlelib.idle_test.mock_idlerr
rrrr?r�r�r�r�rrZTestCaserr=rXr�r�rr9rrrrr�<module>s:;SoV