• File: test_config.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/idlelib/idle_test/__pycache__/test_config.cpython-37.pyc
  • Date Modified: 10/26/2026 8:08 PM
  • File size: 24.57 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

Nj.}@sNdZddlmZddlZddlZddlZddlmZmZddl	Z	ddl	m
Z
ddlZddlmZej
Z
e
jZiZedZed<edZed	<edZed
<edZed<dd
ZddZGddde	jZGddde	jZGddde	jZGddde	jZGddde	jZGddde	jZedkrJe	j dddS)zTest 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_stderrfindfile)mock)Funcmain	highlightkeys
extensionscCstt_dt_dS)NT)testcfgidleConfuserCfgidlelibtestingrrB/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_config.pysetUpModulesrcCstt_dt_dS)NF)usercfgr
rrrrrrrtearDownModule!src@s4eZdZdZdZddZddZddZd	d
ZdS)IdleConfParserTestzTest that IdleConfParser worksz
        [one]
        one = false
        two = true
        three = 10

        [two]
        one = a string
        two = true
        three = false
    cCstd}||j|j}||jddddd||jddddd||jddd	dd
||ddd||jddddd||jddddd||ddd||ddd
||dd||jddddddS)Nronebool)typeFtwoTthreeint
za stringtruefalsenotZexistZDEFAULT)default)rIdleConfParserread_stringassertEqualZassertIsGetZassertIsNone)selfparsereqrrrtest_get5s
zIdleConfParserTest.test_getcCs\td}||j|j}||ddddg||ddddg||dgdS)Nrrrrz	not exist)rr"r#
GetOptionListassertCountEqualr$)r&r'Zget_listrrrtest_get_option_listJs
z'IdleConfParserTest.test_get_option_listcCs&td}|||gdS)Nr)rr"Loadr$sections)r&r'rrrtest_load_nothingRs
z$IdleConfParserTest.test_load_nothingcCsFtd}t|}|||ddd||ddgdS)Nzcfgparser.1zFoo Barfoonewbar)rrr"r-r$r%r*)r&config_pathr'rrrtest_load_fileWs

z!IdleConfParserTest.test_load_fileN)	__name__
__module____qualname____doc__rr)r,r/r3rrrrr&src@sJeZdZdZdddZddZddZd	d
ZddZd
dZ	ddZ
dS)IdleUserConfParserTestz"Test that IdleUserConfParser worksrcCs
t|S)N)rIdleUserConfParser)r&pathrrr
new_parserdsz!IdleUserConfParserTest.new_parsercCs|}|d||ddd||ddd||ddd||ddd||ddd||ddg||ddddS)NFoobarrrBar)	r;add_section
assertTrue	SetOptionassertFalser$r%r+r.)r&r'rrrtest_set_optiongs
z&IdleUserConfParserTest.test_set_optioncCsZ|}|d|ddd||dd||dd||dddS)Nr<r=rZNotZExist)r;
AddSectionrAr@ZRemoveOptionrB)r&r'rrrtest_remove_optionws
z)IdleUserConfParserTest.test_remove_optioncCsN|}||g|d|d|d||ddgdS)Nr<r>)r;r$r.rDr+)r&r'rrrtest_add_sections


z'IdleUserConfParserTest.test_add_sectioncCs^|}|d|d|ddd||dddg|||dgdS)Nr<r>ZIdlenameval)r;rDrAr+r.ZRemoveEmptySectionsr$)r&r'rrrtest_remove_empty_sectionss

z1IdleUserConfParserTest.test_remove_empty_sectionscCsv|}|d|d||||g|ddd|d||||dgdS)Nr<r>r=r)	r;rDr@ZIsEmptyr$r.rArBr+)r&r'rrr
test_is_emptys


z$IdleUserConfParserTest.test_is_emptyc	Cst}tj|d}||}|d|ddd|tj	||
|tj	||d|
|tj	|WdQRXdS)Nztest.cfgr<r=r)
tempfileZTemporaryDirectoryosr:joinr;rDrArBexistsZSaver@remove_section)r&Ztdirr:r'rrr	test_saves



