3 Õì2a8ã@sÞddlmZddlZddlmZddlmZmZddl m Z Gdd„dej ƒZ Gdd „d ej ƒZ Gd d „d ej ƒZGd d „d ej ƒZGdd„dej ƒZGdd„dƒZGdd„dƒZGdd„dej ƒZedkrÚejddd�dS)é)Ú paragraphN)Úrequires)ÚTkÚText)Ú EditorWindowc@s8eZdZdZdZdZdZdZdd„Zdd „Z d d „Z d S) Ú Is_Get_Testz# 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_whiteZ assertFalseÚ test_comment)Úself©r ú3/opt/alt/python36/lib64/python3.6/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)r rr r r Útest_get_comment_headers z#Is_Get_Test.test_get_comment_headerN) Ú__name__Ú __module__Ú __qualname__r rrrrrrrr r r r r src@s0eZdZedd„ƒZdd„Zdd„Zdd„Zd S) ÚFindTestcCsddlm}|ƒ|_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) r Z inserttextZstoplineÚexpectedrÚlineZ linelengthÚcolZ tempindexr r r Úruncase8s  zFindTest.runcasec Csd}|j|dddd|dd…fƒd}|j|d d d d|d d …fƒd}|j|d d d d|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,)r Zcommentr r r Útest_find_commentEs zFindTest.test_find_commentc Cs®d}|j|dddd|dd…fƒd}|j|d d d d|d d …fƒd}|j|d d d d|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 """ r/z1.0z4.0rrr5zC """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,)r Z teststringr r r Útest_find_paragraph{szFindTest.test_find_paragraphN)rrrÚ classmethodrr,r7r=r r r r r)s  6rc@seZdZdd„ZdS)ÚReformatFunctionTestcCsØ|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ú rzHello worldéz Hello worldz O hello worldééz O hello worldé é z O hello worldz O hello worldz O hello world)rr Zreformat_paragraph)r rZreformZhwr r r Útest_reformat_paragraph£s z,ReformatFunctionTest.test_reformat_paragraphN)rrrrFr r r r r? sr?c@seZdZdd„ZdS)ÚReformatCommentTestcCsJ|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?"""r0z 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)r rÚ test_stringÚresultr)r r r r Útest_reformat_comment½s z)ReformatCommentTest.test_reformat_commentN)rrrrJr r r r rGºsrGc@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)rrrrPr r r r rKÔsrKc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) Ú TextWrappercCst|d�|_dS)N)Úmaster)rr)r rRr r r Ú__init__èszTextWrapper.__init__cCs t|j|ƒS)N)Úgetattrr)r Únamer r r Ú __getattr__êszTextWrapper.__getattr__cCsdS)Nr )r r r r Úundo_block_startìszTextWrapper.undo_block_startcCsdS)Nr )r r r r Úundo_block_stopíszTextWrapper.undo_block_stopN)rrrrSrVrWrXr r r r rQçsrQc@seZdZdd„ZejZdS)ÚEditorcCst|ƒ|_dS)N)rQr)r Úrootr r r rSðszEditor.__init__N)rrrrSrZget_selection_indicesr r r r rYïsrYc@sPeZdZdZdZdZedd„ƒZedd„ƒZdd „Z d d „Z d d „Z dd„Z dS)ÚFormatEventTestzv '''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)rZ) rrrZZwithdrawrYrr rMZformat_paragraph_eventÚ formatter)rrLr r r r s    zFormatEventTest.setUpClasscCs$|`|`|jjƒ|jjƒ|`dS)N)rr\rZZupdate_idletasksZdestroy)rr r r Ú tearDownClasss  zFormatEventTest.tearDownClasscCs@|jjddƒ|jdƒ|j|jjddƒdƒ|jjddƒdS)Nz1.0z Short line ZDummyr#r")rr#r\rÚgetr()r r 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#ÚParameterDoesNothingr0)Ú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#rHZmark_setr\r^rr(Útag_add)r rrIr)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`r0)rar#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()r rrIr)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`r0)rar#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)r rrIr)r r r Útest_comment_blockNs     z"FormatEventTest.test_comment_blockN) rrrrHrergr>rr]r_rdrfrhr r r r r[ôs r[Ú__main__r!)Ú verbosityÚexit)Zidlelibrr ZunittestZ test.supportrZtkinterrrZidlelib.editorrZTestCaserrr?rGrKrQrYr[rÚmainr r r r Ús   w