a  ze.@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 wrQ/opt/bitninja-python-dojo/embedded/lib/python3.9/idlelib/idle_test/test_outwin.py setUpClasss  zOutputWindowTest.setUpClasscCs$|j|`|`|j|`dSN)r closer r Zdestroyr rrr tearDownClasss  zOutputWindowTest.tearDownClasscCs|jdddS)N1.0end)r deleteselfrrrsetUpszOutputWindowTest.setUpcCs*|j}||d||tdS)Nztest.txt)r Z assertFalseZispythonsource__file__)rrrrrtest_ispythonsource sz$OutputWindowTest.test_ispythonsourcecCs||jjddS)NZOutput) assertEqualr toptitlerrrrtest_window_title&sz"OutputWindowTest.test_window_titlecCsd|j}|j}t|_d|j_||d||jjdd|j_||d||jjd|`dS)NFnoTZyes)r rrZ get_savedresultZ maybesavecalled)rreqrrrtest_maybesave)szOutputWindowTest.test_maybesavecCs||j}|jj}|jj}|jj}|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)Nrrz test text1.endinsert linestartinsert lineendz test text ztest text Line 22.02.endLine 2Line 2 Zmytag)tagsZ secondtagz mytag.firstz mytag.lastzsecondtag.firstzsecondtag.last )rr rgetr writelenrstrip)rr'rr3r4Z test_textZ test_text2rrr test_write7s:    zOutputWindowTest.test_writecCsb|j}|jj}|jj}|d||ddd||ddd||dd d ||d d d dS)N)zLine 1 r0zLine 3 rr)zLine 1r-r.r/z3.0z3.endzLine 3r*r+r,)rr r3r writelines)rr'r3r8rrrtest_writelines^sz 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: spamrr*)rr r rZMockflistrZ gotofileliner showerrorr4Z assertIsNoneZgoto_file_liner&r strrargsr)rr'rr Zgflr=rrrtest_goto_file_lineis(       z$OutputWindowTest.test_goto_file_lineN) __name__ __module__ __qualname__ classmethodrrrrr!r(r7r9r@rrrrr s  ' r c@s2eZdZeddZddZedddZdS) ModuleFunctionTestcCs dt_dSr)rfile_line_progsrrrrrszModuleFunctionTest.setUpcCs2tttjtjD]\}}||j|qdSr)rZ compile_progszipZfile_line_patsrFrpattern)rpatZregexrrrtest_compile_progssz%ModuleFunctionTest.test_compile_progsz builtins.opencCs@tj}d}|D],\}}|||||r||ddqdS)N))z"foo file "testfile1", line 42, bar)Z testfile1r;)zfoo testfile2(21) bar)Z testfile2r:)z testfile3 : 42: foo bar\n)z testfile3 r;)zfoo testfile4.py :1: )zfoo testfile4.py r#)utestfile5: ᧔᧒: )Z testfile5r;)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) rArBrCrDrrJrZpatchrMrrrrrEs  rE__main__r$) verbosity)__doc__ZidlelibrZunittestZ test.supportrtkinterrrZidlelib.idle_test.mock_tkrZidlelib.idle_test.mock_idlerrZTestCaser rErAmainrrrrs     |