z IdleUserConfParserTest.test_saveN)r)r4r5r6r7r;rCrErFrIrJrPrrrrr8as
	

r8c@s,eZdZdZeddZeddZdAddZd	d
Ze	
ej
ddd
dZe	
ej
ddddZddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Z d4d5Z!d6d7Z"d8d9Z#d:d;Z$d<d=Z%d>d?Z&d@S)BIdleConfTestzTest for idleConfc
Csi|_tjdd}tdkr(tjt}ntjt	jd}xD|j
D]:}tj|d|}t|d}|
|j|<WdQRXqBWtj|_tt_dS)NT)_utest__main__rz../config-%s.defr)
config_stringrIdleConfr4rLr:dirname__file__abspathsysconfig_typesrMopenread_warn	orig_warnr)clsconfidle_dirctyper2frrr
setUpClassszIdleConfTest.setUpClasscCs|jt_dS)N)r_rr^)r`rrr
tearDownClassszIdleConfTest.tearDownClassFcCstj|dS)N)rR)rrV)r&rRrrr
new_configszIdleConfTest.new_configcCsltjdd}xZ|jD]P}td|j|<|j||j|td|j|<|j||j|qW|S)zbReturn a mocked idleConf

        Both default and user config used the same config-*.def
        T)rRr)	rrVr[r"
defaultCfgr#rUr9r)r&rarcrrrmock_configszIdleConfTest.mock_configwinzthis is test for unix systemcCs|jdd}tjddd0tjddd||dWdQRXWdQRXtjdddFtjd	d
d,td||dWdQRXWdQRXWdQRXtjd
dd:|t$|t|WdQRXWdQRXWdQRXdS)NT)rRzos.path.expanduserz	/home/foo)return_valuezos.path.existsz/home/foo/.idlerc~z	os.getcwdz/home/foo/cpythonzos.mkdirz/home/foo/cpython/.idlerczos.path.joinz/path/not/exists)rgrpatchr$
GetUserCfgDirassertRaises
SystemExitFileNotFoundError)r&rarrrtest_get_user_cfg_dir_unixs$
$z'IdleConfTest.test_get_user_cfg_dir_unixzthis is test for Windows systemcCs|jdd}tjddd0tjddd||dWdQRXWdQRXtjdddFtjd	d
d,td||dWdQRXWdQRXWdQRXtjd
dd:|t$|t|WdQRXWdQRXWdQRXdS)NT)rRzos.path.expanduserzC:\foo)rkzos.path.existszC:\foo\.idlercrlz	os.getcwdzC:\foo\cpythonzos.mkdirzC:\foo\cpython\.idlerczos.path.joinz/path/not/exists)rgrrmr$rnrorprq)r&rarrrtest_get_user_cfg_dir_windowss$
$z*IdleConfTest.test_get_user_cfg_dir_windowsc
Cs6|jdd}d}tjddi(tjd|d|WdQRXWdQRX||j|j||j	|jx |j
D]}||tj
qWx |j	
D]}||tjqWx6|jD](\}}||jtj|d|d	qWx>|j	D]0\}}||jtj|jpd
d|dqWdS)NT)rRz	/home/foor4Z__foo__zos.path.dirname)rkzconfig-z.def#z.cfg)rgrrmdictZCreateConfigHandlersr+rhr
r[rvaluesZassertIsInstancerr"r9itemsr$filerLr:rMZuserdir)r&rarbZdefault_parserZuser_parserZcfg_typer'rrrtest_create_config_handlerss"z(IdleConfTest.test_create_config_handlerscCs|jdd}td}t||jd<t||jd<||j}||jd	ddd||jd
ddg||jd	ddd||jd
ddgdS)NT)rRzcfgparser.1r0zFoo Barr1)rgrrr"rhr9rZLoadCfgFilesr$r%r*)r&rar2r(rrrtest_load_cfg_files&sz IdleConfTest.test_load_cfg_filesc	Cs>|}td"}|||jt|jWdQRXdS)Nz&idlelib.config.IdleUserConfParser.Save)rirrmZSaveUserCfgFilesr$
call_countlenr)r&ramrrrtest_save_user_cfg_files;sz%IdleConfTest.test_save_user_cfg_filesc	Cs|}|j}||dddd||jddddddtdV}||jddd	ddd||ddd
d||jddd
ddd||jd
WdQRXdS)NrEditorWindowwidthZ80r)rPzidlelib.config._warnZfont	NotExistsZNE)r!)rir$	GetOptionrrmr{)r&rar(r^rrrtest_get_optionBszIdleConfTest.test_get_optioncCs2|}|dddd||dddddS)Nrr<r=r1)rirAr$r)r&rarrrrCNszIdleConfTest.test_set_optioncCs|}||ddddddddd	d
g||ddddddddd	d
g|tj|ddWdQRX|tj|dd
WdQRXdS)Nr!rZGeneralrZPyShellIndentThemeKeysZHistory	HelpFilesuserZfoobarZ	notexists)rir+GetSectionListrorInvalidConfigSetZInvalidConfigType)r&rarrrtest_get_section_listTs



z"IdleConfTest.test_get_section_listc	Cs|}|j}||ddddd||ddddd|dd	d
d|dd	dd
td||d	ddd
dWdQRXdS)NzIDLE ClassicZnormalz#000000z#ffffff)Z
foregroundZ
backgroundZcursorZblackr	Foobarznormal-foregroundz#747474znormal-backgroundz#171717zidlelib.config._warn)rir$ZGetHighlightrArrm)r&rar(rrrtest_get_highlightes

zIdleConfTest.test_get_highlightc	CsL|}||dd|dd|tj|ddWdQRXdS)Nr!zIDLE Classicrbad)rir$ZGetThemeDictrorZInvalidTheme)r&rarrrtest_get_theme_dictws
z IdleConfTest.test_get_theme_dictcCs8|}|||d|||ddS)Nrr)rir$ZCurrentThemecurrent_colors_and_keysCurrentKeys)r&rarrrtest_get_current_theme_and_keyssz,IdleConfTest.test_get_current_theme_and_keyscCs|}||dddS)NrzIDLE Classic)rir$r)r&rarrrtest_current_colors_and_keyssz)IdleConfTest.test_current_colors_and_keyscCs^tj}|jdd}dt_||ddt_||ddt_||d|t_dS)	NT)rRZwin32zIDLE Classic WindowsdarwinzIDLE Classic OSXz
some-linuxzIDLE Modern Unix)rZplatformrgr$default_keys)r&current_platformrarrrtest_default_keysszIdleConfTest.test_default_keyscCstd|j}tj}||ddg||dg||dddg||ddddg||ddd	ddgtdtddS)
Nzn
            [ZzDummy]
            enable = True
            [DISABLE]
            enable = False
            T)Z
shell_onlyZzDummy)editor_onlyF)active_onlyZDISABLE)rr)userextnr#r$r
Z
GetExtensionsrO)r&r(ZiGErrrtest_get_extensionss
z IdleConfTest.test_get_extensionscCs0|}|||dddddddgdS)Nr!rZAutoCompleteZCodeContextZFormatParagraphZ
ParenMatchr)rir+ZRemoveKeyBindNamesr)r&rarrrtest_remove_key_bind_namessz'IdleConfTest.test_remove_key_bind_namescCs>td|j}|tdd|tddtddS)Nz=
            [ZzDummy]
            enable = True
            zz-inrzz-out)rr#r$r
ZGetExtnNameForEventrO)r&r(rrrtest_get_extn_name_for_eventsz)IdleConfTest.test_get_extn_name_for_eventcCs0td|tdddgitddS)Nz=
            [ZzDummy]
            enable = True
            rz<<z-in>>z!<Control-Shift-KeyRelease-Insert>)rr#r$r
ZGetExtensionKeysrO)r&rrrtest_get_extension_keyss
z$IdleConfTest.test_get_extension_keyscCsNtd|j}tj}||didgdgd}||d|tddS)Nz=
            [ZzDummy]
            enable = True
            rz!<Control-Shift-KeyRelease-Insert>z!<Control-Shift-KeyRelease-Delete>)z<<z-in>>z	<<z-out>>r)rr#r$r
ZGetExtensionBindingsrO)r&r(ZiGEBZexpectrrrtest_get_extension_bindingss
z(IdleConfTest.test_get_extension_bindingscCs|}|j}||ddddg||ddddg||ddd	d
g||dddg||d
ddg||ddg||ddgdS)NzIDLE Modern Unixz<<copy>>z<Control-Shift-Key-C>z<Control-Key-Insert>zIDLE Classic Unixz<Alt-Key-w>z<Meta-Key-w>zIDLE Classic Windowsz<Control-Key-c>z<Control-Key-C>zIDLE Classic Macz<Command-Key-c>zIDLE Classic OSXz
NOT EXISTS)rir$Z
GetKeyBinding)r&rar(rrrtest_get_keybindings


z IdleConfTest.test_get_keybindingcCs8tj}|}dt_|||||t_dS)Nz
some-linux)rZrrir$ZGetCurrentKeySet	GetKeySetr)r&rrarrrtest_get_current_keysets
	z$IdleConfTest.test_get_current_keysetcCsj|}|jdd|jdd|jdddd|jdddd||dd	d
dS)NrrZFoobar_cfgBindingsZenableTrueZnewfooz<Key-F3>zIDLE Modern Unixz
<<newfoo>>r)rirhr?setr$r)r&rarrrtest_get_keysetszIdleConfTest.test_get_keysetcCsL|}||d||d||d||ddS)NcopyZcutzdel-word-rightz
not-exists)rir@Z
IsCoreBindingrB)r&rarrrtest_is_core_bindings
z!IdleConfTest.test_is_core_bindingc	Cs|}||dg||dg|tj||dgWdQRX|||d|d|jd	ddd|jd	ddd	|jd	dd
d|jd	ddd
||ddddg|||d|ddS)Nr!rrrr4zPython;https://python.org3zPython:https://python.org2z/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)
rir$ZGetExtraHelpSourceListrorrr+ZGetAllExtraHelpSourcesListrrA)r&rarrrtest_extra_help_source_lists&z(IdleConfTest.test_extra_help_source_listcCsddlm}ddlm}ddlm}|}|d|}|||dd|d}|	|
|d	d
|d|ddkr|d
n|d|df|~dS)Nr)requires)Tk)FontZguiZTkFixedFontT)rGrNrootrrZfamilysizerZweight)test.supportrZtkinterrZtkinter.fontrriZwithdrawZactualr$ZGetFontZdestroy)r&rrrrarrdrrr
test_get_font*s(zIdleConfTest.test_get_fontcCs|}|j}||ddg||dddg||ddg||ddd	d
g||dddg||d
dddg||ddddgdS)Nz<<center-insert>>z<Control-l>z<<copy>>z<Control-c>z<Control-C>z<<history-next>>z<Alt-n>zIDLE Classic Windowsz<Control-Key-l>z<Control-Key-L>zIDLE Classic OSXz<Command-Key-c>zIDLE Classic Unixz<Alt-Key-n>z<Meta-Key-n>zIDLE Modern Unix)rir$ZGetCoreKeys)r&rar(rrrtest_get_core_keys=s

zIdleConfTest.test_get_core_keysN)F)'r4r5r6r7classmethodrerfrgriunittestZskipIfrZr
startswithrrrsryrzr~rrCrrrrrrrrrrrrrrrrrrrrrrrQs<



	rQc@sReZdZdZejZdZeZddZ	ddZ
ddZd	d
ZddZ
d
dZdS)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).
    zIDLE ClassiccCs~||d|jtd||d|jdtdd<||dddtdd<||d|jtddS)Nrz<
            [Theme]
            default = True
            zIDLE NewrGznon-existent)r$	colorkeys
default_themeusermainr#rO)r&rrrtest_old_builtin_themeXsz+CurrentColorKeysTest.test_old_builtin_themecCshtd||dddtdd<||dddtdd<||d|jtddS)NzZ
            [Theme]
            default = True
            name2 = IDLE Dark
            rz	IDLE DarkzIDLE NewrGznon-existentname2)rr#r$rrrO)r&rrrtest_new_builtin_themejsz+CurrentColorKeysTest.test_new_builtin_themecCsptd||d|jtd||dddtdd<||ddtdtddS)Nz\
            [Theme]
            default = False
            name = Custom Dark
            rz[Custom Dark]
a=bzCustom Darkznon-existentr)rr#r$rruserhighrO)r&rrrtest_user_override_themezs

z-CurrentColorKeysTest.test_user_override_themecCs^||d|jtd||dddtdd<||d|jtddS)Nrz`
            [Keys]
            default = True
            name = IDLE Classic Unix
            zIDLE Classic Unixznon-existentrG)r$rrrr#rO)r&rrrtest_old_builtin_keyssz*CurrentColorKeysTest.test_old_builtin_keyscCshtd||dddtdd<||dddtdd<||d|jtddS)Nz`
            [Keys]
            default = True
            name2 = IDLE Modern Unix
            rzIDLE Modern UnixzIDLE Classic UnixrGznon-existentr)rr#r$rrrO)r&rrrtest_new_builtin_keyssz*CurrentColorKeysTest.test_new_builtin_keyscCsptd||d|jtd||dddtdd<||ddtdtddS)Nz[
            [Keys]
            default = False
            name = Custom Keys
            rz[Custom Keys]
