3 § f©ã@s”dZddlmZddlZddlmZddlmZmZddl m Z ddl m Z ddlm Z Gd d „d ejƒZGd d „d ejƒZed kr�ejdd�dS)zTest outwin, coverage 76%.é)ÚoutwinN)Úrequires)ÚTkÚText)Ú Mbox_func)ÚFunc)Úmockc@s\eZdZedd„ƒZedd„ƒZdd„Zdd„Zd d „Zd d „Z d d„Z dd„Z dd„Z dS)ÚOutputWindowTestcCsFtdƒtƒ}|_|jƒtjddd|ƒ}|_t|ƒ|_|_dS)NZgui) rrÚrootZwithdrawrZ OutputWindowÚwindowrÚtext)Úclsr Úw©rúB/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_outwin.pyÚ setUpClasss  zOutputWindowTest.setUpClasscCs$|jjƒ|`|`|jjƒ|`dS)N)r Úcloser r Zdestroy)r rrrÚ tearDownClasss  zOutputWindowTest.tearDownClasscCs|jjddƒdS)Nz1.0Úend)r Údelete)ÚselfrrrÚsetUpszOutputWindowTest.setUpcCs*|j}|j|jdƒƒ|j|jtƒƒdS)Nztest.txt)r Z assertFalseZispythonsourceÚ__file__)rrrrrÚtest_ispythonsource sz$OutputWindowTest.test_ispythonsourcecCs|j|jjjƒdƒdS)NZOutput)Ú assertEqualr ÚtopÚtitle)rrrrÚtest_window_title&sz"OutputWindowTest.test_window_titlecCsd|j}|j}tƒ|_d|j_||jƒdƒ||jjdƒd|j_||jƒdƒ||jjdƒ|`dS)NFÚnoéTÚyesé)r rrZ get_savedÚresultZ maybesaveÚcalled)rrÚeqrrrÚtest_maybesave)szOutputWindowTest.test_maybesavecCs¦|j}|jj}|jj}|jj}d}|||ƒt|ƒƒ||ddƒ|jƒƒ|ddƒd}|||ƒt|ƒƒ||ddƒdƒ||ddƒdƒ|ddƒd}|||ƒt|ƒƒ||ddƒdƒ||ddƒd ƒ|ddƒd }|||ƒt|ƒƒ||ddƒdƒ||d d ƒd ƒ||ddƒd ƒ|ddƒd}d}|||dd�t|ƒƒ|||dd�t|ƒƒ||ddƒ|ƒ||ddƒ|ƒ||ddƒ|jdƒƒ||d d ƒ|jdƒƒdS)Ns Test bytes.z1.0z1.endrz test textzinsert linestartzinsert lineendz test text Úztest text Line 2z2.0z2.endzLine 2zLine 2 Zmytag)ZtagsZ secondtagz mytag.firstz mytag.lastzsecondtag.firstzsecondtag.lastÚ ) rr rÚgetr ÚwriteÚlenÚdecodeÚrstrip)rr$rr(r)ÚbZ test_textZ test_text2rrrÚ test_write7s@    zOutputWindowTest.test_writecCsb|j}|jj}|jj}|dƒ||ddƒdƒ||ddƒd ƒ||d d ƒd ƒ||d dƒdƒdS)NúLine 1 úLine 2 úLine 3 z1.0z1.endzLine 1z2.0z2.endzLine 2z3.0z3.endzLine 3zinsert linestartzinsert lineendr&)r/r0r1)rr r(r Ú writelines)rr$r(r2rrrÚtest_writelinescsz OutputWindowTest.test_writelinescCs |j}|j}|j}tjƒ|_tƒ}|j_tƒ}|_ |j dƒ|j |j ƒƒ||j dƒ||jdƒ|j ttƒ›d�ƒ|j ttƒ›d�ƒ|j |j ƒƒ||jttƒdfƒ|jddƒ|j ttƒ›d�ƒ|j dƒ|j |j ƒƒ||jttƒd fƒ|j`|` dS) NzNot a file linerzNo special linez : 42: spam z : 21: spaméz1.0ré*)rr r rZMockZflistrZ gotofilelinerÚ showerrorr)Z assertIsNoneZgoto_file_liner#rÚstrrÚargsr)rr$rr Zgflr6rrrÚtest_goto_file_linens(       z$OutputWindowTest.test_goto_file_lineN) Ú__name__Ú __module__Ú __qualname__Ú classmethodrrrrrr%r.r3r9rrrrr s  , r c@s2eZdZedd„ƒZdd„Zejdƒdd„ƒZdS) ÚModuleFunctionTestcCs dt_dS)N)rÚfile_line_progs)r rrrr�szModuleFunctionTest.setUpcCs6tjƒx(ttjtjƒD]\}}|j|j|ƒqWdS)N)rZ compile_progsÚzipZfile_line_patsr?rÚpattern)rZpatZregexrrrÚtest_compile_progs“sz%ModuleFunctionTest.test_compile_progsz builtins.opencCsDtj}d}x4|D],\}}|j||ƒ|ƒ|r|j|ddƒqWdS)Nú"foo file "testfile1", line 42, barÚ testfile1r5úfoo testfile2(21) barÚ testfile2r4ú testfile3 : 42: foo bar\nú testfile3 úfoo testfile4.py :1: úfoo testfile4.py rõtestfile5: ᧔᧒: Ú testfile5ú testfile6: 42útestfile7 42 textrÚr©rDr5©rCrP©rFr4©rErR©rHr5©rGrT©rJr©rIrV©rLr5©rKrX©rMN©rNN)rQrSrUrWrYrZr[)rZfile_line_helperrZassert_called_with)rZ mock_openZflhZ test_linesÚlineZexpected_outputrrrÚtest_file_line_helper˜sz(ModuleFunctionTest.test_file_line_helperN) r:r;r<r=rrBrZpatchr]rrrrr>�s r>Ú__main__r!)Ú verbosity)Ú__doc__ZidlelibrZunittestZ test.supportrZtkinterrrZidlelib.idle_test.mock_tkrZidlelib.idle_test.mock_idlerrZTestCaser r>r:ÚmainrrrrÚs