B � 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�}|_|��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)NFZno�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 rZMockZflistrZ gotofileliner� showerrorr'Z assertIsNoneZgoto_file_liner!r�strr�argsr)rr"rr Zgflr1rrr�test_goto_file_linens(       z$OutputWindowTest.test_goto_file_lineN) �__name__� __module__� __qualname__� classmethodrrrrrr#r,r.r4rrrrr 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 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 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) r5r6r7r8rr=rZpatchr@rrrrr9�s r9�__main__r)� verbosity)�__doc__ZidlelibrZunittestZ test.supportrZtkinterrrZidlelib.idle_test.mock_tkrZidlelib.idle_test.mock_idlerrZTestCaser r9r5�mainrrrr�s