Your IP : 3.139.80.194


Current Path : /opt/alt/python36/lib64/python3.6/idlelib/idle_test/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/idle_test/__pycache__/test_paragraph.cpython-36.pyc

3

� f8�@s�dZddlmZddlZddlmZddlmZm	Z	ddl
mZGdd�dej�Z
Gd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�d�ZGdd�d�ZGdd�dej�Zedkr�ejddd�dS)zTest paragraph, coverage 76%.�)�	paragraphN)�requires)�Tk�Text)�EditorWindowc@s<eZdZdZdZdZdZdZdZdd�Z	d	d
�Z
dd�Zd
S)�Is_Get_TestzTest the is_ and get_ functionsz# This is a commentzThis is not a commentz# This is a comment   z    # This is a commentz    This is not a commentcCs6|jtjd��|jtjd��|jtj|j��dS)N�z	

)Z
assertTrue�pgZis_all_whiteZassertFalse�test_comment)�self�r�E/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_paragraph.py�test_is_all_whiteszIs_Get_Test.test_is_all_whitecCsR|j}|tj|j�d�|tj|j�d�|tj|j�d�|tj|j�d�dS)Nrz    )�assertEqualr	Z
get_indentr
�trailingws_comment�leadingws_comment�leadingws_nocomment)r�Equalrrr
�test_get_indents
zIs_Get_Test.test_get_indentcCsd|j}|tj|j�d�|tj|j�d�|tj|j�d�|tj|j�d�|tj|j�d�dS)N�#z    #z    r)rr	Zget_comment_headerr
rrr�test_nocomment)rrrrr
�test_get_comment_headersz#Is_Get_Test.test_get_comment_headerN)�__name__�
__module__�__qualname__�__doc__r
rrrrrrrrrrr
r
src@s4eZdZdZedd��Zdd�Zdd�Zdd	�Zd
S)�FindTestaaTest the find_paragraph function in paragraph module.

    Using the runcase() function, find_paragraph() is called with 'mark' set at
    multiple indexes before and inside the test paragraph.

    It appears that code with the same indentation as a quoted string is grouped
    as part of the same paragraph, which is probably incorrect behavior.
    cCsddlm}|�|_dS)Nr)r)Zidlelib.idle_test.mock_tkr�text)�clsrrrr
�
setUpClass3szFindTest.setUpClassc	Cs�|j}|jd|�xftd|�D]X}t|jd|�jd�d�}x6d|d|fD]$}d||f}|jtj||�|�qNWqW|j	dd�dS)	Nz1.0�z%d.end�.r�z%d.%d�end)
r�insert�range�int�index�splitrr	Zfind_paragraph�delete)	rZ
inserttextZstopline�expectedr�lineZ
linelength�colZ	tempindexrrr
�runcase8szFindTest.runcasec	Csd}|j|dddd|dd�f�d}|j|d	d
dd|dd
�f�d}|j|d	d
dd|dd�f�d}|j|dd
dd|dd�f�d}|j|dd
dd|dd�f�d}|j|dd
dd|dd�f�d}|j|dd
dd|dd�f�d}|j|dd
dd|dd�f�dS)Nz;# Comment block with no blank lines before
# Comment line

�z1.0z3.0rr�:zG
# Comment block with whitespace line before and after
# Comment line

�z2.0z4.0r �FzS
    # Indented comment block with whitespace before and after
    # Comment line

z    #�Rz
# Single line comment

�z4
    # Single line comment with leading whitespace

�3z0
# Comment immediately followed by code
x = 42

�(z=
    # Indented comment immediately followed by code
x = 42

�5z=
# Comment immediately followed by indented code
    x = 42

�1)r-)rZcommentrrr
�test_find_commentEs zFindTest.test_find_commentc	Cs�d}|j|dddd|dd�f�d}|j|d	d
dd|dd
�f�d}|j|d	d
dd|dd�f�d}|j|dd
dd|dd�f�d}|j|dd
dd|dd�f�dS)Nz6"""String with no blank lines before
String line
"""

r0z1.0z4.0rrr6zC
"""String with whitespace line before and after
String line.
"""

�z2.0z5.0r �BzV
    """Indented string with whitespace before and after
    Comment string.
    """

z    �Uz
"""Single line string."""

r.z3.0�z8
    """Single line string with leading whitespace."""

�7)r-)rZ
teststringrrr
�test_find_paragraph{szFindTest.test_find_paragraphN)	rrrr�classmethodrr-r8r>rrrr
r)s

