B  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}|_|tddd|}|_t||_|_dS)NZgui) rrrootZwithdrawrZ OutputWindowwindowrtext)clsr wrB/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|jdddS)Nz1.0end)r delete)selfrrrsetUpszOutputWindowTest.setUpcCs*|j}||d||tdS)Nztest.txt)r Z assertFalseZispythonsource__file__)rrrrrtest_ispythonsource sz$OutputWindowTest.test_ispythonsourcecCs||jjddS)NZOutput) assertEqualr toptitle)rrrrtest_window_title&sz"OutputWindowTest.test_window_titlecCsd|j}|j}t|_d|j_||d||jjdd|j_||d||jjd|`dS)NFZnoTZyes)r rrZ get_savedresultZ maybesavecalled)rreqrrrtest_maybesave)szOutputWindowTest.test_maybesavecCs|j}|jj}|jj}|jj}d}|||t|||dd||ddd}|||t|||ddd||ddd|ddd}|||t|||ddd||ddd |ddd }|||t|||ddd||d d d ||ddd |ddd}d}|||ddt||||ddt|||dd|||dd|||dd|d||d d |ddS)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||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-rrrtest_writelinescsz OutputWindowTest.test_writelinescCs |j}|j}|j}t|_t}|j_t}|_ | d| | ||j d||jd| ttd| ttd| | ||jttdf|dd| ttd| d| | ||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 Zgflr1rrrtest_goto_file_linens(       z$OutputWindowTest.test_goto_file_lineN) __name__ __module__ __qualname__ classmethodrrrrrr#r,r.r4rrrrr s  , r c@s2eZdZeddZddZedddZdS) ModuleFunctionTestcCs dt_dS)N)rfile_line_progs)r rrrrszModuleFunctionTest.setUpcCs6tx(ttjtjD]\}}||j|qWdS)N)rZ compile_progszipZfile_line_patsr:rpattern)rZpatZregexrrrtest_compile_progssz%ModuleFunctionTest.test_compile_progsz builtins.opencCsDtj}d}x4|D],\}}|||||r||ddqWdS)N))z"foo file "testfile1", line 42, bar)Z testfile1r0)zfoo testfile2(21) bar)Z testfile2r/)z testfile3 : 42: foo bar\n)z testfile3 r0)zfoo testfile4.py :1: )zfoo testfile4.py r)utestfile5: ᧔᧒: )Z testfile5r0)z testfile6: 42N)ztestfile7 42 textNrr)rZfile_line_helperrZassert_called_with)rZ mock_openZflhZ test_lineslineZexpected_outputrrrtest_file_line_helpers z(ModuleFunctionTest.test_file_line_helperN) r5r6r7r8rr=rZpatchr@rrrrr9s r9__main__r) verbosity)__doc__ZidlelibrZunittestZ test.supportrZtkinterrrZidlelib.idle_test.mock_tkrZidlelib.idle_test.mock_idlerrZTestCaser r9r5mainrrrrs