ž ©ÿfÝ7c@s=ddlZddlmZddlmZddlmZmZm Z ddl m Z Gdd„dej ƒZ Gdd „d ej ƒZGd d „d ej ƒZGd d „d ej ƒZGdd„dej ƒZGdd„dƒZGdd„dƒZGdd„dej ƒZedkr9ejddddƒndS(iN(uFormatParagraph(u EditorWindow(uTkuTextuTclError(urequirescBs\|EeZdZdZdZdZdZdZdZdd„Z d d „Z d d „Z d S(u Is_Get_TestuTest the is_ and get_ functionsu# This is a commentuThis is not a commentu# This is a comment u # This is a commentu This is not a commentcCsI|jtjdƒƒ|jtjdƒƒ|jtj|jƒƒdS(Nuu (u assertTrueufpu is_all_whiteu assertFalseu test_comment(uself((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyutest_is_all_whitesuIs_Get_Test.test_is_all_whitecCsq|j}|tj|jƒdƒ|tj|jƒdƒ|tj|jƒdƒ|tj|jƒdƒdS(Nuu (u assertEqualufpu get_indentu test_commentutrailingws_commentuleadingws_commentuleadingws_nocomment(uselfuEqual((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyutest_get_indents  uIs_Get_Test.test_get_indentcCsŠ|j}|tj|jƒdƒ|tj|jƒdƒ|tj|jƒdƒ|tj|jƒdƒ|tj|jƒdƒdS(Nu#u #u u(u assertEqualufpuget_comment_headeru test_commentutrailingws_commentuleadingws_commentuleadingws_nocommentutest_nocomment(uselfuEqual((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyutest_get_comment_headers  u#Is_Get_Test.test_get_comment_headerN( u__name__u __module__u __qualname__u__doc__u test_commentutest_nocommentutrailingws_commentuleadingws_commentuleadingws_nocommentutest_is_all_whiteutest_get_indentutest_get_comment_header(u __locals__((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyu Is_Get_Test s  u Is_Get_TestcBsP|EeZdZdZedd„ƒZdd„Zdd„Zdd „Zd S( uFindTestu`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(Ni(uText(uidlelib.idle_test.mock_tkuTextutext(uclsuText((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyu setUpClass2suFindTest.setUpClassc Cs·|j}|jd|ƒx‡td|ƒD]v}t|jd|ƒjdƒdƒ}xGd|d|fD]2}d||f}|jtj||ƒ|ƒqiWq)W|j ddƒdS( Nu1.0iu%d.endu.iiu%d.%duend( utextuinserturangeuintuindexusplitu assertEqualufpufind_paragraphudelete( uselfu inserttextustoplineuexpectedutextulineu linelengthucolu tempindex((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyuruncase7s &$uFindTest.runcasec 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ƒd}|j|dd dd|d d…fƒd}|j|dd dd|d d…fƒd}|j|dd dd|d d…fƒdS(Nu;# Comment block with no blank lines before # Comment line iu1.0u3.0u#ii:uG # Comment block with whitespace line before and after # Comment line iu2.0u4.0iiFuS # Indented comment block with whitespace before and after # Comment line u #iRu # Single line comment iu4 # Single line comment with leading whitespace i3u0 # Comment immediately followed by code x = 42 i(u= # Indented comment immediately followed by code x = 42 i5u= # Comment immediately followed by indented code x = 42 i1(uruncase(uselfucomment((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyutest_find_commentDs )))))))uFindTest.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(Nu6"""String with no blank lines before String line """ iu1.0u4.0uii5uC """String with whitespace line before and after String line. """ iu2.0u5.0iiBuV """Indented string with whitespace before and after Comment string. """ u iUu """Single line string.""" iu3.0iu8 """Single line string with leading whitespace.""" i7(uruncase(uselfu teststring((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyutest_find_paragraphzs))))uFindTest.test_find_paragraphN( u__name__u __module__u __qualname__u__doc__u classmethodu setUpClassuruncaseutest_find_commentutest_find_paragraph(u __locals__((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyuFindTest(s  6uFindTestcBs&|EeZdZdZdd„ZdS(uReformatFunctionTestu?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(Nu O hello worldu iuHello worldiu Hello worldu O hello worldiiu O hello worldi i u O hello worldu O hello worldu O hello world(u assertEqualufpureformat_paragraph(uselfuEqualureformuhw((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyutest_reformat_paragrah¢s   u+ReformatFunctionTest.test_reformat_paragrahN(u__name__u __module__u __qualname__u__doc__utest_reformat_paragrah(u __locals__((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyuReformatFunctionTestŸsuReformatFunctionTestcBs&|EeZdZdZdd„ZdS(uReformatCommentTestu=Test the reformat_comment function without the editor window.cCsi|j}d}tj|ddƒ}d}|||ƒd}tj|ddƒ}d}|||ƒdS(Nuu """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""iFu uy """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""um# this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?u#uo# this is a test of a reformat for a triple quoted string will it # reformat to less than 70 characters for me?(u assertEqualufpureformat_comment(uselfuEqualu test_stringuresultuexpectedu test_comment((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyutest_reformat_comment¼s  u)ReformatCommentTest.test_reformat_commentN(u__name__u __module__u __qualname__u__doc__utest_reformat_comment(u __locals__((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyuReformatCommentTest¹suReformatCommentTestcBs |EeZdZdd„ZdS(uFormatClassTestcCsCtjdƒ}|j|jdƒ|jƒ|j|jdƒdS(Nueditor(ufpuFormatParagraphu assertEqualueditwinucloseuNone(uselfuinstance((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyutest_init_closeÔs uFormatClassTest.test_init_closeN(u__name__u __module__u __qualname__utest_init_close(u __locals__((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyuFormatClassTestÓsuFormatClassTestcBsD|EeZdZdd„Zdd„Zdd„Zdd„Zd S( u TextWrappercCstd|ƒ|_dS(Numaster(uTextutext(uselfumaster((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyu__init__çsuTextWrapper.__init__cCst|j|ƒS(N(ugetattrutext(uselfuname((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyu __getattr__ésuTextWrapper.__getattr__cCsdS(N((uself((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyuundo_block_startësuTextWrapper.undo_block_startcCsdS(N((uself((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyuundo_block_stopìsuTextWrapper.undo_block_stopN(u__name__u __module__u __qualname__u__init__u __getattr__uundo_block_startuundo_block_stop(u __locals__((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyu TextWrapperæs   u TextWrappercBs)|EeZdZdd„ZejZdS(uEditorcCst|ƒ|_dS(N(u TextWrapperutext(uselfuroot((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyu__init__ïsuEditor.__init__N(u__name__u __module__u __qualname__u__init__u EditorWindowuget_selection_indices(u __locals__((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyuEditorîs uEditorcBs€|EeZdZdZdZdZdZedd„ƒZedd„ƒZ d d „Z d d „Z d d„Z dd„Z dS(uFormatEventTestu­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. uv '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?''' u '''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. ''' u,# 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(Nuguiuroot( urequiresuTkurootuEditorutextufpuFormatParagraphuformat_paragraph_eventu formatter(uclsueditor((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyu setUpClass s   uFormatEventTest.setUpClasscCs#|jjƒ|`|`|`dS(N(urootudestroyutextu formatter(ucls((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyu tearDownClasss uFormatEventTest.tearDownClasscCsV|jjddƒ|jdƒ|j|jjddƒdƒ|jjddƒdS(Nu1.0u Short line uDummyuinsertuend(utextuinsertu formatteru assertEqualugetudelete(uself((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyutest_short_lines uFormatEventTest.test_short_linecCsà|j}|jd|jƒ|jddƒ|jdƒ|jddƒ}d}|j||ƒ|jddƒ|jd|jƒ|jdddƒ|jdƒ|jddƒ}d }|j||ƒ|jddƒdS( Nu1.0uinsertuParameterDoesNothinguz '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?''' uenduselu1.11u1.enduv '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?'''( utextuinsertu test_stringumark_setu formatterugetu assertEqualudeleteutag_add(uselfutexturesultuexpected((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyutest_long_line"s   uFormatEventTest.test_long_linecCsx|j}|jd|jƒ|jdddƒ|jdƒ|jddƒ}d}|j||ƒ|jddƒdS( Nu1.0uselu2.0u4.0uParameterDoesNothinguinsertuà 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. uend(utextuinsertumultiline_test_stringutag_addu formatterugetu assertEqualudelete(uselfutexturesultuexpected((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyutest_multiple_lines=s  u#FormatEventTest.test_multiple_linescCsÐ|j}|jd|jƒ|jdƒ|jddƒ}d}|j||ƒ|jddƒ|jd|jƒ|jdddƒ|jdƒ|jddƒ}d }|j||ƒ|jddƒdS( Nu1.0uParameterDoesNothinguinsertu/# 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. uenduselu2.0u3.0u™# 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. (utextuinsertumultiline_test_commentu formatterugetu assertEqualudeleteutag_add(uselfutexturesultuexpected((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyutest_comment_blockLs   u"FormatEventTest.test_comment_blockN(u__name__u __module__u __qualname__u__doc__u test_stringumultiline_test_stringumultiline_test_commentu classmethodu setUpClassu tearDownClassutest_short_lineutest_long_lineutest_multiple_linesutest_comment_block(u __locals__((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyuFormatEventTestós    uFormatEventTestu__main__u verbosityiuexit(uunittestuidlelibuFormatParagraphufpuidlelib.EditorWindowu EditorWindowutkinteruTkuTextuTclErroru test.supporturequiresuTestCaseu Is_Get_TestuFindTestuReformatFunctionTestuReformatCommentTestuFormatClassTestu TextWrapperuEditoruFormatEventTestu__name__umain(((uK/opt/alt/python33/lib64/python3.3/idlelib/idle_test/test_formatparagraph.pyus w…