B YI~d©ã@s�ddlmZddlZddlmZddlmZmZddlm Z ddl m Z ddlm Z Gdd „d ej ƒZGd d „d ej ƒZed krŒejd d�dS)é)Ú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ƒ}|_| ¡t ddd|¡}|_t|ƒ|_|_dS)NZgui) rrÚrootZwithdrawrZ OutputWindowÚwindowrÚtext)Úclsr Úw©rúB/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_outwin.pyÚ setUpClasss  zOutputWindowTest.setUpClasscCs$|j ¡|`|`|j ¡|`dS)N)r Úcloser r Zdestroy)r rrrÚ tearDownClasss  zOutputWindowTest.tearDownClasscCs|j dd¡dS)Nz1.0Úend)r Údelete)ÚselfrrrÚsetUpszOutputWindowTest.setUpcCs*|j}| | d¡¡| | t¡¡dS)Nztest.txt)r Z assertFalseZispythonsourceÚ__file__)rrrrrÚtest_ispythonsource sz$OutputWindowTest.test_ispythonsourcecCs| |jj ¡d¡dS)NZOutput)Ú assertEqualr ÚtopÚtitle)rrrrÚtest_window_title&sz"OutputWindowTest.test_window_titlecCsd|j}|j}tƒ|_d|j_|| ¡dƒ||jjdƒd|j_|| ¡dƒ||jjdƒ|`dS)NFÚnoéTZyesé)r rrZ get_savedÚresultZ maybesaveÚcalled)rrÚeqrrrÚtest_maybesave)szOutputWindowTest.test_maybesavecCs¦|j}|jj}|jj}|jj}d}|||ƒt|ƒƒ||ddƒ| ¡ƒ|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ƒ| d¡ƒ||d d ƒ| d¡ƒ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ƒ||dd ƒd ƒ||d d ƒd ƒdS)N)zLine 1 zLine 2 zLine 3 z1.0z1.endzLine 1z2.0z2.endzLine 2z3.0z3.endzLine 3zinsert linestartzinsert lineendr%)rr r'r Ú writelines)rr#r'r.rrrÚtest_writelinescsz OutputWindowTest.test_writelinescCs |j}|j}|j}t ¡|_tƒ}|j_tƒ}|_ |  d¡|  |  ¡¡||j dƒ||jdƒ|  ttƒ›d�¡|  ttƒ›d�¡|  |  ¡¡||jttƒdfƒ| dd¡|  ttƒ›d�¡|  d¡|  |  ¡¡||jttƒd fƒ|j`|` dS) NzNot a file linerzNo special linez : 42: spam z : 21: spaméz1.0ré*)rr r rZMockÚflistrZ gotofilelinerÚ showerrorr(Z assertIsNoneZgoto_file_liner"rÚstrrÚargsr)rr#rr Zgflr3rrrÚtest_goto_file_linens(       z$OutputWindowTest.test_goto_file_lineN) Ú__name__Ú __module__Ú __qualname__Ú classmethodrrrrrr$r-r/r6rrrrr s  , r c@s2eZdZedd„ƒZdd„Ze d¡dd„ƒZdS) ÚModuleFunctionTestcCs dt_dS)N)rÚfile_line_progs)r rrrr�szModuleFunctionTest.setUpcCs6t ¡x(ttjtjƒD]\}}| |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],\}}| ||ƒ|¡|r| |dd¡qWdS)N))z"foo file "testfile1", line 42, bar)Z testfile1r1)zfoo testfile2(21) bar)Z testfile2r0)z testfile3 : 42: foo bar\n)z testfile3 r1)zfoo testfile4.py :1: )zfoo testfile4.py r)utestfile5: ᧔᧒: )Z testfile5r1)z testfile6: 42N)ztestfile7 42 textNrÚr)rZfile_line_helperrZassert_called_with)rZ mock_openZflhZ test_linesÚlineZexpected_outputrrrÚtest_file_line_helper˜s z(ModuleFunctionTest.test_file_line_helperN) r7r8r9r:rr?rZpatchrBrrrrr;�s r;Ú__main__r )Ú verbosity)ZidlelibrZunittestZ test.supportrZtkinterrrZidlelib.idle_test.mock_tkrZidlelib.idle_test.mock_idlerrZTestCaser r;r7ÚmainrrrrÚs