3  f@sdZddlmZddlZddlmZddlmZmZddl m Z ddl m Z ddlm Z Gd d d ejZGd d d ejZed krejdddS)zTest outwin, coverage 76%.)outwinN)requires)TkText) Mbox_func)Func)mockc@s\eZdZeddZeddZddZddZd d Zd d Z d dZ ddZ ddZ dS)OutputWindowTestcCsFtdt}|_|jtjddd|}|_t||_|_dS)NZgui) rrrootZwithdrawrZ OutputWindowwindowrtext)clsr wrB/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|jjdddS)Nz1.0end)r delete)selfrrrsetUpszOutputWindowTest.setUpcCs*|j}|j|jd|j|jtdS)Nztest.txt)r Z assertFalseZispythonsource__file__)rrrrrtest_ispythonsource sz$OutputWindowTest.test_ispythonsourcecCs|j|jjjddS)NZOutput) assertEqualr toptitle)rrrrtest_window_title&sz"OutputWindowTest.test_window_titlecCsd|j}|j}t|_d|j_||jd||jjdd|j_||jd||jjd|`dS)NFnoTyes)r rrZ get_savedresultZ maybesavecalled)rreqrrrtest_maybesave)szOutputWindowTest.test_maybesavecCs|j}|jj}|jj}|jj}d}|||t|||dd|j|ddd}|||t|||ddd||ddd|ddd}|||t|||ddd||ddd |ddd }|||t|||ddd||d d d ||ddd |ddd}d}|||ddt||||ddt|||dd|||dd|||dd|jd||d d |jddS)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 rgetr writelendecoderstrip)rr$rr(r)bZ test_textZ test_text2rrr test_write7s@    zOutputWindowTest.test_writecCsb|j}|jj}|jj}|d||ddd||ddd ||d d d ||d dddS)NLine 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(r2rrrtest_writelinescsz OutputWindowTest.test_writelinescCs |j}|j}|j}tj|_t}|j_t}|_ |j d|j |j ||j d||jd|j ttd|j ttd|j |j ||jttdf|jdd|j ttd|j d|j |j ||jttd f|j`|` dS) NzNot a file linerzNo special linez : 42: spam z : 21: spamz1.0r*)rr r rZMockZflistrZ gotofileliner showerrorr)Z assertIsNoneZgoto_file_liner#rstrrargsr)rr$rr Zgflr6rrrtest_goto_file_linens(       z$OutputWindowTest.test_goto_file_lineN) __name__ __module__ __qualname__ classmethodrrrrrr%r.r3r9rrrrr s  , r c@s2eZdZeddZddZejdddZdS) ModuleFunctionTestcCs dt_dS)N)rfile_line_progs)r rrrrszModuleFunctionTest.setUpcCs6tjx(ttjtjD]\}}|j|j|qWdS)N)rZ compile_progszipZfile_line_patsr?rpattern)rZpatZregexrrrtest_compile_progssz%ModuleFunctionTest.test_compile_progsz builtins.opencCsDtj}d}x4|D],\}}|j||||r|j|ddqWdS)N"foo file "testfile1", line 42, bar testfile1r5foo testfile2(21) bar testfile2r4 testfile3 : 42: foo bar\n testfile3 foo testfile4.py :1: foo testfile4.py rtestfile5: ᧔᧒: testfile5 testfile6: 42testfile7 42 textrrrDr5rCrPrFr4rErRrHr5rGrTrJrrIrVrLr5rKrXrMNrNN)rQrSrUrWrYrZr[)rZfile_line_helperrZassert_called_with)rZ mock_openZflhZ test_lineslineZexpected_outputrrrtest_file_line_helpersz(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:mainrrrrs