ó {G_Tc@sÕddlZddlmZddlmZmZmZmZdejfd„ƒYZ de fd„ƒYZ de fd „ƒYZ d e fd „ƒYZ d ejfd „ƒYZ d„ZedkrÑeƒndS(iÿÿÿÿN(t test_support(t TextWrappertwraptfilltdedentt BaseTestCasecBs2eZdZd„Zd„Zd„Zd„ZRS(s5Parent class with utility methods for textwrap tests.cCs…t|tƒr_g}x5tt|ƒƒD]!}|jd|||fƒq(Wdj|ƒ}n"t|tƒrdt|ƒ}n|S(Ns %d: %rs s %s (t isinstancetlisttrangetlentappendtjoint basestringtrepr(tselfttextintresultti((s./usr/local/lib/python2.7/test/test_textwrap.pytshowscCs3|j||d|j|ƒ|j|ƒfƒdS(Nsexpected: %s but got: %s(t assertEqualR(RRtexpect((s./usr/local/lib/python2.7/test/test_textwrap.pytchecks cKs&t|||}|j||ƒdS(N(RR(RttexttwidthRtkwargsR((s./usr/local/lib/python2.7/test/test_textwrap.pyt check_wrap$scCs3|jj|ƒ}|j||d||fƒdS(Ns expected %r but got %r(twrappert_splitR(RRRR((s./usr/local/lib/python2.7/test/test_textwrap.pyt check_split(s (t__name__t __module__t__doc__RRRR(((s./usr/local/lib/python2.7/test/test_textwrap.pyRs   t WrapTestCasecBseZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zejrüd„Zd„Zd„Znd„Zd„Zd„Z RS(cCstddƒ|_dS(NRi-(RR(R((s./usr/local/lib/python2.7/test/test_textwrap.pytsetUp1sc Cs^d}|j|dddddddgƒ|j|d d d gƒ|j|d |gƒdS( Ns=Hello there, how are you this fine day? I'm glad to hear it!i s Hello there,s how are yous this fines day? I'ms glad to hearsit!i*s'Hello there, how are you this fine day?sI'm glad to hear it!iP(R(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyt test_simple4s    cCs0|jddgƒ|jddgdtƒdS(Ntitdrop_whitespace(RtFalse(R((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_empty_stringEscCs<|jddgddƒ|jddgdddtƒdS(NR#itinitial_indents++R$(RR%(R((s./usr/local/lib/python2.7/test/test_textwrap.pyt%test_empty_string_with_initial_indentJscCsxd}dddddg}tddtƒ}|j|ƒ}|j||ƒ|j|ƒ}|j|d j|ƒƒdS( Ns®This is a paragraph that already has line breaks. But some of its lines are much longer than the others, so it needs to be wrapped. Some lines are tabbed too. What a mess! s)This is a paragraph that already has lines'breaks. But some of its lines are muchs)longer than the others, so it needs to bes-wrapped. Some lines are tabbed too. What asmess!i-tfix_sentence_endingss (RtTrueRRRR (RRRRR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_whitespaceOs  cCs_tddtƒ}d}dg}|j|j|ƒ|ƒd}dg}|j|j|ƒ|ƒd}|j|j|ƒ|ƒd}d g}|j|j|ƒ|ƒd |_d d d g}|j|j|ƒ|ƒd}dddg}|j|j|ƒ|ƒd|_dg}|j|j|ƒ|ƒd}dg}|j|j|ƒ|ƒdS(Ni<R)s$A short line. Note the single space.s%A short line. Note the single space.s Well, Doctor? What do you think?s!Well, Doctor? What do you think?s Well, Doctor? What do you think?s)I say, chaps! Anyone for "tennis?" Hmmph!s+I say, chaps! Anyone for "tennis?" Hmmph!is I say, chaps!sAnyone for "tennis?"sHmmph!s1And she said, "Go to hell!" Can you believe that?sAnd she said, "Go toshell!" Can yous believe that?s2And she said, "Go to hell!" Can you believe that?sFile stdio.h is nice.(RR*RRR(RRRR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_fix_sentence_endingsgs4        cCs9d}|j|dddgƒ|j|ddgƒdS(NsThis is a short paragraph.isThis is a shorts paragraph.i(sThis is a short paragraph.(R(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_wrap_short‘s cCs<d}|j|ddgƒ|j|ddgddƒdS(NsThis is a short line.is(1) This is a short line.R's(1) (R(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_wrap_short_1line›scCsUd}|j|dddgƒ|j|dddgƒ|j|dddgƒdS( NsBthis-is-a-useful-feature-for-reformatting-posts-from-tim-peters'lyi(sthis-is-a-useful-feature-for-s%reformatting-posts-from-tim-peters'lyi)i*s*this-is-a-useful-feature-for-reformatting-sposts-from-tim-peters'ly(R(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_hyphenated¥s     cCsd}|j|ddddgƒ|j|dddgƒd }|j|d d d gƒ|j|d d d gƒ|j|dd gƒdS(NsRPython 1.0.0 was released on 1994-01-26. Python 1.0.1 was released on 1994-02-15.i#sPython 1.0.0 was released ons1994-01-26. Python 1.0.1 wassreleased on 1994-02-15.i(s(Python 1.0.0 was released on 1994-01-26.s(Python 1.0.1 was released on 1994-02-15.sI do all my shopping at 7-11.isI do all my shopping ats7-11.ii(R(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_hyphenated_numbersµs    cCsçd}|j|dddgƒ|j|dddgƒdd g}|j|d |ƒ|j|d |ƒ|j|d dgƒd }dddg}|j|d|ƒ|j|d|ƒdddg}|j|d|ƒ|j|d|ƒddg}|j|d|ƒ|j|d|ƒddg}|j|d|ƒ|j|d |ƒd}ddddd dd!d"dd#d d$dd%d&d#dd'g}|j||ƒd(}d#dd)d d*d d+dd,dd-g }|j||ƒdS(.Ns$Em-dashes should be written -- thus.isEm-dashes should beswritten -- thus.isEm-dashes should be writtens-- thus.sEm-dashes should be written --sthus.ii#i$s%You can also do--this or even---this.sYou can also dos--this or evens---this.iisYou can also do--sthis or even---sthis.iisYou can also do--this or evenis You can also do--this or even---i s7Here's an -- em-dash and--here's another---and another!sHere'st tans--sem-tdashtandshere'stanothers---sanother!sand then--bam!--he was gonetthensbam!thetwastgone(RR(RRR((s./usr/local/lib/python2.7/test/test_textwrap.pyt test_em_dashÇsR           cCs4d}|j|dddddgƒ|j|ddd d gƒd d g}|j|d |ƒ|j|d|ƒ|j|d|ƒ|j|d|ƒddg}|j|d|ƒ|j|d|ƒdd g}|j|d|ƒd}ddddddddddddddg}|j||ƒdS( Ns<You should use the -n option, or --dry-run in its long form.isYou should use thes-n option, or --dry-srun in its longsform.isYou should use the -nsoption, or --dry-runsin its long form.s You should use the -n option, ors--dry-run in its long form.i i"i#i&s'You should use the -n option, or --dry-srun in its long form.i'i)s*You should use the -n option, or --dry-runi*s'the -n option, or --dry-run or --dryrunttheR1s-nsoption,tors--dry-truns--dryrun(RR(RRR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_unix_optionsþs6       cCs³|jddddddgƒ|jddddgƒ|jd ddd gƒ|jd d gƒ|jd d gƒ|jd ddgƒ|jdddddddgƒdS(Nswhat the--hey!twhatR1R;s--shey!s what the--sthe--s what the--.sthe--.s --text--.s--options --option-opts --option-toptsfoo --option-opt bartfootbar(R(R((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_funky_hyphens s cCsŒ|jdddddddgƒ|jddddd ddgƒ|jd ddd d ddgƒ|jd ddddddgƒdS(Nsthe 'wibble-wobble' widgetR;R1s'wibble-swobble'twidgetsthe "wibble-wobble" widgets"wibble-swobble"sthe (wibble-wobble) widgets(wibble-swobble)sthe ['wibble-wobble'] widgets ['wibble-swobble'](R(R((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_punct_hyphens1s    c Csg|jddddddgƒ|jddddddgƒ|jd d dd dd dd gƒdS(Nsfoo (--option) barRAR1s (--option)RBs foo (bar) bazs(bar)tbazsblah (ding dong), wubbatblahs(dingsdong),twubba(R(R((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_funky_parensBs   c Cs5d}|j|dddddddgd tƒdS( Ns0 This is a sentence with much whitespace.i s This is as s sentence s with s much whitesspace.R$(RR%(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_drop_whitespace_falseOs   cCs |jdddgdtƒdS(Ns iR$(RR%(R((s./usr/local/lib/python2.7/test/test_textwrap.pyt*test_drop_whitespace_false_whitespace_onlyXscCs&|jdddgdtddƒdS(Ns is R$R's (RR%(R((s./usr/local/lib/python2.7/test/test_textwrap.pyt6test_drop_whitespace_false_whitespace_only_with_indent\scCs|jddgƒdS(Ns i(R(R((s./usr/local/lib/python2.7/test/test_textwrap.pyt$test_drop_whitespace_whitespace_onlybscCs9d}|j|ddgƒ|j|dddgƒdS(Ns, This is a sentence with leading whitespace.i2is This is a sentence withsleading whitespace.(R(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyt'test_drop_whitespace_leading_whitespacefs    cCsEd}|j|ddddgdtƒ|j|dddgƒdS(Ns abcd efghitabcds tefghR$(RR%(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyt$test_drop_whitespace_whitespace_lineqscCs|jddgddƒdS(Ns iR's++(R(R((s./usr/local/lib/python2.7/test/test_textwrap.pyt0test_drop_whitespace_whitespace_only_with_indentzscCs)|jddddgddddƒdS(Ns abcd efghis abcds efghR's tsubsequent_indent(R(R((s./usr/local/lib/python2.7/test/test_textwrap.pyt&test_drop_whitespace_whitespace_indent€scCs‘d}|j|ddgƒ|j|dddgƒ|jj|ƒ}|j|tƒ|j|dtƒ|jj|ƒ}|j|tƒdS(NuHello there, how are you today?i2iuHello there, how ares you today?i(RRRtassertIsInstanceRtunicodeR(RRtolinestotext((s./usr/local/lib/python2.7/test/test_textwrap.pyt test_unicodeˆscCs&d}|j|ddddgƒdS(NuDie Empfänger-Auswahli uDieu Empfänger-uAuswahl(R(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_no_split_at_umlaut•scCs#d}|j|dddgƒdS(Nu aa ää-ääiuaa ää-uää(R(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_umlaut_followed_by_dash™scCsbd}|jj|ƒ}|j|dddddddddddd dd dd dd gƒdS( Ns0Hello there -- you goof-ball, use the -b option!tHelloR1ttheres--tyousgoof-sball,tuseR;s-bsoption!(RRR(RRR((s./usr/local/lib/python2.7/test/test_textwrap.pyt test_splits  cCsHd}|j|dddgdtƒ|j|dddgdtƒdS(Ns yaba daba-dooi s yaba daba-tdootbreak_on_hyphenstyabasdaba-doo(RR*R%(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_break_on_hyphens¨s cCs6d}|jtt|dƒ|jtt|dƒdS(NsWhatever, it doesn't matter.iiÿÿÿÿ(t assertRaisest ValueErrorR(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_bad_width°s(!RRR!R"R&R(R+R,R-R.R/R0R:R>RCRERIRJRKRLRMRNRQRRRTRt have_unicodeRYRZR[R`RdRg(((s./usr/local/lib/python2.7/test/test_textwrap.pyR /s<      *   7 "           tLongWordTestCasecBs#eZd„Zd„Zd„ZRS(cCstƒ|_d|_dS(Ns]Did you say "supercalifragilisticexpialidocious?" How *do* you spell that odd word, anyways? (RRR(R((s./usr/local/lib/python2.7/test/test_textwrap.pyR!¸s c Csž|j|jdddddgƒ|j|jdddgƒ|jdd d d ddddgddƒ|j|jddddddddddg ƒdS( NisDid you say "supercalifragilissticexpialidocious?" How *do*syou spell that odd word,sanyways?i2s1Did you say "supercalifragilisticexpialidocious?"s*How *do* you spell that odd word, anyways?t-i thellos ----------s hs es ls oRSR1ii s Did you say s "supercalifrt agilisticexps ialidocious?s " How *do*s you spellsthat oddsword,s ----------s----------hellos (RR(R((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_break_long¿s4    cCs~d|j_d|j_ddddg}|jj|jƒ}|j||ƒt|jddddƒ}|j||ƒdS( Niis Did you says%"supercalifragilisticexpialidocious?"sHow *do* you spell that oddsword, anyways?Rtbreak_long_words(RRnRRRR(RRR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_nobreak_longãs   (RRR!RmRo(((s./usr/local/lib/python2.7/test/test_textwrap.pyRi·s  $tIndentTestCasescBs,eZd„Zd„Zd„Zd„ZRS(cCs d|_dS(NsnThis paragraph will be filled, first without any indentation, and then with some (including a hanging indent).(R(R((s./usr/local/lib/python2.7/test/test_textwrap.pyR!÷scCs,d}t|jdƒ}|j||ƒdS(NsnThis paragraph will be filled, first without any indentation, and then with some (including a hanging indent).i((RRR(RRR((s./usr/local/lib/python2.7/test/test_textwrap.pyt test_fillýscCsrdddg}t|jdddƒ}|j||ƒdj|ƒ}t|jdddƒ}|j||ƒdS(Ns# This paragraph will be filled,s'first without any indentation, and thens'with some (including a hanging indent).i(R's s (RRRR R(RRR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_initial_indent s cCs8d}t|jdddddƒ}|j||ƒdS(Ns~ * This paragraph will be filled, first without any indentation, and then with some (including a hanging indent).i(R's * RSs (RRR(RRR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_subsequent_indents(RRR!RqRrRs(((s./usr/local/lib/python2.7/test/test_textwrap.pyRpôs  tDedentTestCasecBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCs|j|t|ƒƒdS(s,assert that dedent() has no effect on 'text'N(RR(RR((s./usr/local/lib/python2.7/test/test_textwrap.pytassertUnchanged)scCsPd}|j|ƒd}|j|ƒd}|j|ƒd}|j|ƒdS(Ns,Hello there. How are you? Oh good, I'm glad.sHello there. Boo!s Hello there. This is indented.sHello there. Boo! (Ru(RR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_dedent_nomargin-s   cCsjd}d}|j|t|ƒƒd}d}|j|t|ƒƒd}d}|j|t|ƒƒdS(Ns' Hello there. How are ya? Oh good.s!Hello there. How are ya? Oh good.s) Hello there. How are ya? Oh good. s#Hello there. How are ya? Oh good. s+ Hello there. How are ya? Oh good. (RR(RRR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_dedent_even>scCsjd}d}|j|t|ƒƒd}d}|j|t|ƒƒd}d}|j|t|ƒƒdS(NsK def foo(): while 1: return foo s+def foo(): while 1: return foo s Foo Bar Baz sFoo Bar Baz s Foo Bar Baz (RR(RRR((s./usr/local/lib/python2.7/test/test_textwrap.pyttest_dedent_unevenNscCs<d}d}|j|t|ƒƒ|j|t|ƒƒdS(Ns hello there how are you?shello there how are you?(RR(RRR((s./usr/local/lib/python2.7/test/test_textwrap.pyt"test_dedent_preserve_internal_tabsgscCs¦d}|j|ƒd}|j|ƒd}d}|j|t|ƒƒd}|j|t|ƒƒd}|j|t|ƒƒd}d}|j|t|ƒƒdS( Ns hello there how are you?s! hello there how are you?s hello there how are you?shello there how are you?s hello there how are you?s" hello there how are you?s hello there how are you?shello there how are you?(RuRR(RRR((s./usr/local/lib/python2.7/test/test_textwrap.pyt test_dedent_preserve_margin_tabsss  (RRRuRvRwRxRyRz(((s./usr/local/lib/python2.7/test/test_textwrap.pyRt's      cCstjttttƒdS(N(Rt run_unittestR RiRpRt(((s./usr/local/lib/python2.7/test/test_textwrap.pyt test_main‹s t__main__(tunittestttestRttextwrapRRRRtTestCaseRR RiRpRtR|R(((s./usr/local/lib/python2.7/test/test_textwrap.pyt s "ÿ‰=3d