a
    åze.}  ã                   @   sN  d Z ddlmZ ddlZddlZddlZddlmZmZ ddl	Z	ddl	m
Z
 ddlZddlmZ ejZejZi Ze d¡ Zed< e d¡ Zed	< e d¡ Zed
< e d¡ Zed< dd„ Zdd„ ZG dd„ de	jƒZG dd„ de	jƒZG dd„ de	jƒZG dd„ de	jƒZG dd„ de	jƒZG dd„ de	jƒZedkrJe	j dd dS )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Ú
extensionsc                   C   s   t t_dt_d S )NT)ÚtestcfgÚidleConfÚuserCfgÚidlelibÚtesting© r   r   ú3/usr/lib/python3.9/idlelib/idle_test/test_config.pyÚsetUpModule   s    r   c                   C   s   t t_dt_d S )NF)Úusercfgr   r   r   r   r   r   r   r   ÚtearDownModule!   s    r   c                   @   s4   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚIdleConfParserTestzTest that IdleConfParser workszœ
        [one]
        one = false
        two = true
        three = 10

        [two]
        one = a string
        two = true
        three = false
    c                 C   sô   t  d¡}| | j ¡ | j}|  |jddddd¡ |  |jddddd¡ ||jddd	dd
ƒ || dd¡dƒ |  |jddddd¡ |  |jddddd¡ || dd¡dƒ || dd¡dƒ |  | dd¡¡ ||jdddddƒ d S )Nr   ÚoneÚbool©ÚtypeFÚtwoTÚthreeÚinté
   za stringÚtrueÚfalseÚnotZexistZDEFAULT©Údefault)r   ÚIdleConfParserÚread_stringÚassertEqualZassertIsÚGetZassertIsNone)ÚselfÚparserÚeqr   r   r   Útest_get5   s    
zIdleConfParserTest.test_getc                 C   sX   t  d¡}| | j ¡ |j}|  |dƒg d¢¡ |  |dƒg d¢¡ |  |dƒg ¡ d S )Nr   r   )r   r   r   r   z	not exist)r   r$   r%   ÚGetOptionListÚassertCountEqualr&   )r(   r)   Zget_listr   r   r   Útest_get_option_listJ   s    
z'IdleConfParserTest.test_get_option_listc                 C   s&   t  d¡}| ¡  |  | ¡ g ¡ d S )Nr   )r   r$   ÚLoadr&   Úsections©r(   r)   r   r   r   Útest_load_nothingR   s    
z$IdleConfParserTest.test_load_nothingc                 C   sF   t dƒ}t |¡}| ¡  |  | dd¡d¡ |  | d¡dg¡ d S )Núcfgparser.1úFoo BarÚfooÚnewbar)r   r   r$   r/   r&   r'   r,   )r(   Úconfig_pathr)   r   r   r   Útest_load_fileW   s
    
z!IdleConfParserTest.test_load_fileN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r+   r.   r2   r8   r   r   r   r   r   &   s   r   c                   @   sJ   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dS )ÚIdleUserConfParserTestz"Test that IdleUserConfParser worksr   c                 C   s
   t  |¡S ©N)r   ÚIdleUserConfParser)r(   Úpathr   r   r   Ú
new_parserd   s    z!IdleUserConfParserTest.new_parserc                 C   s¢   |   ¡ }| d¡ |  | ddd¡¡ |  | ddd¡¡ |  | ddd¡¡ |  | dd¡d¡ |  | ddd¡¡ |  | ¡ ddg¡ |  | dd¡d¡ d S )NÚFooÚbarr   r    ÚBar)	rA   Úadd_sectionÚ
assertTrueÚ	SetOptionÚassertFalser&   r'   r-   r0   r1   r   r   r   Útest_set_optiong   s    
z&IdleUserConfParserTest.test_set_optionc                 C   sZ   |   ¡ }| d¡ | ddd¡ |  | dd¡¡ |  | dd¡¡ |  | dd¡¡ d S )NrB   rC   r   ZNotZExist)rA   Ú
AddSectionrG   rF   ZRemoveOptionrH   r1   r   r   r   Útest_remove_optionw   s    
z)IdleUserConfParserTest.test_remove_optionc                 C   sN   |   ¡ }|  | ¡ g ¡ | d¡ | d¡ | d¡ |  | ¡ ddg¡ d S )NrB   rD   )rA   r&   r0   rJ   r-   r1   r   r   r   Útest_add_section€   s    


