Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/idlelib/idle_test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/idlelib/idle_test/__pycache__/test_outwin.cpython-310.pyc

o

0�i.�@s�dZddlmZddlZddlmZddlmZmZddl	m
Z
ddlmZddlm
Z
Gd	d
�d
ej�ZGdd�dej�Zed
krJejdd�dSdS)zTest outwin, coverage 76%.�)�outwinN)�requires)�Tk�Text)�	Mbox_func)�Func)�mockc@s\eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)�OutputWindowTestcCsFtd�t�}|_|��t�ddd|�}|_t|�|_|_dS)NZgui)	rr�rootZwithdrawrZOutputWindow�windowr�text)�clsr
�w�r�D/opt/alt/python310/lib64/python3.10/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)N�1.0�end)r�delete��selfrrr�setUpszOutputWindowTest.setUpcCs*|j}|�|�d��|�|�t��dS)Nztest.txt)rZassertFalseZispythonsource�__file__)rrrrr�test_ispythonsource sz$OutputWindowTest.test_ispythonsourcecCs|�|jj��d�dS)NZOutput)�assertEqualr�top�titlerrrr�test_window_title&sz"OutputWindowTest.test_window_titlecCsd|j}|j}t�|_d|j_||��d�||jjd�d|j_||��d�||jjd�|`dS)NFZno�TZyes�)rrrZ	get_saved�resultZ	maybesave�called)rr�eqrrr�test_maybesave)szOutputWindowTest.test_maybesavecCs||j}|jj}|jj}|jj}|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)Nrrz	test text�1.end�insert linestart�insert lineendz
test text
�ztest text
Line 2�2.0�2.end�Line 2�Line 2
Zmytag)ZtagsZ	secondtagzmytag.firstz
mytag.lastzsecondtag.firstzsecondtag.last�
)rrr�getr�write�len�rstrip)rr&rr1r2Z	test_textZ
test_text2rrr�
test_write7s:



zOutputWindowTest.test_writecCsb|j}|jj}|jj}|d�||dd�d�||dd�d�||dd	�d
�||dd�d
�dS)N)zLine 1
r/zLine 3
rr(zLine 1r,r-r.z3.0z3.endzLine 3r)r*r+)rrr1r�
writelines)rr&r1r6rrr�test_writelines^sz 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�rr�*)rrrrZMockZflistrZgotofileliner�	showerrorr2ZassertIsNoneZgoto_file_liner%r �strr�argsr)rr&rrZgflr:rrr�test_goto_file_lineis(


z$OutputWindowTest.test_goto_file_lineN)
�__name__�
__module__�__qualname__�classmethodrrrrr!r'r5r7r=rrrrr	s

'r	c@s2eZdZedd��Zdd�Ze�d�dd��ZdS)	�ModuleFunctionTestcCs
dt_dSr)r�file_line_progsrrrrr�s
zModuleFunctionTest.setUpcCs2t��ttjtj�D]\}}|�|j|�qdSr)rZ
compile_progs�zipZfile_line_patsrCr�pattern)rZpatZregexrrr�test_compile_progs�s�z%ModuleFunctionTest.test_compile_progsz
builtins.opencCs@tj}d}|D]\}}|�||�|�|r|�|dd�qdS)N))z"foo file "testfile1", line 42, bar)Z	testfile1r9)zfoo testfile2(21) bar)Z	testfile2r8)z  testfile3  : 42: foo bar\n)z
  testfile3  r9)zfoo testfile4.py :1: )zfoo testfile4.py r")utestfile5: ᧔᧒: )Z	testfile5r9)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)	r>r?r@rArrFrZpatchrIrrrrrB�s
rB�__main__r#)�	verbosity)�__doc__ZidlelibrZunittestZtest.supportrZtkinterrrZidlelib.idle_test.mock_tkrZidlelib.idle_test.mock_idlerrZTestCaser	rBr>�mainrrrr�<module>s|