a 5êdgZ›ã@sÂddlZddlmZmZmZmZmZmZGdd„dejƒZ Gdd„de ƒZ Gdd„de ƒZ Gd d „d e ƒZ Gd d „d e ƒZ Gd d„dejƒZGdd„dejƒZGdd„de ƒZedkr¾e ¡dS)éN)Ú TextWrapperÚwrapÚfillÚdedentÚindentÚshortenc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) Ú BaseTestCasecCsdt|tƒrJg}tt|ƒƒD]}| d|||f¡q|rDd |¡nd}nt|tƒr`dt|ƒ}|S)Nz %d: %rÚ z no linesz %s )Ú isinstanceÚlistÚrangeÚlenÚappendÚjoinÚstrÚrepr)ÚselfZtextinÚresultÚi©rú./usr/local/lib/python3.9/test/test_textwrap.pyÚshows   zBaseTestCase.showc Cs&| ||d| |¡| |¡f¡dS)Nzexpected: %s but got: %s)Ú assertEqualr)rrÚexpectrrrÚchecks ÿÿzBaseTestCase.checkcKs"t||fi|¤Ž}| ||¡dS©N)rr©rÚtextÚwidthrÚkwargsrrrrÚ check_wrap#szBaseTestCase.check_wrapcCs&|j |¡}| ||d||f¡dS)Nz expected %r but got %r)ÚwrapperÚ_splitr)rrrrrrrÚ check_split's  ÿÿzBaseTestCase.check_splitN)Ú__name__Ú __module__Ú __qualname__rrr r#rrrrrs rc@süeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Zd9d:„Zd;d<„Z d=S)>Ú WrapTestCasecCstdd|_dS)Né-)r)rr!©rrrrÚsetUp0szWrapTestCase.setUpcCs<d}| |dgd¢¡| |dddg¡| |d|g¡dS)Nú=Hello there, how are you this fine day? I'm glad to hear it!é ©ú Hello there,ú how are youú this finez day? I'mz glad to hearzit!é*z'Hello there, how are you this fine day?zI'm glad to hear it!éP©r ©rrrrrÚ test_simple3sÿÿÿzWrapTestCase.test_simplecCs$| ddg¡|jddgdddS)NÚéF©Údrop_whitespacer3r)rrrÚtest_empty_stringDszWrapTestCase.test_empty_stringcCs*|jddgdd|jddgddddS)Nr6r7ú++©Úinitial_indentF)r=r9r3r)rrrÚ%test_empty_string_with_initial_indentIsz2WrapTestCase.test_empty_string_with_initial_indentcCs‚d}gd¢}tddd}| |¡}| ||¡| |¡}| |d |¡¡d}dg}| |d |¡d }d g}|j|d |d d dS)Nz®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! )z)This is a paragraph that already has linez'breaks. But some of its lines are muchz)longer than the others, so it needs to bez-wrapped. Some lines are tabbed too. What azmess!r(T©Zfix_sentence_endingsr z Test default tabsize.z( Test default tabsize.r2z Test custom tabsize.z Test custom tabsize.é)Útabsize)rrrrrr )rrrr!rrrrÚtest_whitespaceNs    zWrapTestCase.test_whitespacecCsòtddd}d}dg}| | |¡|¡d}dg}| | |¡|¡d}| | |¡|¡d }d g}| | |¡|¡d |_gd ¢}| | |¡|¡d }gd¢}| | |¡|¡d|_dg}| | |¡|¡d}dg}| | |¡|¡dS)Né<Tr?z$A short line. Note the single space.z%A short line. Note the single space.z Well, Doctor? What do you think?z!Well, Doctor? What do you think?z Well, Doctor? What do you think?z)I say, chaps! Anyone for "tennis?" Hmmph!z+I say, chaps! Anyone for "tennis?" Hmmph!é)z I say, chaps!zAnyone for "tennis?"zHmmph!z1And she said, "Go to hell!" Can you believe that?)zAnd she said, "Go tozhell!" Can youz believe that?z2And she said, "Go to hell!" Can you believe that?zFile stdio.h is nice.)rrrr)rr!rrrrrÚtest_fix_sentence_endingsns0 z&WrapTestCase.test_fix_sentence_endingscCs*d}| |dddg¡| |ddg¡dS)NzThis is a short paragraph.rDzThis is a shortz paragraph.é(zThis is a short paragraph.r3r4rrrÚtest_wrap_short˜s  ÿzWrapTestCase.test_wrap_shortcCs,d}| |ddg¡|j|ddgdddS)NzThis is a short line.éz(1) This is a short line.z(1) r<r3r4rrrÚtest_wrap_short_1line¢s  ÿz"WrapTestCase.test_wrap_short_1linecCs”d}| |dddg¡| |dddg¡| |dddg¡d  d ¡}|j|d |d d | ||¡| ddg¡| ddg¡| dd d ¡¡dS)NzBthis-is-a-useful-feature-for-reformatting-posts-from-tim-peters'lyrFzthis-is-a-useful-feature-for-z%reformatting-posts-from-tim-peters'lyé)r1z*this-is-a-useful-feature-for-reformatting-zposts-from-tim-peters'lyzLthis-|is-|a-|useful-|feature-|for-|reformatting-|posts-|from-|tim-|peters'lyú|éF©Úbreak_long_wordsze-mailzJelly-Oz half-a-crownzhalf-|a-|crown)r Úsplitr#©rrrrrrÚtest_hyphenated¬s0ÿÿÿÿÿÿÿ zWrapTestCase.test_hyphenatedcCsd}| |dgd¢¡| |dddg¡|j|d| ¡dd d }| |d d d g¡| |dd d g¡| |dd g¡|j|d| ¡dd dS)NzRPython 1.0.0 was released on 1994-01-26. Python 1.0.1 was released on 1994-02-15.rH)zPython 1.0.0 was released onz1994-01-26. Python 1.0.1 waszreleased on 1994-02-15.rFz(Python 1.0.0 was released on 1994-01-26.z(Python 1.0.1 was released on 1994-02-15.rLFrMzI do all my shopping at 7-11.ézI do all my shopping atz7-11.éé)r rOr4rrrÚtest_hyphenated_numbersÆs ÿ ÿ ÿz$WrapTestCase.test_hyphenated_numberscCs$d}| |dddg¡| |dddg¡dd g}| |d |¡| |d |¡| |d dg¡d }gd¢}| |d|¡| |d|¡gd¢}| |d|¡| |d|¡ddg}| |d|¡| |d|¡ddg}| |d|¡| |d |¡d}gd¢}| ||¡d}gd¢}| ||¡dS)Nz$Em-dashes should be written -- thus.rRzEm-dashes should bezwritten -- thus.rTzEm-dashes should be writtenz-- thus.zEm-dashes should be written --zthus.rHé#é$z%You can also do--this or even---this.)zYou can also doz--this or evenú---this.éé)zYou can also do--zthis or even---úthis.éézYou can also do--this or evenrXéz You can also do--this or even---r[é z7Here's an -- em-dash and--here's another---and another!)zHere'sú Zanr`ú--r`zem-Zdashr`Úandrazhere'sr`Zanotherz---rbr`zanother!zand then--bam!--he was gone) rbr`Zthenrazbam!raÚher`Zwasr`Zgone©r r#rPrrrÚ test_em_dashÚsTÿÿÿÿÿÿÿÿ zWrapTestCase.test_em_dashcCs¾d}| |dgd¢¡| |dgd¢¡ddg}| |d|¡| |d |¡| |d |¡| |d |¡d d g}| |d|¡| |d|¡ddg}| |d|¡d}gd¢}| ||¡dS)NzrBrErGrIrQrUrernrurwrxr{r}r€rrƒr†r‡rŠrŒrŽr’r”r–ršr›rrrrr'.s< *  7"     r'c@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) ÚMaxLinesTestCaser+cCs|j|jddgdd|j|jddgdd|j|jdddgdd|j|jd dd gdd|j|jd |jgdd|j|jdgd ¢d ddS)Nr,z Hello [...]r©Ú max_linesrLr.z how [...]ér“z how are [...]r2r-r7©r rr)rrrr5âs2 þ þ ÿý ÿý ùzMaxLinesTestCase.test_simplecCsP|j|jdgd¢dd|j|jdddgdd|j|jd dgd ¢dddS) Nr,)r.r/r0z day? [...]r@rr7r‹ú[...]rŸz r-r r)rrrÚ test_spacesûs û ÿýùzMaxLinesTestCase.test_spacesc Cs|j|jddgddd|j|jdddgddd| t¡$t|jd d dd d Wdƒn1sf0Y| t¡$t|jd d dd d Wdƒn1s¤0Y|j|jd ddgdd dd d|j|jd dgddd d d|j|jd|jgdddS)Nr,zHello...rLz...©ržÚ placeholderr.z how are...rŸrZrzz [truncated]...)r=ržr¤)r‰ržr¤z Hello there,z [truncated]...r)ržr=r‰r¤r2aè........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................©r¤)r rrr‘rr)rrrÚtest_placeholdersJ ý ÿü  ÿ$  ÿ$ ÿú ûz!MaxLinesTestCase.test_placeholdercCs d}|j|dddgddddS)Nz1Good grief Python features are advancing quickly!r,z Good griefz Python*****éz*****r£r3r4rrrÚtest_placeholder_backtrack2s ýz+MaxLinesTestCase.test_placeholder_backtrackN)r$r%r&rr5r¢r¦r¨rrrrrœßs  rœc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚLongWordTestCasecCstƒ|_d|_dS)Nz]Did you say "supercalifragilisticexpialidocious?" How *do* you spell that odd word, anyways? )rr!rr)rrrr*?szLongWordTestCase.setUpcCsV| |jdgd¢¡| |jdddg¡|jddgd¢d d | |jd gd ¢¡dS) NrH)zDid you say "supercalifragiliszticexpialidocious?" How *do*zyou spell that odd word,úanyways?r‚z1Did you say "supercalifragilisticexpialidocious?"z*How *do* you spell that odd word, anyways?z----------hellory)z ----------z hz eú lr«z oz )r‰r,) ú Did you say ú "supercalifrÚ agilisticexpz ialidocious?z " How *do*z you spellzthat oddzword,rªr r)rrrÚtest_break_longFs ÿ ÿÿù ÿz LongWordTestCase.test_break_longcCsRd|j_d|j_gd¢}|j |j¡}| ||¡t|jddd}| ||¡dS)NrrH)z Did you sayz%"supercalifragilisticexpialidocious?"zHow *do* you spell that oddzword, anyways?)rrN)r!rNrrrr©rrrrrrÚtest_nobreak_longjs z"LongWordTestCase.test_nobreak_longcCs|j|jdgd¢dddS)Nr,)r¬r­r®r¡r@rr r)rrrÚtest_max_lines_longzs ûz$LongWordTestCase.test_max_lines_longN)r$r%r&r*r¯r±r²rrrrr©>s$r©c@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) ÚIndentTestCasescCs d|_dS)NznThis paragraph will be filled, first without any indentation, and then with some (including a hanging indent).)rr)rrrr*†szIndentTestCases.setUpcCs d}t|jdƒ}| ||¡dS)NznThis paragraph will be filled, first without any indentation, and then with some (including a hanging indent).rF©rrrr°rrrÚ test_fillŒs zIndentTestCases.test_fillcCsNgd¢}t|jddd}| ||¡d |¡}t|jddd}| ||¡dS)N)z# This paragraph will be filled,z'first without any indentation, and thenz'with some (including a hanging indent).rFr~r<r )rrrrrr°rrrÚtest_initial_indent˜s   z#IndentTestCases.test_initial_indentcCs&d}t|jdddd}| ||¡dS)Nz~ * This paragraph will be filled, first without any indentation, and then with some (including a hanging indent).rFz * rzrˆr´r°rrrÚtest_subsequent_indent¦s ÿz&IndentTestCases.test_subsequent_indentN)r$r%r&r*rµr¶r·rrrrr³ƒs r³c@sDeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)ÚDedentTestCasecCs| |t|ƒ¡dSr©rrr4rrrÚassertUnchanged¸szDedentTestCase.assertUnchangedcCs<d}| |¡d}| |¡d}| |¡d}| |¡dS)Nz,Hello there. How are you? Oh good, I'm glad.zHello there. Boo!z Hello there. This is indented.zHello there. Boo! )rºr4rrrÚtest_dedent_nomargin¼s   z#DedentTestCase.test_dedent_nomargincCsLd}d}| |t|ƒ¡d}d}| |t|ƒ¡d}d}| |t|ƒ¡dS)Nz' Hello there. How are ya? Oh good.z!Hello there. How are ya? Oh good.z) Hello there. How are ya? Oh good. z#Hello there. How are ya? Oh good. z+ Hello there. How are ya? Oh good. r¹rPrrrÚtest_dedent_evenÍszDedentTestCase.test_dedent_evencCsLd}d}| |t|ƒ¡d}d}| |t|ƒ¡d}d}| |t|ƒ¡dS)NzK def foo(): while 1: return foo z+def foo(): while 1: return foo z Foo Bar Baz zFoo Bar Baz z Foo Bar Baz r¹rPrrrÚtest_dedent_unevenÝsz!DedentTestCase.test_dedent_unevencCsLd}d}| |t|ƒ¡d}d}| |t|ƒ¡d}d}| |t|ƒ¡dS)Nz Foo Bar z Foo Bar z Foo Bar z Foo Bar z Foo Bar r¹rPrrrÚtest_dedent_decliningõsz$DedentTestCase.test_dedent_decliningcCs,d}d}| |t|ƒ¡| |t|ƒ¡dS)Nz hello there how are you?zhello there how are you?r¹rPrrrÚ"test_dedent_preserve_internal_tabssz1DedentTestCase.test_dedent_preserve_internal_tabscCsd}| |¡d}| |¡d}d}| |t|ƒ¡d}| |t|ƒ¡d}| |t|ƒ¡d}d}| |t|ƒ¡d }d }| |t|ƒ¡dS) Nz hello there how are you?z! hello there how are you?z hello there how are you?zhello there how are you?z hello there how are you?z" hello there how are you?z hello there how are you?zhello there how are you?z2 hello there how are you? I'm fine, thanksz/ hello there how are you? I'm fine, thanks)rºrrrPrrrÚ test_dedent_preserve_margin_tabss"  z/DedentTestCase.test_dedent_preserve_margin_tabsN) r$r%r&rºr»r¼r½r¾r¿rÀrrrrr¸¶s r¸c@speZdZdZedZdd„Zdd„Zdd„Zd d „Zd d „Z d d„Z dd„Z dd„Z dd„Z dd„Zdd„ZdS)ÚIndentTestCase)úHi. This is a test. Testing.zHi. This is a test. Testing.z Hi. This is a test. Testing. )ú Hi. This is a test. Testing. z# Hi. This is a test. Testing. cCs"|jD]}| t|dƒ|¡qdS©Nr6©ÚCASESrrr4rrrÚtest_indent_nomargin_defaultDs z+IndentTestCase.test_indent_nomargin_defaultcCs$|jD]}| t|ddƒ|¡qdSrÄrÅr4rrrÚ%test_indent_nomargin_explicit_defaultIs z4IndentTestCase.test_indent_nomargin_explicit_defaultcCs,dd„}|jD]}| t|d|ƒ|¡qdS)NcSsdS©NTr©ÚlinerrrÚRóz?IndentTestCase.test_indent_nomargin_all_lines..r6rÅ©rÚ predicaterrrrÚtest_indent_nomargin_all_linesOs z-IndentTestCase.test_indent_nomargin_all_linescCs,dd„}|jD]}| t|d|ƒ|¡qdS)NcSsdS)NFrrÊrrrrÌXrÍz5IndentTestCase.test_indent_no_lines..rzrÅrÎrrrÚtest_indent_no_linesVs z#IndentTestCase.test_indent_no_linescCs&|jD]}| tt|dƒƒ|¡qdS)Nrz©ÚROUNDTRIP_CASESrrrr4rrrÚtest_roundtrip_spaces\s z$IndentTestCase.test_roundtrip_spacescCs&|jD]}| tt|dƒƒ|¡qdS)Nz rÒr4rrrÚtest_roundtrip_tabsas z"IndentTestCase.test_roundtrip_tabscCs&|jD]}| tt|dƒƒ|¡qdS)Nz rÒr4rrrÚtest_roundtrip_mixedfs z#IndentTestCase.test_roundtrip_mixedcCs4d}d}t|j|ƒD]\}}| t||ƒ|¡qdS©Nr)ú" Hi. This is a test. Testing.z# Hi. This is a test. Testing.z$ Hi. This is a test. Testing. ú& Hi. This is a test. Testing. z) Hi. This is a test. Testing. ©ÚziprÆrr©rÚprefixÚexpectedrrrrrÚtest_indent_defaultks z"IndentTestCase.test_indent_defaultcCs6d}d}t|j|ƒD]\}}| t||dƒ|¡qdSr×rÚrÜrrrÚtest_indent_explicit_default}s z+IndentTestCase.test_indent_explicit_defaultcCs>d}d}dd„}t|j|ƒD]\}}| t|||ƒ|¡qdS)Nr)rØz% Hi. This is a test. Testing.z& Hi. This is a test. Testing. rÙz/ Hi. This is a test. Testing. cSsdSrÉrrÊrrrrÌžrÍz6IndentTestCase.test_indent_all_lines..rÚ©rrÝrÞrÏrrrrrÚtest_indent_all_liness  z$IndentTestCase.test_indent_all_linescCs>d}d}dd„}t|j|ƒD]\}}| t|||ƒ|¡qdS)Nr)rÂzHi. This is a test. Testing.z Hi. This is a test. Testing. rÃz) Hi. This is a test. Testing. cSs | ¡ Sr)ÚstriprÊrrrṟrÍz8IndentTestCase.test_indent_empty_lines..rÚrárrrÚtest_indent_empty_lines¢s  z&IndentTestCase.test_indent_empty_linesN)r$r%r&rÓrÆrÇrÈrÐrÑrÔrÕrÖrßràrârärrrrrÁ0srÁc@sDeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)ÚShortenTestCasecKs"t||fi|¤Ž}| ||¡dSr)rrrrrrÚ check_shorten¸szShortenTestCase.check_shortencCs>d}| |dd¡| |t|ƒ|¡| |t|ƒdd¡dS)Núz>This is a paragraph that already has line breaks and tabs too.é=z:This is a paragraph that already has line breaks and [...]zhello world! r,z hello world!é z hello [...]ryr¡rêr4rrrrBÔsÿÿzShortenTestCase.test_whitespacecCsJtdddd| t¡tddddWdƒn1s<0YdS)NZxxxxxxxxxxxxxxxxxxxxéz(......))rr¤z (.......))rrr‘r)rrrÚ$test_width_too_small_for_placeholderæs z4ShortenTestCase.test_width_too_small_for_placeholdercCs| ddd¡dS)NZHellooér¡rêr)rrrÚ-test_first_word_too_long_but_placeholder_fitsësz=ShortenTestCase.test_first_word_too_long_but_placeholder_fitsN) r$r%r&rær5r¦r:rBrïrñrrrrrå¶s  råÚ__main__)ZunittestÚtextwraprrrrrrZTestCaserr'rœr©r³r¸rÁrår$ÚmainrrrrÚ s 4_E3z9