z'IdleUserConfParserTest.test_add_sectionc                 C   s\   |   ¡ }| d¡ | d¡ | ddd¡ |  | ¡ g d¢¡ | ¡  |  | ¡ dg¡ d S )NrB   rD   ÚIdleÚnameÚval)rD   rB   rM   )rA   rJ   rG   r-   r0   ZRemoveEmptySectionsr&   r1   r   r   r   Útest_remove_empty_sections‹   s    

z1IdleUserConfParserTest.test_remove_empty_sectionsc                 C   sv   |   ¡ }| d¡ | d¡ |  | ¡ ¡ |  | ¡ g ¡ | ddd¡ | d¡ |  | ¡ ¡ |  | ¡ dg¡ d S )NrB   rD   rC   r    )	rA   rJ   rF   ZIsEmptyr&   r0   rG   rH   r-   r1   r   r   r   Útest_is_empty•   s    


z$IdleUserConfParserTest.test_is_emptyc                 C   s¬   t  ¡ }tj |d¡}|  |¡}| d¡ | ddd¡ |  tj 	|¡¡ | 
¡  |  tj 	|¡¡ | d¡ | 
¡  |  tj 	|¡¡ W d   ƒ n1 sž0    Y  d S )Nztest.cfgrB   rC   r   )ÚtempfileÚTemporaryDirectoryÚosr@   ÚjoinrA   rJ   rG   rH   ÚexistsZSaverF   Úremove_section)r(   Ztdirr@   r)   r   r   r   Ú	test_save¢   s    



z IdleUserConfParserTest.test_saveN)r   )r9   r:   r;   r<   rA   rI   rK   rL   rP   rQ   rX   r   r   r   r   r=   a   s   
	
r=   c                   @   s,  e Zd ZdZedd„ ƒZedd„ ƒZdAdd„Zd	d
„ Ze	 
ej d¡d¡dd„ ƒZe	 
ej d¡ d¡dd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Z d4d5„ Z!d6d7„ Z"d8d9„ Z#d:d;„ Z$d<d=„ Z%d>d?„ Z&d@S )BÚIdleConfTestzTest for idleConfc              	   C   s¤   i | _ tjdd}tdkr(tj t¡}ntj t	jd ¡}|j
D ]N}tj |d| ¡}t|dƒ}| ¡ | j |< W d   ƒ q@1 s„0    Y  q@tj| _tƒ t_d S )NT©Ú_utestÚ__main__r   z../config-%s.defÚr)Úconfig_stringr   ÚIdleConfr9   rT   r@   ÚdirnameÚ__file__ÚabspathÚsysÚconfig_typesrU   ÚopenÚreadÚ_warnÚ	orig_warnr   )ÚclsÚconfÚidle_dirÚctyper7   Úfr   r   r   Ú
setUpClass·   s    
.zIdleConfTest.setUpClassc                 C   s   | j t_d S r>   )rh   r   rg   )ri   r   r   r   ÚtearDownClassÈ   s    zIdleConfTest.tearDownClassFc                 C   s   t j|dS )NrZ   )r   r_   )r(   r[   r   r   r   Ú
new_configÌ   s    zIdleConfTest.new_configc                 C   sh   t jdd}|jD ]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
        TrZ   r   )	r   r_   rd   r$   Ú
defaultCfgr%   r^   r?   r   )r(   rj   rl   r   r   r   Úmock_configÏ   s    
zIdleConfTest.mock_configÚwinzthis is test for unix systemc              
   C   s¤  | j dd}tjdddN tjddd  |  | ¡ d¡ W d   ƒ n1 sP0    Y  W d   ƒ n1 sn0    Y  tjdddx tjd	d
