Viewing File: /opt/alt/python35/lib64/python3.5/idlelib/idle_test/__pycache__/test_formatparagraph.cpython-35.pyc



©ÕYfû7ã@s4ddlZddlmZddlmZddlmZmZddl	m
Z
Gdd„dejƒZGdd	„d	ejƒZ
Gd
d„dejƒZGdd
„d
ejƒZGdd„dejƒZGdd„dƒZGdd„dƒZGdd„dejƒZedkr0ejddddƒdS)éN)ÚFormatParagraph)ÚEditorWindow)ÚTkÚText)Úrequiresc@sXeZdZdZdZdZdZdZdZdd„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 commentcCsI|jtjdƒƒ|jtjdƒƒ|jtj|jƒƒdS)NÚz	

)Z
assertTrueÚfpZis_all_whiteZassertFalseÚtest_comment)Úself©rúK/opt/alt/python35/lib64/python3.5/idlelib/idle_test/test_formatparagraph.pyÚtest_is_all_whiteszIs_Get_Test.test_is_all_whitecCsq|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_indentcCsŠ|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	src@sLeZdZdZedd„ƒZdd„Zdd„Zdd	„Zd
S)ÚFindTesta`Test the find_paragraph function in FormatParagraph.

    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.
    cCs ddlm}|ƒ|_dS)Nr)r)Zidlelib.idle_test.mock_tkrÚtext)Úclsrrrr
Ú
setUpClass2szFindTest.setUpClassc	Cs·|j}|jd|ƒx‡td|ƒD]v}t|jd|ƒjdƒdƒ}xGd|d|fD]2}d||f}|jtj||ƒ|ƒqiWq)W|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
Úruncase7s	&$zFindTest.runcasec	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ƒ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_commentDs )))))))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_paragraphzs))))zFindTest.test_find_paragraphN)	rrrrÚclassmethodrr-r8r>rrrr
r(s

6rc@s"eZdZdZdd„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@Ÿsr@c@s"eZdZdZdd„ZdS)ÚReformatCommentTestz=Test the reformat_comment function without the editor window.cCsi|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¹srHc@seZdZdd„ZdS)ÚFormatClassTestcCsCtjdƒ}|j|jdƒ|jƒ|j|jdƒdS)NÚeditor)r	rrZeditwinÚclose)rÚinstancerrr
Útest_init_closeÔs
zFormatClassTest.test_init_closeN)rrrrPrrrr
rLÓsrLc@s@eZdZdd„Zdd„Zdd„Zdd„Zd	S)
ÚTextWrappercCstd|ƒ|_dS)NÚmaster)rr)rrRrrr
Ú__init__çszTextWrapper.__init__cCst|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)rrrrSrVrWrXrrrr
rQæsrQc@s%eZdZdd„ZejZdS)ÚEditorcCst|ƒ|_dS)N)rQr)rÚrootrrr
rSïszEditor.__init__N)rrrrSrZget_selection_indicesrrrr
rYîsrYc@s|eZdZdZdZdZdZedd„ƒ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.cCsPtdƒtƒ|_td|jƒ}|jj|_tj|ƒj|_dS)NZguirZ)	rrrZrYrr	rZformat_paragraph_eventÚ	formatter)rrMrrr
rs

zFormatEventTest.setUpClasscCs#|`|`|jjƒ|`dS)N)rr\rZZdestroy)rrrr
Ú
tearDownClasss
zFormatEventTest.tearDownClasscCsV|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$ÚParameterDoesNothingÚlimitr1zz    '''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.0rbz2.0z4.0r`rar1r$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_stringrcr\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.0r`rar1r$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#rbz2.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)rc)rrrJr*rrr
Útest_comment_blockKs	z"FormatEventTest.test_comment_blockN)rrrrrIrergr?rr]r_rdrfrhrrrr
r[ós	r[Ú__main__Ú	verbosityr"Úexit)ZunittestZidlelibrr	Zidlelib.EditorWindowrZtkinterrrZtest.supportrZTestCaserrr@rHrLrQrYr[rÚmainrrrr
Ú<module>sw„
Back to Directory File Manager