B YI~dcã@s²ddlmZddlZddlmZddlmZddlmZddl m Z ej Z Gdd„dej ƒZGd d „d ej ƒZd d „ZGd d„dej ƒZGdd„dej ƒZedkr®ejdd�dS)é)ÚeditorN)Ú namedtuple)Úrequires)ÚTk)ÚFuncc@s,eZdZedd„ƒZedd„ƒZdd„ZdS)ÚEditorWindowTestcCstdƒtƒ|_|j ¡dS)NÚgui)rrÚrootÚwithdraw)Úcls©r úB/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_editor.pyÚ setUpClassszEditorWindowTest.setUpClasscCsB|j ¡x$|jj dd¡D]}|j |¡qW|j ¡|`dS)NÚafterÚinfo)r Úupdate_idletasksÚtkÚcallÚ after_cancelÚdestroy)r Úidr r r Ú tearDownClasss   zEditorWindowTest.tearDownClasscCs(t|jd�}| |j|j¡| ¡dS)N)r )ÚEditorr Ú assertEqualÚ_close)ÚselfÚer r r Ú test_inits zEditorWindowTest.test_initN)Ú__name__Ú __module__Ú __qualname__Ú classmethodrrrr r r r r s  rc@s$eZdZdd„Zdd„Zdd„ZdS)ÚTestGetLineIndentc CsPxJdD]B}x|D]6\}}|j|d��| tj|dd�|¡WdQRXq WdS)N) )z no spaces)rr)z space test)r%r%)z tab test)r#r%)z double tabs test)r$r')z mixed test)ér')z mixed test)r/r&)z mixed test)r/r')z mixed test)ér%)z mixed test)r0r/)z mixed test)r0r&)z newline test)rr)r*r%)r+)r,rrr-)rÚtestsr*Úexpectedr r r Útest_tabwidth_4-s  z!TestGetLineIndent.test_tabwidth_4c CsHd}x>|D]6\}}|j|d��| tj|dd�|¡WdQRXq WdS)N) )z no spaces)rr)z space test)r'r')z tab test)r#r')z double tabs test)r$é)z mixed test)é r4)z mixed test)r5é )z mixed test)r5r4)z mixed test)r0r')z mixed test)r0r5)z mixed test)r0r6)z newline test)rr)r*r')r+)r,rrr-)rr1r*r2r r r Útest_tabwidth_8Fs  z!TestGetLineIndent.test_tabwidth_8N)rrr r.r3r7r r r r r"#s r"cCs$| dd¡| d|¡| ¡dS)Nz1.0Úend)ÚdeleteÚinsertÚupdate)ÚtextÚstringr r r r:`s  r:c@s,eZdZedd„ƒZedd„ƒZdd„ZdS)ÚIndentAndNewlineTestcCs<tdƒtƒ|_|j ¡t|jd�|_d|j_d|j_dS)Nr)r r$)rrr r rÚwindowZ indentwidthr+)r r r r rhs  zIndentAndNewlineTest.setUpClasscCsP|j ¡|`|j ¡x$|jj dd¡D]}|j |¡q*W|j ¡|`dS)Nrr)r?rr rrrrr)r rr r r rqs   z"IndentAndNewlineTest.tearDownClassc Csl|j}|j}|j}|j}|j}tdddddgƒ}|dddd ƒ|d d d d ƒ|dd d dƒ|ddddƒ|ddddƒ|dddd ƒ|ddddƒ|ddd d ƒ|d!dd"dƒf }d#|_x\|D]T}|j|jd$��<t ||jƒ|  d%|j ¡|dd&�||d'd(ƒ|j ƒWdQRXq¬Wt |d)ƒ|  d*d+d ¡|dƒ||d'd(ƒd,ƒd-|_t |d.ƒ|  d%d/¡|dƒ||d'd(ƒd0ƒdS)1NZTestsÚlabelr<r2Úmarkz"Empty line inserts with no indent.z def __init__(self):z def __init__(self): z1.endz+Inside bracket before space, deletes space.z def f1(self, a, b):z def f1(self, a, b): z1.14z*Inside bracket after space, deletes space.z1.15z(Inside string with one line - no indent.z """Docstring."""z """Docstring. """ z&Inside string with more than one line.z% """Docstring. Docstring Line 2"""z) """Docstring. Docstring Line 2 """ z2.18zBackslash with one line.za =\za =\ z"Backslash with more than one line.za =\ multiline\z%a =\ multiline\ z2.endz Block opener - indents +1 level.z def f1(self): passz def f1(self): pass z Block closer - dedents -1 level.z def f1(self): pass r()r@r:)Zeventz1.0r8z& def f1(self, a, b): return a + bZselz1.17z- def f1(self, a, return a + b z>>> z >>> a =z1.5z >>> a = )rr?r<ÚgetZnewline_and_indent_eventrZprompt_last_liner,r@r:Zmark_setrAr2Ztag_add) rÚeqÚwr<rBÚnlZTestInfor1Ztestr r r Útest_indent_and_newline_event{st       z2IndentAndNewlineTest.test_indent_and_newline_eventN)rrr r!rrrFr r r r r>fs r>c@s:eZdZedd„ƒZedd„ƒZGdd„dƒZdd„Zd S) Ú RMenuTestcCs,tdƒtƒ|_|j ¡t|jd�|_dS)Nr)r )rrr r rr?)r r r r rÃs zRMenuTest.setUpClasscCsP|j ¡|`|j ¡x$|jj dd¡D]}|j |¡q*W|j ¡|`dS)Nrr)r?rr rrrrr)r rr r r rÊs   zRMenuTest.tearDownClassc@seZdZdd„ZdS)zRMenuTest.DummyRMenucCsdS)Nr )ÚxÚyr r r Útk_popupÕózRMenuTest.DummyRMenu.tk_popupN)rrr rJr r r r Ú DummyRMenuÔsrLcCsdS)Nr )rr r r Ú test_rclick×szRMenuTest.test_rclickN)rrr r!rrrLrMr r r r rGÁs  rGÚ__main__r$)Ú verbosity)ZidlelibrZunittestÚ collectionsrZ test.supportrZtkinterrZidlelib.idle_test.mock_idlerZ EditorWindowrZTestCaserr"r:r>rGrÚmainr r r r Ús     =[