dJ t d¡  |  | ¡ d¡ W d   ƒ n1 sÈ0    Y  W d   ƒ n1 sæ0    Y  W d   ƒ n1 s0    Y  tjdddp |  t¡D |  t¡ | ¡  W d   ƒ n1 sV0    Y  W d   ƒ n1 sv0    Y  W d   ƒ n1 s–0    Y  d S )NTrZ   ú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©rp   r   Úpatchr&   ZGetUserCfgDirÚassertRaisesÚ
SystemExitÚFileNotFoundError©r(   rj   r   r   r   Útest_get_user_cfg_dir_unixÝ   s    L
ÿ`z'IdleConfTest.test_get_user_cfg_dir_unixzthis is test for Windows systemc              
   C   s¤  | j dd}tjdddN tjddd  |  | ¡ d¡ W d   ƒ n1 sP0    Y  W d   ƒ n1 sn0    Y  tjdddx tjd	d
dJ t d¡  |  | ¡ d¡ W d   ƒ n1 sÈ0    Y  W d   ƒ n1 sæ0    Y  W d   ƒ n1 s0    Y  tjdddp |  t¡D |  t¡ | ¡  W d   ƒ n1 sV0    Y  W d   ƒ n1 sv0    Y  W d   ƒ n1 s–0    Y  d S )NTrZ   rt   zC:\foorv   rw   zC:\foo\.idlercrx   ry   zC:\foo\cpythonrz   zC:\foo\cpython\.idlercr{   r|   r}   r‚   r   r   r   Útest_get_user_cfg_dir_windowsô   s    L
ÿ`z*IdleConfTest.test_get_user_cfg_dir_windowsc              
   C   sP  | j dd}d}tj ddi¡F tjd|d | ¡  W d   ƒ n1 sN0    Y  W d   ƒ n1 sl0    Y  |  |j ¡ |j¡ |  |j	 ¡ |j¡ |j 
¡ D ]}|  |tj¡ q¨|j	 
¡ D ]}|  |tj¡ qÆ|j ¡ D ](\}}|  |jtj |d|› d	¡¡ qä|j	 ¡ D ]2\}}|  |jtj |jp8d
d|› d¡¡ qd S )NTrZ   ru   r9   Z__foo__zos.path.dirnamerv   zconfig-z.defú#z.cfg)rp   r   r~   ÚdictZCreateConfigHandlersr-   rq   r
   rd   r   ÚvaluesZassertIsInstancer   r$   r?   Úitemsr&   ÚfilerT   r@   rU   Zuserdir)r(   rj   rk   Zdefault_parserZuser_parserZcfg_typer)   r   r   r   Útest_create_config_handlers  s&    Dÿÿz(IdleConfTest.test_create_config_handlersc                 C   s¦   | j dd}tdƒ}t |¡|jd< t |¡|jd< | ¡  | j}||jd  	dd¡dƒ ||jd  
d¡dgƒ ||jd  	dd¡dƒ ||jd  
d¡dgƒ d S )NTrZ   r3   r5   r4   r6   )rp   r   r   r$   rq   r?   r   ZLoadCfgFilesr&   r'   r,   )r(   rj   r7   r*   r   r   r   Útest_load_cfg_files&  s    z IdleConfTest.test_load_cfg_filesc                 C   sR   |   ¡ }t d¡,}| ¡  |  |jt|jƒ¡ W d   ƒ n1 sD0    Y  d S )Nz&idlelib.config.IdleUserConfParser.Save)rr   r   r~   ZSaveUserCfgFilesr&   Ú
call_countÚlenr   )r(   rj   Úmr   r   r   Útest_save_user_cfg_files;  s    z%IdleConfTest.test_save_user_cfg_filesc                 C   s¸   |   ¡ }| j}|| ddd¡dƒ ||jddddddƒ t d¡`}||jddd	ddd ƒ || ddd
¡d ƒ ||jddd
dddƒ ||jdƒ W d   ƒ n1 sª0    Y  d S )Nr   ÚEditorWindowÚwidthZ80r   r   éP   úidlelib.config._warnZfontÚ	NotExistsZNEr"   é   )rr   r&   Ú	GetOptionr   r~   rŒ   )r(   rj   r*   rg   r   r   r   Útest_get_optionB  s    zIdleConfTest.test_get_optionc                 C   s2   |   ¡ }| dddd¡ |  | ddd¡d¡ d S )Nr   rB   rC   r6   )rr   rG   r&   r–   r‚   r   r   r   rI   N  s    zIdleConfTest.test_set_optionc                 C   s¬   |   ¡ }|  | dd¡g d¢¡ |  | dd¡g d¢¡ |  tj¡ | dd¡ W d   ƒ n1 sf0    Y  |  tj¡ | dd¡ W d   ƒ n1 sž0    Y  d S )Nr#   r   )ZGeneralr   ZPyShellÚIndentÚThemeÚKeysZHistoryÚ	HelpFilesÚuserZfoobarZ	notexists)rr   r-   ÚGetSectionListr   r   ÚInvalidConfigSetZInvalidConfigTyper‚   r   r   r   Útest_get_section_listT  s    
þ
þ*z"IdleConfTest.test_get_section_listc                 C   s¤   |   ¡ }| j}|| dd¡dddœƒ || dd¡dddœƒ | dd	d
d¡ | dd	dd¡ t d¡( || d	d¡dddœƒ W d   ƒ n1 s–0    Y  d S )NúIDLE ClassicZnormalz#000000z#ffffff)Z
foregroundZ
backgroundZcursorZblackr	   ÚFoobarznormal-foregroundz#747474znormal-backgroundz#171717r“   )rr   r&   ZGetHighlightrG   r   r~   ©r(   rj   r*   r   r   r   Útest_get_highlighte  s    ÿÿÿzIdleConfTest.test_get_highlightc                 C   s`   |   ¡ }|  | dd¡| dd¡¡ |  tj¡ | dd¡ W d   ƒ n1 sR0    Y  d S )Nr#   r    rœ   Úbad)rr   r&   ZGetThemeDictr   r   ZInvalidThemer‚   r   r   r   Útest_get_theme_dictw  s    