a=bzCustom Keysznon-existentr)rr#r$rruserkeysrO)r&rrrtest_user_override_keyss

z,CurrentColorKeysTest.test_user_override_keysN)r4r5r6r7r
rrrrrrrrrrrrrrrMsrc@seZdZiiiidZddZdddiiddd	iid
ddiiidZd
dZddZddZddZ	ddZ
ddZddZddZ
ddZdS) ChangesTest)rr	r
rcCs:|j}|dddd|dddd|d	d
dd|S)
NrMsecmitemmvalr	Hsechitemhvalr
Kseckitemkval)changes
add_option)r&rrrrloads
zChangesTest.loadrrrrrrrrrcCst|_dS)N)rZ
ConfigChangesr)r&rrrsetUpszChangesTest.setUpcCs||j|jdS)N)r$rempty)r&rrr	test_initszChangesTest.test_initcCs8|}|||j|dddd|||jdS)Nrrrr)rr$loadedr)r&rrrrtest_add_optionszChangesTest.test_add_optioncCs|jj}||dddd||dddd|tddd||dddd|tddd||dddd|tddtddS)NrrZwhat0z
use-spacesr)rsave_optionr@rBr$r
has_optionrO)r&rrrrtest_save_optionszChangesTest.test_save_optioncCs|}|||tddd|tddd|tddd	|d
ddd||t	dt	dt	ddS)Nrrrrrrrrrr)
rr@save_allr$rrrrrBrO)r&rrrrtest_save_addeds