6rc@seZdZdZdd�ZdS)�ReformatFunctionTestz?Test the reformat_paragraph function without the editor window.cCs�|j}tj}d}||dd�d�||dd�d�|||d�d�|||d�d�|||d	�d
�|||d�d
�|||d�d�d
}|||d�d�|||d�d�|||d	�d�|||d�d�|||d�d
�dS)Nz
O hello world� r zHello    world�zHello  worldz
O
hello
world��z
O hello
world��
z
O hello worldz
O
hello
worldz
O hello
world)rr	Zreformat_paragraph)rrZreformZhwrrr
�test_reformat_paragraph�s z,ReformatFunctionTest.test_reformat_paragraphN)rrrrrGrrrr
r@�sr@c@seZdZdZdd�ZdS)�ReformatCommentTestz=Test the reformat_comment function without the editor window.cCsJ|j}d}tj|dd�}d}|||�d}tj|dd�}d}|||�dS)Nzu    """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""r1z    zy    """this is a test of a reformat for a triple quoted string will it
    reformat to less than 70 characters for me?"""zm# this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?rzo# this is a test of a reformat for a triple quoted string will it
# reformat to less than 70 characters for me?)rr	Zreformat_comment)rr�test_string�resultr*r
rrr
�test_reformat_comment�s
z)ReformatCommentTest.test_reformat_commentN)rrrrrKrrrr
rH�srHc@seZdZdd�ZdS)�FormatClassTestcCs2tjd�}|j|jd�|j�|j|jd�dS)N�editor)r	�FormatParagraphrZeditwin�close)r�instancerrr
�test_init_close�s
zFormatClassTest.test_init_closeN)rrrrQrrrr
rL�srLc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TextWrappercCst|d�|_dS)N)�master)rr)rrSrrr
�__init__�szTextWrapper.__init__cCst|j|�S)N)�getattrr)r�namerrr
�__getattr__�szTextWrapper.__getattr__cCsdS)Nr)rrrr
�undo_block_start�szTextWrapper.undo_block_startcCsdS)Nr)rrrr
�undo_block_stop�szTextWrapper.undo_block_stopN)rrrrTrWrXrYrrrr
rR�srRc@seZdZdd�ZejZdS)�EditorcCst|�|_dS)N)rRr)r�rootrrr
rT�szEditor.__init__N)rrrrTrZget_selection_indicesrrrr
rZ�srZc@sTeZdZdZdZdZdZedd��Zedd��Z	d	d
�Z
dd�Zd
d�Zdd�Z
dS)�FormatEventTestz�Test the formatting of text inside a Text widget.

    This is done with FormatParagraph.format.paragraph_event,
    which calls functions in the module as appropriate.
    zv    '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?'''
a    '''The first line is under the max width.
    The second line's length is way over the max width. It goes on and on until it is over 100 characters long.
    Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it.
    '''
a,# The first line is under the max width.
# The second line's length is way over the max width. It goes on and on until it is over 100 characters long.
# Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it.
# The fourth line is short like the first line.cCsBtd�t�|_|jj�t|jd�}|jj|_tj|�j|_	dS)NZgui)r[)
rrr[ZwithdrawrZrr	rNZformat_paragraph_event�	formatter)rrMrrr
r
s

zFormatEventTest.setUpClasscCs$|`|`|jj�|jj�|`dS)N)rr]r[Zupdate_idletasksZdestroy)rrrr
�
tearDownClasss

zFormatEventTest.tearDownClasscCs@|jjdd�|jd�|j|jjdd�d�|jjdd�dS)Nz1.0zShort line
ZDummyr$r#)rr$r]r�getr))rrrr
�test_short_lines
zFormatEventTest.test_short_linecCs�|j}|jd|j�|jdd�|jddd�|jdd�}d}|j||�|jdd�|jd|j�|jdd	d
�|jddd�|jdd�}d}|j||�|jdd�dS)Nz1.0r$�ParameterDoesNothingr1)�limitzz    '''this is a test of a reformat for a triple quoted string will it
    reformat to less than 70 characters for me?'''
r#�selz1.11z1.endzv    '''this is a test of a reformat for a triple quoted string will it reformat
 to less than 70 characters for me?''')	rr$rIZmark_setr]r_rr)�tag_add)rrrJr*rrr
�test_long_line$szFormatEventTest.test_long_linecCs\|j}|jd|j�|jddd�|jddd�|jdd�}d	}|j||�|jdd
�dS)Nz1.0rcz2.0z4.0rar1)rbr$z�    The second line's length is way over the max width. It goes on and
    on until it is over 100 characters long. Same thing with the third
    line. It is also way over the max width, but FormatParagraph will
    fix it.
r#)rr$�multiline_test_stringrdr]r_rr))rrrJr*rrr
�test_multiple_lines?sz#FormatEventTest.test_multiple_linescCs�|j}|jd|j�|jddd�|jdd�}d}|j||�|jdd�|jd|j�|jdd	d
�|jddd�|jdd�}d}|j||�|jdd�dS)Nz1.0rar1)rbr$a/# The first line is under the max width. The second line's length is
# way over the max width. It goes on and on until it is over 100
# characters long. Same thing with the third line. It is also way over
# the max width, but FormatParagraph will fix it. The fourth line is
# short like the first line.
r#rcz2.0z3.0z�# The first line is under the max width.
# The second line's length is way over the max width. It goes on and
# on until it is over 100 characters long.
)rr$�multiline_test_commentr]r_rr)rd)rrrJr*rrr
�test_comment_blockNsz"FormatEventTest.test_comment_blockN)rrrrrIrfrhr?rr^r`rergrirrrr
r\�s
r\�__main__r")�	verbosity�exit)rZidlelibrr	ZunittestZtest.supportrZtkinterrrZidlelib.editorrZTestCaserrr@rHrLrRrZr\r�mainrrrr
�<module>s w

?>