þz IdleConfTest.test_get_theme_dictc                 C   s8   |   ¡ }|  | ¡ | d¡¡ |  | ¡ | d¡¡ d S )Nr™   rš   )rr   r&   ZCurrentThemeÚcurrent_colors_and_keysÚCurrentKeysr‚   r   r   r   Útest_get_current_theme_and_keysƒ  s    z,IdleConfTest.test_get_current_theme_and_keysc                 C   s   |   ¡ }|  | d¡d¡ d S )Nr™   r    )rr   r&   r¦   r‚   r   r   r   Útest_current_colors_and_keys‰  s    z)IdleConfTest.test_current_colors_and_keysc                 C   s^   t j}| jdd}dt _|  | ¡ d¡ dt _|  | ¡ d¡ dt _|  | ¡ d¡ |t _d S )	NTrZ   Úwin32úIDLE Classic WindowsÚdarwinúIDLE Classic OSXú
some-linuxúIDLE Modern Unix)rc   Úplatformrp   r&   Údefault_keys©r(   Zcurrent_platformrj   r   r   r   Útest_default_keysŽ  s    zIdleConfTest.test_default_keysc                 C   sˆ   t  d¡ | j}tj}||ddg ƒ ||ƒ dgƒ ||dddgƒ ||ddddgƒ ||ddd	ddgƒ t  d¡ t  d¡ d S )
Nzn
            [ZzDummy]
            enable = True
            [DISABLE]
            enable = False
            T)Z
