ó {fc@s7ddlZddlmZddlmZddlmZmZddl m Z dej fd„ƒYZ dej fd „ƒYZ d ej fd „ƒYZd ej fd „ƒYZdej fd„ƒYZddd„ƒYZddd„ƒYZdej fd„ƒYZedkr3ejddddƒndS(iÿÿÿÿN(tFormatParagraph(t EditorWindow(tTktText(trequirest Is_Get_TestcBsGeZdZdZdZdZdZdZd„Zd„Z d„Z RS( sTest the is_ and get_ functionss# This is a commentsThis is not a comments# This is a comment s # This is a comments This is not a commentcCsI|jtjdƒƒ|jtjdƒƒ|jtj|jƒƒdS(Nts (t assertTruetfpt is_all_whitet assertFalset test_comment(tself((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_is_all_whitescCsq|j}|tj|jƒdƒ|tj|jƒdƒ|tj|jƒdƒ|tj|jƒdƒdS(NRs (t assertEqualRt get_indentR ttrailingws_commenttleadingws_commenttleadingws_nocomment(R tEqual((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_get_indents  cCsŠ|j}|tj|jƒdƒ|tj|jƒdƒ|tj|jƒdƒ|tj|jƒdƒ|tj|jƒdƒdS(Nt#s #s R(RRtget_comment_headerR RRRttest_nocomment(R R((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_get_comment_headers  ( t__name__t __module__t__doc__R RRRRR RR(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR s  tFindTestcBs8eZdZed„ƒZd„Zd„Zd„ZRS(s`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ÿÿÿÿ(R(tidlelib.idle_test.mock_tkRttext(tclsR((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyt setUpClass2sc Cs·|j}|jd|ƒx‡td|ƒD]v}t|jd|ƒjdƒdƒ}xGd|d|fD]2}d||f}|jtj||ƒ|ƒqiWq)W|j ddƒdS( Ns1.0is%d.endt.iis%d.%dtend( RtinserttrangetinttindextsplitRRtfind_paragraphtdelete( R t inserttexttstoplinetexpectedRtlinet linelengthtcolt tempindex((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pytruncase7s &$c Csdd}|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(Ns;# Comment block with no blank lines before # Comment line is1.0s3.0Rii:sG # Comment block with whitespace line before and after # Comment line is2.0s4.0iiFsS # Indented comment block with whitespace before and after # Comment line s #iRs # Single line comment is4 # Single line comment with leading whitespace i3s0 # Comment immediately followed by code x = 42 i(s= # Indented comment immediately followed by code x = 42 i5s= # Comment immediately followed by indented code x = 42 i1(R1(R tcomment((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_find_commentDs &&&&&&&c 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(Ns6"""String with no blank lines before String line """ is1.0s4.0Rii5sC """String with whitespace line before and after String line. """ is2.0s5.0iiBsV """Indented string with whitespace before and after Comment string. """ s iUs """Single line string.""" is3.0is8 """Single line string with leading whitespace.""" i7(R1(R t teststring((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_find_paragraphzs&&&&(RRRt classmethodR R1R3R5(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR(s  6tReformatFunctionTestcBseZdZd„ZRS(s?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(Ns O hello worldt isHello worldis Hello worlds O hello worldiis O hello worldi i s O hello worlds O hello worlds O hello world(RRtreformat_paragraph(R Rtreformthw((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_reformat_paragraph¢s   (RRRR<(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR7ŸstReformatCommentTestcBseZdZd„ZRS(s=Test the reformat_comment function without the editor window.cCsi|j}d}tj|ddƒ}d}|||ƒd}tj|ddƒ}d}|||ƒdS(Nsu """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""iFs sy """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""sm# this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?Rso# this is a test of a reformat for a triple quoted string will it # reformat to less than 70 characters for me?(RRtreformat_comment(R Rt test_stringtresultR,R ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_reformat_comment¼s  (RRRRA(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR=¹stFormatClassTestcBseZd„ZRS(cCsCtjdƒ}|j|jdƒ|jƒ|j|jdƒdS(Nteditor(RRRteditwintclosetNone(R tinstance((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_init_closeÔs (RRRH(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRBÓst TextWrappercBs,eZd„Zd„Zd„Zd„ZRS(cCstd|ƒ|_dS(Ntmaster(RR(R RJ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyt__init__çscCst|j|ƒS(N(tgetattrR(R tname((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyt __getattr__éscCsdS(N((R ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pytundo_block_startëRcCsdS(N((R ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pytundo_block_stopìR(RRRKRNRORP(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRIæs   tEditorcBseZd„ZejjZRS(cCst|ƒ|_dS(N(RIR(R troot((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRKïs(RRRKRtget_selection_indicestim_func(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRQîs tFormatEventTestcBsbeZdZdZdZdZed„ƒZed„ƒZd„Z d„Z d„Z d „Z RS( s­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. sv '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?''' s '''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. ''' s,# 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(NtguiRR( RRRRRQRRRtformat_paragraph_eventt formatter(RRC((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyR s   cCs#|`|`|jjƒ|`dS(N(RRXRRtdestroy(R((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyt tearDownClasss  cCsV|jjddƒ|jdƒ|j|jjddƒdƒ|jjddƒdS(Ns1.0s Short line tDummyR#R"(RR#RXRtgetR)(R ((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_short_lines cCsì|j}|jd|jƒ|jddƒ|jdddƒ|jddƒ}d}|j||ƒ|jddƒ|jd|jƒ|jdd d ƒ|jdddƒ|jddƒ}d }|j||ƒ|jddƒdS( Ns1.0R#tParameterDoesNothingtlimitiFsz '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?''' R"tsels1.11s1.endsv '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?'''( RR#R?tmark_setRXR\RR)ttag_add(R RR@R,((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_long_line!s cCs~|j}|jd|jƒ|jdddƒ|jdddƒ|jddƒ}d }|j||ƒ|jdd ƒdS( Ns1.0R`s2.0s4.0R^R_iFR#sà 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#tmultiline_test_stringRbRXR\RR)(R RR@R,((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_multiple_lines<s cCsÜ|j}|jd|jƒ|jdddƒ|jddƒ}d}|j||ƒ|jddƒ|jd|jƒ|jdd d ƒ|jdddƒ|jddƒ}d }|j||ƒ|jddƒdS( Ns1.0R^R_iFR#s/# 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"R`s2.0s3.0s™# 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#tmultiline_test_commentRXR\RR)Rb(R RR@R,((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyttest_comment_blockKs ( RRRR?RdRfR6R RZR]RcReRg(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyRUós    t__main__t verbosityitexit(((tunittesttidlelibRRtidlelib.EditorWindowRtTkinterRRttest.test_supportRtTestCaseRRR7R=RBRIRQRURtmain(((s>/usr/lib64/python2.7/idlelib/idle_test/test_formatparagraph.pyts w„