zChangesTest.test_save_addedcCsV|j}|dddd|dddd||tdd|tdddS)NrrrZidledocZELDIZcodeldi)rrrrrBrrr@)r&rrrrtest_save_helpszChangesTest.test_save_helpcCs|j}|dddddS)Nrrz
use-spacesr)rr)r&rrrrtest_save_defaultszChangesTest.test_save_defaultc
Cs|}|dd|||jx\dD]T\}}t||dd||||t|||t||WdQRXq(WdS)NrZfake))rr)r
rrGvalue)rZdelete_sectionr$rrrAroKeyError)r&rZcfgtypeZsectionrrrtest_delete_sectionszChangesTest.test_delete_sectioncCs"|}||||jdS)N)rclearr$r)r&rrrr
test_clearszChangesTest.test_clearN)r4r5r6rrrrrrrrrrrrrrrrrs


	rc@seZdZddZdS)WarningTestc	Cs|j}tt_t}tddWdQRX|tjdh||dt}tddWdQRX||dt}tddWdQRX|tjddh||d	dS)
Nwarningkey)rrzwarning
rwarn2yek)rrzwarn2
)r$rrZ_warnedrr^getvalue)r&ZEqualstderrrrr	test_warnszWarningTest.test_warnN)r4r5r6rrrrrrsrrS)	verbosity)!r7rrrZrLrKrrrrrZidlelib.idle_test.mock_idlerr
rrrr9rrrrrrZTestCaserr8rQrrrr4rrrrr<module>s:;SoV