shell_onlyÚZzDummy)Úeditor_onlyF)Úactive_onlyZDISABLE)r¶   rµ   )Úuserextnr%   r&   r   ZGetExtensionsrW   )r(   r*   ZiGEr   r   r   Útest_get_extensionsž  s    

z IdleConfTest.test_get_extensionsc                 C   s*   |   ¡ }|  | | dd¡¡g d¢¡ d S )Nr#   r   )ZAutoCompleteZCodeContextZFormatParagraphZ
ParenMatchr´   )rr   r-   ZRemoveKeyBindNamesr   r‚   r   r   r   Útest_remove_key_bind_names°  s
    þz'IdleConfTest.test_remove_key_bind_namesc                 C   s>   t  d¡ | j}|t d¡dƒ |t d¡d ƒ t  d¡ d S )Nú=
            [ZzDummy]
            enable = True
            zz-inr´   zz-out)r·   r%   r&   r   ZGetExtnNameForEventrW   )r(   r*   r   r   r   Útest_get_extn_name_for_event·  s
    
z)IdleConfTest.test_get_extn_name_for_eventc                 C   s0   t  d¡ |  t d¡ddgi¡ t  d¡ d S )Nrº   r´   ú<<z-in>>ú!<Control-Shift-KeyRelease-Insert>)r·   r%   r&   r   ZGetExtensionKeysrW   ©r(   r   r   r   Útest_get_extension_keysÁ  s
    
ÿz$IdleConfTest.test_get_extension_keysc                 C   sN   t  d¡ | j}tj}||dƒi ƒ dgdgdœ}||dƒ|ƒ t  d¡ d S )Nrº   r”   r½   z!<Control-Shift-KeyRelease-Delete>)r¼   z	<<z-out>>r´   )r·   r%   r&   r   ZGetExtensionBindingsrW   )r(   r*   ZiGEBÚexpectr   r   r   Útest_get_extension_bindingsÍ  s    
ÿz(IdleConfTest.test_get_extension_bindingsc                 C   s    |   ¡ }| j}|| dd¡ddgƒ || dd¡ddgƒ || dd¡d	d
gƒ || dd¡dgƒ || dd¡dgƒ || dd¡g ƒ || dd¡g ƒ d S )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>zIDLE Classic Macú<Command-Key-c>r­   z
NOT EXISTS)rr   r&   ZGetKeyBindingr¢   r   r   r   Útest_get_keybindingÚ  s    ÿÿÿz IdleConfTest.test_get_keybindingc                 C   s8   t j}|  ¡ }dt _|  | ¡ | | ¡ ¡¡ |t _d S )Nr®   )rc   r°   rr   r&   ZGetCurrentKeySetÚ	GetKeySetr§   r²   r   r   r   Útest_get_current_keysetë  s
    	z$IdleConfTest.test_get_current_keysetc                 C   sj   |   ¡ }|jd  d¡ |jd  d¡ |jd  ddd¡ |jd  ddd¡ |  | d¡d	 d
¡ d S )Nr   r¡   ZFoobar_cfgBindingsÚenableÚTrueZnewfooz<Key-F3>r¯   z
<<newfoo>>r   )rr   rq   rE   Úsetr&   rÆ   r‚   r   r   r   Útest_get_keysetü  s    zIdleConfTest.test_get_keysetc                 C   sL   |   ¡ }|  | d¡¡ |  | d¡¡ |  | d¡¡ |  | d¡¡ d S )NÚcopyZcutzdel-word-rightz
not-exists)rr   rF   ZIsCoreBindingrH   r‚   r   r   r   Útest_is_core_binding  s
    z!IdleConfTest.test_is_core_bindingc                 C   s  |   ¡ }|  | d¡g ¡ |  | d¡g ¡ |  tj¡" |  | d¡g ¡ W d   ƒ n1 s`0    Y  |  | ¡ | d¡| d¡ ¡ |jd  	ddd¡ |jd  	ddd	¡ |jd  	dd
d¡ |jd  	ddd¡ |  | d¡g d¢¡ |  | ¡ | d¡| d¡ ¡ d S )Nr#   rœ   r¤   r   r›   Ú4zPython;https://python.orgÚ3zPython: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Ñ   )ZPillowz(https://pillow.readthedocs.io/en/latest/rÐ   )ÚPythonzhttps://python.orgrÎ   )
rr   r&   ZGetExtraHelpSourceListr   r   rž   r-   ZGetAllExtraHelpSourcesListr   rG   r‚   r   r   r   Útest_extra_help_source_list  s(    0þÿþz(IdleConfTest.test_extra_help_source_listc                 C   sœ   ddl m} ddlm} ddlm} |  ¡ }|dƒ |ƒ }| ¡  | |dd|d¡}|  	| 
|d	d
¡|d |d dkr|dn|d |d f¡ | ¡  ~d S )Nr   )Úrequires)ÚTk)ÚFontZguiZTkFixedFontT)rN   rV   Úrootr   r   ÚfamilyÚsizer   Zweight)Útest.supportrÕ   ÚtkinterrÖ   Ztkinter.fontr×   rr   ZwithdrawÚactualr&   ZGetFontZdestroy)r(   rÕ   rÖ   r×   rj   rØ   rm   r   r   r   Útest_get_font*  s    $þzIdleConfTest.test_get_fontc                 C   s®   |   ¡ }| j}|| ¡ d dgƒ || ¡ d ddgƒ || ¡ d dgƒ || d¡d d	d
gƒ || d¡d dgƒ || d¡d ddgƒ || d¡d ddgƒ d S )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¯   )rr   r&   ZGetCoreKeysr¢   r   r   r   Útest_get_core_keys=  s    ÿÿÿzIdleConfTest.test_get_core_keysN)F)'r9   r:   r;   r<   Úclassmethodrn   ro   rp   rr   ÚunittestZskipIfrc   r°   Ú
startswithrƒ   r„   rŠ   r‹   r   r—   rI   rŸ   r£   r¥   r¨   r©   r³   r¸   r¹   r»   r¿   rÁ   rÅ   rÇ   rË   rÍ   rÔ   rÞ   rß   r   r   r   r   rY   ´   sD   






	rY   c                   @   sR   e Zd ZdZejZdZe ¡ Zdd„ Z	dd„ Z
