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@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) Ú BaseTestCasez5Parent class with utility methods for textwrap tests.cCsdt|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__Ú__doc__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_whitespacer4r*rrrÚtest_empty_stringDszWrapTestCase.test_empty_stringcCs*|jddgdd|jddgddddS)Nr7r8ú++©Úinitial_indentF)r>r:r4r*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.r3z 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.rEzThis is a shortz paragraph.é(zThis is a short paragraph.r4r5rrrÚ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=r4r5rrrÚ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'lyrGzthis-is-a-useful-feature-for-z%reformatting-posts-from-tim-peters'lyé)r2z*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.rI)zPython 1.0.0 was released onz1994-01-26. Python 1.0.1 waszreleased on 1994-02-15.rGz(Python 1.0.0 was released on 1994-01-26.z(Python 1.0.1 was released on 1994-02-15.rMFrNzI do all my shopping at 7-11.ézI do all my shopping atz7-11.éé)r rPr5rrrÚ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.rSzEm-dashes should bezwritten -- thus.rUzEm-dashes should be writtenz-- thus.zEm-dashes should be written --zthus.rIé#é$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 evenrYéz You can also do--this or even---r\é z7Here's an -- em-dash and--here's another---and another!)zHere'sú Zanraú--razem-ZdashraÚandrbzhere'sraZanotherz---rcrazanother!zand then--bam!--he was gone) rcraZthenrbzbam!rbÚheraZwasraZgone©r r#rQrrrÚ 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)Nzr4r*rrrÚ6test_drop_whitespace_false_whitespace_only_with_indentssÿzCWrapTestCase.test_drop_whitespace_false_whitespace_only_with_indentcCs| ddg¡dS)Nr€r8r4r*rrrÚ$test_drop_whitespace_whitespace_onlyysz1WrapTestCase.test_drop_whitespace_whitespace_onlycCs*d}| |ddg¡| |dddg¡dS)Nz, This is a sentence with leading whitespace.é2rIz This is a sentence withzleading whitespace.r4r5rrrÚ'test_drop_whitespace_leading_whitespace}sÿÿz4WrapTestCase.test_drop_whitespace_leading_whitespacecCs0d}|j|dgd¢dd| |dddg¡dS)Nz abcd efghr8)Úabcdr{ÚefghFr9r…r†r4r5rrrÚ$test_drop_whitespace_whitespace_lineˆs ÿz1WrapTestCase.test_drop_whitespace_whitespace_linecCs|jddgdddS)Nr€r8r<r=r4r*rrrÚ0test_drop_whitespace_whitespace_only_with_indent‘sz=WrapTestCase.test_drop_whitespace_whitespace_only_with_indentcCs|jddddgddddS)Nz abcd efghr8z abcdz efghr€©r>Úsubsequent_indentr4r*rrrÚ&test_drop_whitespace_whitespace_indent—sÿz3WrapTestCase.test_drop_whitespace_whitespace_indentcCs$d}|j |¡}| |gd¢¡dS)Nz0Hello there -- you goof-ball, use the -b option!)ÚHelloraZthererarbraZyourazgoof-zball,raZuserarlraz-brazoption!)r!r"r)rrrrrrÚ test_splitžs  ÿzWrapTestCase.test_splitcCs4d}|j|dddgdd|j|dddgd ddS) Nz yaba daba-doorzz yaba daba-ZdooT©Zbreak_on_hyphensZyabazdaba-dooFr4r5rrrÚtest_break_on_hyphens©sÿÿz"WrapTestCase.test_break_on_hyphenscCs(d}| tt|d¡| tt|d¡dS)NzWhatever, it doesn't matter.réÿÿÿÿ)Ú assertRaisesÚ ValueErrorrr5rrrÚtest_bad_width±szWrapTestCase.test_bad_widthcCsd}| |dgd¢¡dS)NuDie Empfänger-Auswahlé )ZDieu Empfänger-ZAuswahlr4r5rrrÚtest_no_split_at_umlaut·sz$WrapTestCase.test_no_split_at_umlautcCsd}| |dddg¡dS)Nu aa ää-ääéuaa ää-uäär4r5rrrÚtest_umlaut_followed_by_dash»sz)WrapTestCase.test_umlaut_followed_by_dashcCs4d}|j|dgd¢dd|j|dgd¢dddS)Nu,This is a sentence with non-breaking space.rE)úThis is a sentenceú with non-ubreaking space.TrŽ)r˜Úwithunon-breaking space.Fr4r5rrrÚtest_non_breaking_space¿süüz$WrapTestCase.test_non_breaking_spacecCs4d}|j|dgd¢dd|j|dgd¢dddS)Nu-This is a sentence with non-breaking space.rE)r˜r™ubreaking space.TrŽ)r˜ršunon-breaking space.Fr4r5rrrÚtest_narrow_non_breaking_spaceÎsüüz+WrapTestCase.test_narrow_non_breaking_spaceN)!r$r%r&r+r6r;r?rCrFrHrJrRrVrfrorvrxryr|r~rr‚r„r‡rˆr‹rrr“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_linesrMr/z how [...]ér”z how are [...]r3r.r8©r rr*rrrr6âs2 þ þ ÿý ÿý ùzMaxLinesTestCase.test_simplecCsP|j|jdgd¢dd|j|jdddgdd|j|jd dgd ¢dddS) Nr-)r/r0r1z day? [...]rAržr8rŒú[...]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...rMz...©rŸÚ placeholderr/z how are...r r[r{z [truncated]...)r>rŸr¥)rŠrŸr¥z Hello there,z [truncated]...r€)rŸr>rŠr¥r3aè........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................©r¥)r rr‘r’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¤r4r5rrrÚtest_placeholder_backtrack2s ýz+MaxLinesTestCase.test_placeholder_backtrackN)r$r%r&rr6r£r§r©rrrrrßs  rc@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) NrI)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----------hellorz)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)NrrI)z Did you sayz%"supercalifragilisticexpialidocious?"zHow *do* you spell that oddzword, anyways?)rrO)r!rOrrrr©rrrrrrÚtest_nobreak_longjs z"LongWordTestCase.test_nobreak_longcCs|j|jdgd¢dddS)Nr-)r­r®r¯r¢rAržr¡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).rG©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).rGrr=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).rGz * r{r‰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|ƒ¡dS)z,assert that dedent() has no effect on 'text'N©rrr5rrrÚ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»r5rrrÚ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ºrQrrrÚ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ºrQrrrÚ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ºrQrrrÚ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ºrQrrrÚ"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»rrrQrrrÚ 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©Nr7©ÚCASESrrr5rrrÚtest_indent_nomargin_defaultDs z+IndentTestCase.test_indent_nomargin_defaultcCs$|jD]}| t|ddƒ|¡qdSrÅrÆr5rrrÚ%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..r7rÆ©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..r{rÆrÏrrrÚtest_indent_no_linesVs z#IndentTestCase.test_indent_no_linescCs&|jD]}| tt|dƒƒ|¡qdS)Nr{©ÚROUNDTRIP_CASESrrrr5rrrÚtest_roundtrip_spaces\s z$IndentTestCase.test_roundtrip_spacescCs&|jD]}| tt|dƒƒ|¡qdS)Nz rÓr5rrrÚtest_roundtrip_tabsas z"IndentTestCase.test_roundtrip_tabscCs&|jD]}| tt|dƒƒ|¡qdS)Nz rÓr5rrrÚ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Ërrrrͱ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 [...]rzr¢rër5rrrrCÔsÿÿzShortenTestCase.test_whitespacecCsJtdddd| t¡tddddWdƒn1s<0YdS)NZxxxxxxxxxxxxxxxxxxxxéz(......))rr¥z (.......))rr‘r’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çr6r§r;rCrðròrrrrræ¶s  ræÚ__main__)ZunittestÚtextwraprrrrrrZTestCaserr(rrªr´r¹rÂrær$ÚmainrrrrÚ s 4_E3z9