dd„ Zd	d
„ Zdd„ Zdd„ ZdS )Ú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    c                 C   s~   |   |  d¡| j¡ t d¡ |   |  d¡| j¡ dtd d< |   |  d¡d¡ dtd d< |   |  d¡| j¡ t d¡ d S )Nr™   z<
            [Theme]
            default = True
            úIDLE NewrN   únon-existent)r&   Ú	colorkeysÚdefault_themeÚusermainr%   rW   r¾   r   r   r   Útest_old_builtin_themeX  s    
z+CurrentColorKeysTest.test_old_builtin_themec                 C   sh   t  d¡ |  |  d¡d¡ dt d d< |  |  d¡d¡ dt d d< |  |  d¡| j¡ t  d¡ d S )NzZ
            [Theme]
            default = True
            name2 = IDLE Dark
            r™   z	IDLE Darkrä   rN   rå   Úname2)rè   r%   r&   ræ   rç   rW   r¾   r   r   r   Útest_new_builtin_themej  s    
z+CurrentColorKeysTest.test_new_builtin_themec                 C   sp   t  d¡ |  |  d¡| j¡ t d¡ |  |  d¡d¡ dt d d< |  |  d¡d¡ t  d¡ t d¡ d S )Nz\
            [Theme]
            default = False
            name = Custom Dark
            r™   z[Custom Dark]
a=bzCustom Darkrå   rê   )rè   r%   r&   ræ   rç   ÚuserhighrW   r¾   r   r   r   Útest_user_override_themez  s    


z-CurrentColorKeysTest.test_user_override_themec                 C   s^   |   |  d¡| j¡ t d¡ |   |  d¡d¡ dtd d< |   |  d¡| j¡ t d¡ d S )Nrš   z`
            [Keys]
            default = True
            name = IDLE Classic Unix
            rÃ   rå   rN   )r&   ræ   r±   rè   r%   rW   r¾   r   r   r   Útest_old_builtin_keys‹  s    
z*CurrentColorKeysTest.test_old_builtin_keysc                 C   sh   t  d¡ |  |  d¡d¡ dt d d< |  |  d¡d¡ dt d d< |  |  d¡| j¡ t  d¡ d S )Nz`
            [Keys]
            default = True
            name2 = IDLE Modern Unix
            rš   r¯   rÃ   rN   rå   rê   )rè   r%   r&   ræ   r±   rW   r¾   r   r   r   Útest_new_builtin_keysš  s    
z*CurrentColorKeysTest.test_new_builtin_keysc                 C   sp   t  d¡ |  |  d¡| j¡ t d¡ |  |  d¡d¡ dt d d< |  |  d¡d¡ t  d¡ t d¡ d S )Nz[
            [Keys]
            default = False
            name = Custom Keys
            rš   z[Custom Keys]
a=bzCustom Keysrå   rê   )rè   r%   r&   ræ   r±   ÚuserkeysrW   r¾   r   r   r   Útest_user_override_keysª  s    


z,CurrentColorKeysTest.test_user_override_keysN)r9   r:   r;   r<   r   r¦   ræ   rç   r±   ré   rë   rí   rî   rï   rñ   r   r   r   r   rã   M  s   rã   c                   @   s   e Zd Zi i i i dœZdd„ Zdddiiddd	iid
ddiii dœZdd„ Zdd„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ ZdS ) ÚChangesTest)r   r	   r
   r   c                 C   s:   | j }| dddd¡ | dddd¡ | d	d
dd¡ |S )Nr   ÚMsecÚmitemÚmvalr	   ÚHsecÚhitemÚhvalr
   ÚKsecÚkitemÚkval©ÚchangesÚ
add_option©r(   rý   r   r   r   ÚloadÀ  s
    zChangesTest.loadró   rô   rõ   rö   r÷   rø   rù   rú   rû   c                 C   s   t  ¡ | _d S r>   )r   ZConfigChangesrý   r¾   r   r   r   ÚsetUpÌ  s    zChangesTest.setUpc                 C   s   |   | j| j¡ d S r>   )r&   rý   Úemptyr¾   r   r   r   Ú	test_initÏ  s    zChangesTest.test_initc                 C   s8   |   ¡ }|  || j¡ | dddd¡ |  || j¡ d S )Nr   ró   rô   rõ   )r   r&   Úloadedrþ   rÿ   r   r   r   Útest_add_optionÒ  s    zChangesTest.test_add_optionc                 C   s    | j j}|  |ddddƒ¡ |  |ddddƒ¡ |  td d d¡ |  |ddddƒ¡ |  td d d¡ |  |ddddƒ¡ |  t dd¡¡ t d¡ d S )Nr   r˜   ZwhatÚ0ú
use-spacesrÑ   )rý   Úsave_optionrF   rH   r&   rè   Ú
has_optionrW   )r(   r  r   r   r   Útest_save_optionØ  s    zChangesTest.test_save_optionc                 C   s’   |   ¡ }|  | ¡ ¡ |  td d d¡ |  td d d¡ |  td d d	¡ | d
ddd¡ |  | ¡ ¡ t 	d¡ t 	d¡ t 	d¡ d S )Nró   rô   rõ   rö   r÷   rø   rù   rú   rû   r   )
r   rF   Úsave_allr&   rè   rì   rð   rþ   rH   rW   rÿ   r   r   r   Útest_save_addedä  s    

zChangesTest.test_save_addedc                 C   sV   | j }| dddd¡ | dddd¡ | ¡  |  t dd¡¡ |  t dd¡¡ d S )Nr   r›   rÒ   ZidledocZELDIZcodeldi)rý   r  rþ   r  rH   rè   r	  rF   rÿ   r   r   r   Útest_save_helpð  s    zChangesTest.test_save_helpc                 C   s   | j }| dddd¡ d S )Nr   r˜   r  rÑ   rü   rÿ   r   r   r   Útest_save_defaultù  s    zChangesTest.test_save_defaultc              	   C   s”   |   ¡ }| dd¡ |  || j¡ dD ]h\}}t|  |dd¡ | ||¡ |  t¡( || |  t| |  W d   ƒ q&1 s„0    Y  q&d S )Nr   Zfake))r   ró   )r
   rù   rN   Úvalue)r   Zdelete_sectionr&   r  r   rG   r   ÚKeyError)r(   rý   ZcfgtypeÚsectionr   r   r   Útest_delete_section   s    zChangesTest.test_delete_sectionc                 C   s"   |   ¡ }| ¡  |  || j¡ d S r>   )r   Úclearr&   r  rÿ   r   r   r   Ú
test_clear  s    zChangesTest.test_clearN)r9   r:   r;   r  r   r  r  r  r  r
  r  r  r  r  r  r   r   r   r   rò   ¼  s    


ý	rò   c                   @   s   e Zd Zdd„ ZdS )ÚWarningTestc                 C   sð   | j }tƒ t_tƒ }t dd¡ W d   ƒ n1 s60    Y  |tjdhƒ || ¡ dƒ tƒ }t dd¡ W d   ƒ n1 s„0    Y  || ¡ dƒ tƒ }t dd¡ W d   ƒ n1 sÄ0    Y  |tjddhƒ || ¡ d	ƒ d S )
NÚwarningÚkey)r  r  zwarning
r   Úwarn2Úyek)r  r  zwarn2
)r&   rÊ   r   Z_warnedr   rg   Úgetvalue)r(   ZEqualÚstderrr   r   r   Ú	test_warn  s    ***zWarningTest.test_warnN)r9   r:   r;   r  r   r   r   r   r    s   r  r\   é   )Ú	verbosity)!r<   r   r   rc   rT   rR   rÛ   r   r   rá   r   Zidlelib.idle_test.mock_idler   r   r   r   r   r?   rè   rì   rð   r·   r   r   ZTestCaser   r=   rY   rã   rò   r  r9   r   r   r   r   r   Ú<module>   s:   ;S   oV
