o
    ±ó®g‹§  ã                   @   sÖ   d dl Z d dlmZmZmZmZmZmZ G dd„ de jƒZ	G dd„ de	ƒZ
G dd„ de	ƒZG d	d
„ d
e	ƒZG dd„ de	ƒZG dd„ de	ƒZG dd„ de jƒZG dd„ de jƒZG dd„ de	ƒZedkrie  ¡  dS dS )é    N)ÚTextWrapperÚwrapÚfillÚdedentÚindentÚshortenc                   @   ó0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚBaseTestCasez5Parent class with utility methods for textwrap tests.c                 C   sj   t |tƒr(g }tt|ƒƒD ]}| d||| f ¡ q|r$d |¡}|S d}|S t |tƒr3dt|ƒ }|S )Nz  %d: %rÚ
z
  no linesz  %s
)Ú
isinstanceÚlistÚrangeÚlenÚappendÚjoinÚstrÚrepr)ÚselfZtextinÚresultÚi© r   úH/Users/admin/.pyenv/versions/3.10.0/lib/python3.10/test/test_textwrap.pyÚshow   s   
ý
þzBaseTestCase.showc              	   C   s&   |   ||d|  |¡|  |¡f ¡ d S )Nzexpected:
%s
but got:
%s)ÚassertEqualr   )r   r   Úexpectr   r   r   Úcheck   s
   ÿÿzBaseTestCase.checkc                 K   ó"   t ||fi |¤Ž}|  ||¡ d S ©N)r   r   ©r   ÚtextÚwidthr   Úkwargsr   r   r   r   Ú
check_wrap#   ó   zBaseTestCase.check_wrapc                 C   s&   | j  |¡}|  ||d||f ¡ d S )Nz
expected %r
but got  %r)ÚwrapperÚ_splitr   )r   r   r   r   r   r   r   Úcheck_split'   s   ÿÿzBaseTestCase.check_splitN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r"   r&   r   r   r   r   r	      s    r	   c                   @   sü   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=S )>ÚWrapTestCasec                 C   s   t dd| _d S )Né-   )r    )r   r$   ©r   r   r   r   ÚsetUp0   s   zWrapTestCase.setUpc                 C   s<   d}|   |dg d¢¡ |   |dddg¡ |   |d|g¡ d S )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 hearzit!é*   z'Hello there, how are you this fine day?zI'm glad to hear it!éP   ©r"   ©r   r   r   r   r   Útest_simple3   s   ÿÿÿzWrapTestCase.test_simplec                 C   s$   |   ddg ¡ | j ddg dd d S )NÚ é   F©Údrop_whitespacer7   r-   r   r   r   Útest_empty_stringD   s   zWrapTestCase.test_empty_stringc                 C   s*   | j ddg dd | j ddg ddd d S )Nr:   r;   ú++©Úinitial_indentF)rA   r=   r7   r-   r   r   r   Ú%test_empty_string_with_initial_indentI   s   z2WrapTestCase.test_empty_string_with_initial_indentc                 C   s‚   d}g d¢}t ddd}| |¡}|  ||¡ | |¡}|  |d |¡¡ d}dg}|  |d	|¡ d
}dg}| j|d	|dd d S )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 azmess!r,   T©Zfix_sentence_endingsr
   z	Test	default		tabsize.z(        Test    default         tabsize.r6   z	Test	custom		tabsize.z     Test    custom      tabsize.é   )Útabsize)r   r   r   r   r   r"   )r   r   r   r$   r   r   r   r   Útest_whitespaceN   s   

zWrapTestCase.test_whitespacec                 C   sò   t ddd}d}dg}|  | |¡|¡ d}dg}|  | |¡|¡ d}|  | |¡|¡ d	}d
g}|  | |¡|¡ d|_g d¢}|  | |¡|¡ d}g d¢}|  | |¡|¡ d|_dg}|  | |¡|¡ d}dg}|  | |¡|¡ d S )Né<   TrC   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!zAnyone for "tennis?"zHmmph!z1And she said, "Go to hell!"
Can you believe that?)zAnd she said, "Go tozhell!"  Can youzbelieve that?z2And she said, "Go to hell!"  Can you believe that?zFile stdio.h is nice.)r   r   r   r    )r   r$   r   r   r   r   r   Útest_fix_sentence_endingsn   s0   z&WrapTestCase.test_fix_sentence_endingsc                 C   s*   d}|   |dddg¡ |   |ddg¡ d S )NzThis is a
short paragraph.rH   zThis is a shortz
paragraph.é(   zThis is a short paragraph.r7   r8   r   r   r   Útest_wrap_short˜   s
   
ÿzWrapTestCase.test_wrap_shortc                 C   s,   d}|   |ddg¡ | j |ddgdd d S )NzThis is a short line.é   z(1) This is a short line.z(1) r@   r7   r8   r   r   r   Útest_wrap_short_1line¢   s
   
ÿz"WrapTestCase.test_wrap_short_1linec                 C   s”   d}|   |dddg¡ |   |dddg¡ |   |dddg¡ d	 d
¡}| j |d|dd |  ||¡ |  ddg¡ |  ddg¡ |  dd d
¡¡ d S )NzBthis-is-a-useful-feature-for-reformatting-posts-from-tim-peters'lyrJ   zthis-is-a-useful-feature-for-z%reformatting-posts-from-tim-peters'lyé)   r5   z*this-is-a-useful-feature-for-reformatting-zposts-from-tim-peters'lyzLthis-|is-|a-|useful-|feature-|for-|reformatting-|posts-|from-|tim-|peters'lyú|é   F©Úbreak_long_wordsze-mailzJelly-Ozhalf-a-crownzhalf-|a-|crown)r"   Úsplitr&   ©r   r   r   r   r   r   Útest_hyphenated¬   s0   ÿÿÿÿÿÿÿzWrapTestCase.test_hyphenatedc                 C   s   d}|   |dg d¢¡ |   |dddg¡ | j |d| ¡ dd	 d
}|   |dddg¡ |   |dddg¡ |   |dd
g¡ | j |d| ¡ dd	 d S )NzRPython 1.0.0 was released on 1994-01-26.  Python 1.0.1 was
released on 1994-02-15.rL   )zPython 1.0.0 was released onz1994-01-26.  Python 1.0.1 waszreleased on 1994-02-15.rJ   z(Python 1.0.0 was released on 1994-01-26.z(Python 1.0.1 was released on 1994-02-15.rP   FrQ   zI do all my shopping at 7-11.é   zI do all my shopping atz7-11.é   é   )r"   rS   r8   r   r   r   Útest_hyphenated_numbersÆ   s   
ÿ
ÿ
ÿz$WrapTestCase.test_hyphenated_numbersc                 C   s$  d}|   |dddg¡ |   |dddg¡ dd	g}|   |d
|¡ |   |d|¡ |   |ddg¡ d}g d¢}|   |d|¡ |   |d|¡ g d¢}|   |d|¡ |   |d|¡ ddg}|   |d|¡ |   |d|¡ ddg}|   |d|¡ |   |d|¡ d}g d¢}|  ||¡ d}g d¢}|  ||¡ d S )Nz$Em-dashes should be written -- thus.rV   zEm-dashes should bezwritten -- thus.rX   zEm-dashes should be writtenz-- thus.zEm-dashes should be written --zthus.rL   é#   é$   z%You can also do--this or even---this.)zYou can also doz--this or evenú---this.é   é   )zYou can also do--zthis or even---úthis.é   é   zYou can also do--this or evenr\   é   z You can also do--this or even---r_   é    z7Here's an -- em-dash and--here's another---and another!)zHere'sú Zanrd   ú--rd   zem-Zdashrd   Úandre   zhere'srd   Zanotherz---rf   rd   zanother!zand then--bam!--he was gone)rf   rd   Zthenre   zbam!re   Zherd   Zwasrd   Zgone©r"   r&   rT   r   r   r   Útest_em_dashÚ   sT   ÿÿÿÿÿÿÿÿzWrapTestCase.test_em_dashc                 C   s¾   d}|   |dg d¢¡ |   |dg d¢¡ ddg}|   |d|¡ |   |d	|¡ |   |d
|¡ |   |d|¡ ddg}|   |d|¡ |   |d|¡ ddg}|   |d|¡ d}g d¢}|  ||¡ d S )Nz<You should use the -n option, or --dry-run in its long form.rH   )zYou should use thez-n option, or --dry-zrun in its longzform.é   )zYou should use the -nzoption, or --dry-runúin its long form.z You should use the -n option, orz--dry-run in its long form.rc   é"   rZ   é&   z'You should use the -n option, or --dry-zrun in its long form.é'   rN   z*You should use the -n option, or --dry-runrj   r5   z'the -n option, or --dry-run or --dryrun)Útherd   z-nrd   zoption,rd   Úorrd   z--dry-Úrunrd   ro   rd   z--dryrunrg   rT   r   r   r   Útest_unix_options  s4   ÿÿÿÿÿzWrapTestCase.test_unix_optionsc                 C   sp   |   dg d¢¡ |   dg d¢¡ |   dg d¢¡ |   ddg¡ |   ddg¡ |   d	d
dg¡ |   dg d¢¡ d S )Nzwhat the--hey!)Úwhatrd   rn   re   zhey!z
what the--)rr   rd   zthe--zwhat the--.)rr   rd   zthe--.z	--text--.z--optionz--option-optú	--option-Úoptzfoo --option-opt bar)Úfoord   rs   rt   rd   Úbar©r&   r-   r   r   r   Útest_funky_hyphens3  s   ÿzWrapTestCase.test_funky_hyphensc                 C   sV   |   dg d¢¡ |   dg d¢¡ |   dg d¢¡ |   dg d¢¡ |   d	d
 d¡¡ d S )Nzthe 'wibble-wobble' widget)rn   rd   z'wibble-zwobble'rd   Úwidgetzthe "wibble-wobble" widget)rn   rd   z"wibble-zwobble"rd   ry   zthe (wibble-wobble) widget)rn   rd   z(wibble-zwobble)rd   ry   zthe ['wibble-wobble'] widget)rn   rd   z	['wibble-zwobble']rd   ry   zwhat-d'you-call-it.zwhat-d'you-|call-|it.rO   )r&   rS   r-   r   r   r   Útest_punct_hyphensD  s   ÿÿÿÿÿzWrapTestCase.test_punct_hyphensc                 C   s4   |   dg d¢¡ |   dg d¢¡ |   dg d¢¡ d S )Nzfoo (--option) bar)ru   rd   z
(--option)rd   rv   zfoo (bar) baz)ru   rd   z(bar)rd   Zbazzblah (ding dong), wubba)Zblahrd   z(dingrd   zdong),rd   Zwubbarw   r-   r   r   r   Útest_funky_parensY  s   ÿÿÿzWrapTestCase.test_funky_parensc                 C   s   d}| j |dg d¢dd d S )Nz0 This is a    sentence with     much whitespace.é
   )z
 This is aú    z	sentence z	with     z
much whitezspace.Fr<   r7   r8   r   r   r   Útest_drop_whitespace_falsef  s
   
ýz'WrapTestCase.test_drop_whitespace_falsec                 C   s   | j dddgdd d S )Nú   r;   Fr<   r7   r-   r   r   r   Ú*test_drop_whitespace_false_whitespace_onlyo  s   z7WrapTestCase.test_drop_whitespace_false_whitespace_onlyc                 C   s   | j dddgddd d S )Nr   r;   ú     Fú  )r=   rA   r7   r-   r   r   r   Ú6test_drop_whitespace_false_whitespace_only_with_indents  s   
ÿzCWrapTestCase.test_drop_whitespace_false_whitespace_only_with_indentc                 C   s   |   ddg ¡ d S )Nr‚   r;   r7   r-   r   r   r   Ú$test_drop_whitespace_whitespace_onlyy  s   z1WrapTestCase.test_drop_whitespace_whitespace_onlyc                 C   s*   d}|   |ddg¡ |   |dddg¡ d S )Nz, This is a sentence with leading whitespace.é2   rL   z This is a sentence withzleading whitespace.r7   r8   r   r   r   Ú'test_drop_whitespace_leading_whitespace}  s   ÿÿz4WrapTestCase.test_drop_whitespace_leading_whitespacec                 C   s0   d}| j |dg d¢dd |   |dddg¡ d S )Nzabcd    efghr;   )Úabcdr}   ÚefghFr<   r‡   rˆ   r7   r8   r   r   r   Ú$test_drop_whitespace_whitespace_lineˆ  s
   ÿz1WrapTestCase.test_drop_whitespace_whitespace_linec                 C   s   | j ddg dd d S )Nr‚   r;   r?   r@   r7   r-   r   r   r   Ú0test_drop_whitespace_whitespace_only_with_indent‘  s   z=WrapTestCase.test_drop_whitespace_whitespace_only_with_indentc                 C   s   | j ddddgddd d S )Nz	abcd efghr;   z  abcdz  efghr‚   ©rA   Úsubsequent_indentr7   r-   r   r   r   Ú&test_drop_whitespace_whitespace_indent—  s   
ÿz3WrapTestCase.test_drop_whitespace_whitespace_indentc                 C   s$   d}| j  |¡}|  |g d¢¡ d S )Nz0Hello there -- you goof-ball, use the -b option!)ÚHellord   Zthererd   re   rd   Zyourd   zgoof-zball,rd   Zuserd   rn   rd   z-brd   zoption!)r$   r%   r   )r   r   r   r   r   r   Ú
test_splitž  s
   ÿzWrapTestCase.test_splitc                 C   s4   d}| j |dddgdd | j |dddgd	d d S )
Nzyaba daba-door|   z
yaba daba-ZdooT©Úbreak_on_hyphensZyabazdaba-dooFr7   r8   r   r   r   Útest_break_on_hyphens©  s   ÿ
ÿz"WrapTestCase.test_break_on_hyphensc                 C   s(   d}|   tt|d¡ |   tt|d¡ d S )NzWhatever, it doesn't matter.r   éÿÿÿÿ)ÚassertRaisesÚ
ValueErrorr   r8   r   r   r   Útest_bad_width±  s   zWrapTestCase.test_bad_widthc                 C   s   d}|   |dg d¢¡ d S )Nu   Die EmpfÃ¤nger-Auswahlé   )ZDieu   EmpfÃ¤nger-ZAuswahlr7   r8   r   r   r   Útest_no_split_at_umlaut·  ó   z$WrapTestCase.test_no_split_at_umlautc                 C   s   d}|   |dddg¡ d S )Nu   aa Ã¤Ã¤-Ã¤Ã¤é   u   aa Ã¤Ã¤-u   Ã¤Ã¤r7   r8   r   r   r   Útest_umlaut_followed_by_dash»  r™   z)WrapTestCase.test_umlaut_followed_by_dashc                 C   ó4   d}| j |dg d¢dd | j |dg d¢dd d S )Nu,   This is a sentence with non-breakingÂ space.rH   )úThis is a sentenceú	with non-u   breakingÂ space.Tr   )r   Úwithu   non-breakingÂ space.Fr7   r8   r   r   r   Útest_non_breaking_space¿  s   ü
üz$WrapTestCase.test_non_breaking_spacec                 C   rœ   )Nu-   This is a sentence with non-breakingâ€¯space.rH   )r   rž   u   breakingâ€¯space.Tr   )r   rŸ   u   non-breakingâ€¯space.Fr7   r8   r   r   r   Útest_narrow_non_breaking_spaceÎ  s   ü
üz+WrapTestCase.test_narrow_non_breaking_spaceN)!r'   r(   r)   r.   r9   r>   rB   rF   rI   rK   rM   rU   rY   rh   rq   rx   rz   r{   r~   r€   rƒ   r„   r†   r‰   rŠ   r   r   r’   r–   r˜   r›   r    r¡   r   r   r   r   r+   .   s>     *

7"		r+   c                   @   r   )ÚMaxLinesTestCaser/   c                 C   s   | j | jddgdd | j | jddgdd | j | jdddgdd | j | jd	dd
gdd | j | jd| jgdd | j | jdg d¢dd d S )Nr0   zHello [...]r   ©Ú	max_linesrP   r2   z	how [...]é   r—   zhow are [...]r6   r1   r;   ©r"   r   r-   r   r   r   r9   â  s2   
þ
þ
ÿý
ÿý

ùzMaxLinesTestCase.test_simplec                 C   sP   | j | jdg d¢dd | j | jdddgdd | j | jd	 dg d
¢dd d S )Nr0   )r2   r3   r4   z
day? [...]rD   r£   r;   rŽ   ú[...]r¥   z
          r1   r¦   r-   r   r   r   Útest_spacesû  s   
û
ÿý
ùzMaxLinesTestCase.test_spacesc              	   C   s  | j | jddgddd | j | jdddgddd |  t¡ t| jd	d
ddd W d   ƒ n1 s3w   Y  |  t¡ t| jd	d
ddd W d   ƒ n1 sRw   Y  | j | jd	ddgdd
ddd | j | jd	dgddd
dd | j | jd| jgdd d S )Nr0   zHello...rP   z...©r¤   Úplaceholderr2   z
how are...r¥   r^   r}   z [truncated]...)rA   r¤   rª   )rŒ   r¤   rª   z    Hello there,z  [truncated]...r‚   )r¤   rA   rŒ   rª   r6   aè  ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................©rª   )r"   r   r”   r•   r   r-   r   r   r   Útest_placeholder  sN   
ý
ÿü
ÿÿ
ÿÿ
ÿú
ûz!MaxLinesTestCase.test_placeholderc                 C   s    d}| j |dddgddd d S )Nz1Good grief Python features are advancing quickly!r0   z
Good griefzPython*****é   z*****r©   r7   r8   r   r   r   Útest_placeholder_backtrack2  s   
ýz+MaxLinesTestCase.test_placeholder_backtrackN)r'   r(   r)   r   r9   r¨   r¬   r®   r   r   r   r   r¢   ß  s     r¢   c                   @   ó,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚLongWordTestCasec                 C   s   t ƒ | _d| _d S )Nz]Did you say "supercalifragilisticexpialidocious?"
How *do* you spell that odd word, anyways?
)r   r$   r   r-   r   r   r   r.   ?  s   
zLongWordTestCase.setUpc                 C   sV   |   | jdg d¢¡ |   | jdddg¡ | j ddg d¢d	d
 |   | jdg d¢¡ d S )NrL   )zDid you say "supercalifragiliszticexpialidocious?" How *do*zyou spell that odd word,úanyways?r…   z1Did you say "supercalifragilisticexpialidocious?"z*How *do* you spell that odd word, anyways?z----------hellor|   )z
----------z               hz               eú               lr²   z               oz               )rŒ   r0   )	úDid you say ú"supercalifrÚagilisticexpzialidocious?z
" How *do*z	you spellzthat oddzword,r±   r¦   r-   r   r   r   Útest_break_longF  s   
ÿ
ÿÿù
ÿz LongWordTestCase.test_break_longc                 C   sR   d| j _d| j _g d¢}| j  | j¡}|  ||¡ t| jddd}|  ||¡ d S )Nr   rL   )zDid you sayz%"supercalifragilisticexpialidocious?"zHow *do* you spell that oddzword, anyways?)r    rR   )r$   rR   r    r   r   r   ©r   r   r   r   r   r   Útest_nobreak_longj  s   z"LongWordTestCase.test_nobreak_longc                 C   s   | j | jdg d¢dd d S )Nr0   )r³   r´   rµ   r§   rD   r£   r¦   r-   r   r   r   Útest_max_lines_longz  s   

ûz$LongWordTestCase.test_max_lines_longN)r'   r(   r)   r.   r¶   r¸   r¹   r   r   r   r   r°   >  s
    $r°   c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚLongWordWithHyphensTestCasec                 C   s   t ƒ | _d| _d| _d S )NzOWe used enyzme 2-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylate synthase.
zC1234567890-1234567890--this_is_a_very_long_option_indeed-good-bye"
)r   r$   Útext1Útext2r-   r   r   r   r.   „  s   
z!LongWordWithHyphensTestCase.setUpc                 C   sL   ddg}|   | jd|¡ g d¢}|   | jd|¡ g d¢}|   | jd|¡ d S )Nz(We used enyzme 2-succinyl-6-hydroxy-2,4-z&cyclohexadiene-1-carboxylate synthase.r…   )
úWe usedz	enyzme 2-z	succinyl-z
6-hydroxy-z2,4-Z
cyclohexadziene-1-Z
carboxylatÚeú	synthase.r|   ©Z
1234567890z
-123456789z
0--this_isZ
_a_very_loZ
ng_option_zindeed-z	good-bye"©r"   r»   r¼   ©r   Úexpectedr   r   r   Útest_break_long_words_on_hyphen  s   ÿz;LongWordWithHyphensTestCase.test_break_long_words_on_hyphenc                 C   sT   ddg}| j | jd|dd g d¢}| j | jd|dd g d¢}|   | jd|¡ d S )	Nz2We used enyzme 2-succinyl-6-hydroxy-2,4-cyclohexadziene-1-carboxylate synthase.r…   Fr   )r½   z
enyzme 2-sz
uccinyl-6-z
hydroxy-2,z
4-cyclohexz
adiene-1-cZ
arboxylater¿   r|   rÀ   rÁ   rÂ   r   r   r   Ú#test_break_long_words_not_on_hyphenš  s   ÿz?LongWordWithHyphensTestCase.test_break_long_words_not_on_hyphenc                 C   sT   g d¢}| j | jd|dd g d¢}| j | jd|dd g d¢}|   | jd|¡ d S )N©zWe used enyzmeú52-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylater¿   r…   FrQ   ©r½   ZenyzmerÇ   r¿   r|   rÀ   rÁ   rÂ   r   r   r   Ú'test_break_on_hyphen_but_not_long_words§  s   zCLongWordWithHyphensTestCase.test_break_on_hyphen_but_not_long_wordsc                 C   sX   g d¢}| j | jd|ddd g d¢}| j | jd|ddd g d¢}|   | jd|¡ d S )NrÆ   r…   F)rR   r‘   rÈ   r|   rÀ   rÁ   rÂ   r   r   r   Ú*test_do_not_break_long_words_or_on_hyphens¸  s   þþzFLongWordWithHyphensTestCase.test_do_not_break_long_words_or_on_hyphensN)r'   r(   r)   r.   rÄ   rÅ   rÉ   rÊ   r   r   r   r   rº   ƒ  s    	rº   c                   @   r¯   )
ÚIndentTestCasesc                 C   s
   d| _ d S )NznThis paragraph will be filled, first without any indentation,
and then with some (including a hanging indent).)r   r-   r   r   r   r.   Î  s   
zIndentTestCases.setUpc                 C   s    d}t | jdƒ}|  ||¡ d S )NznThis paragraph will be filled, first
without any indentation, and then with
some (including a hanging indent).rJ   ©r   r   r   r·   r   r   r   Ú	test_fillÔ  s   zIndentTestCases.test_fillc                 C   sN   g d¢}t | jddd}|  ||¡ d |¡}t| jddd}|  ||¡ d S )N)z#     This paragraph will be filled,z'first without any indentation, and thenz'with some (including a hanging indent).rJ   r   r@   r
   )r   r   r   r   r   r·   r   r   r   Útest_initial_indentà  s   
z#IndentTestCases.test_initial_indentc                 C   s&   d}t | jdddd}|  ||¡ d S )Nz~  * This paragraph will be filled, first
    without any indentation, and then
    with some (including a hanging
    indent).rJ   z  * r}   r‹   rÌ   r·   r   r   r   Útest_subsequent_indentî  s
   ÿz&IndentTestCases.test_subsequent_indentN)r'   r(   r)   r.   rÍ   rÎ   rÏ   r   r   r   r   rË   Ë  s
    rË   c                   @   óD   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dS )ÚDedentTestCasec                 C   s   |   |t|ƒ¡ dS )z,assert that dedent() has no effect on 'text'N©r   r   r8   r   r   r   ÚassertUnchanged   s   zDedentTestCase.assertUnchangedc                 C   s<   d}|   |¡ d}|   |¡ d}|   |¡ d}|   |¡ d S )Nz,Hello there.
How are you?
Oh good, I'm glad.zHello there.

Boo!z Hello there.
  This is indented.zHello there.

  Boo!
)rÓ   r8   r   r   r   Útest_dedent_nomargin  s   


z#DedentTestCase.test_dedent_nomarginc                 C   óL   d}d}|   |t|ƒ¡ d}d}|   |t|ƒ¡ d}d}|   |t|ƒ¡ d S )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Ò   rT   r   r   r   Útest_dedent_even  ó   zDedentTestCase.test_dedent_evenc                 C   rÕ   )NzK        def foo():
            while 1:
                return foo
        z+def foo():
    while 1:
        return foo
z  Foo
    Bar

   Baz
zFoo
  Bar

 Baz
z  Foo
    Bar
 
   Baz
rÒ   rT   r   r   r   Útest_dedent_uneven%  s   z!DedentTestCase.test_dedent_unevenc                 C   rÕ   )Nz     Foo
    Bar
z	 Foo
Bar
z     Foo

    Bar
z
 Foo

Bar
z     Foo
    
    Bar
rÒ   rT   r   r   r   Útest_dedent_declining=  r×   z$DedentTestCase.test_dedent_decliningc                 C   s,   d}d}|   |t|ƒ¡ |   |t|ƒ¡ d S )Nz  hello	there
  how are	you?zhello	there
how are	you?rÒ   rT   r   r   r   Ú"test_dedent_preserve_internal_tabsN  s   z1DedentTestCase.test_dedent_preserve_internal_tabsc                 C   s   d}|   |¡ d}|   |¡ d}d}|  |t|ƒ¡ d}|  |t|ƒ¡ d}|  |t|ƒ¡ d}d}|  |t|ƒ¡ d	}d
}|  |t|ƒ¡ d S )Nz  hello there
	how are you?z!        hello there
	how are you?z	hello there
	how are you?zhello there
how are you?z  	hello there
  	how are you?z"  	  hello there
  	  how are you?z   	hello there
  	  how are you?zhello there
  how are you?z2  	hello there
   	how are you?
 	I'm fine, thanksz/ 	hello there
  	how are you?
	I'm fine, thanks)rÓ   r   r   rT   r   r   r   Ú test_dedent_preserve_margin_tabsZ  s"   

z/DedentTestCase.test_dedent_preserve_margin_tabsN)
r'   r(   r)   rÓ   rÔ   rÖ   rØ   rÙ   rÚ   rÛ   r   r   r   r   rÑ   þ  s    rÑ   c                   @   sp   e Zd ZdZed Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚIndentTestCase)ú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.

c                 C   s"   | j D ]}|  t|dƒ|¡ qd S ©Nr:   ©ÚCASESr   r   r8   r   r   r   Útest_indent_nomargin_defaultŒ  s   
ÿz+IndentTestCase.test_indent_nomargin_defaultc                 C   s$   | j D ]}|  t|dd ƒ|¡ qd S rß   rà   r8   r   r   r   Ú%test_indent_nomargin_explicit_default‘  s   
ÿz4IndentTestCase.test_indent_nomargin_explicit_defaultc                 C   ó,   dd„ }| j D ]}|  t|d|ƒ|¡ qd S )Nc                 S   ó   dS ©NTr   ©Úliner   r   r   Ú<lambda>š  ó    z?IndentTestCase.test_indent_nomargin_all_lines.<locals>.<lambda>r:   rà   ©r   Ú	predicater   r   r   r   Útest_indent_nomargin_all_lines—  s   
ÿz-IndentTestCase.test_indent_nomargin_all_linesc                 C   rä   )Nc                 S   rå   )NFr   rç   r   r   r   ré      rê   z5IndentTestCase.test_indent_no_lines.<locals>.<lambda>r}   rà   rë   r   r   r   Útest_indent_no_linesž  s   
ÿz#IndentTestCase.test_indent_no_linesc                 C   ó&   | j D ]}|  tt|dƒƒ|¡ qd S )Nr}   ©ÚROUNDTRIP_CASESr   r   r   r8   r   r   r   Útest_roundtrip_spaces¤  ó   
ÿz$IndentTestCase.test_roundtrip_spacesc                 C   rï   )Nz		rð   r8   r   r   r   Útest_roundtrip_tabs©  ró   z"IndentTestCase.test_roundtrip_tabsc                 C   rï   )Nz 	  	 rð   r8   r   r   r   Útest_roundtrip_mixed®  ró   z#IndentTestCase.test_roundtrip_mixedc                 C   s4   d}d}t | j|ƒD ]\}}|  t||ƒ|¡ q
d S ©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á   r   r   ©r   ÚprefixrÃ   r   r   r   r   r   Útest_indent_default³  s
   ÿz"IndentTestCase.test_indent_defaultc                 C   s6   d}d}t | j|ƒD ]\}}|  t||d ƒ|¡ q
d S rö   rù   rû   r   r   r   Útest_indent_explicit_defaultÅ  s
   ÿz+IndentTestCase.test_indent_explicit_defaultc                 C   ó>   d}d}dd„ }t | j|ƒD ]\}}|  t|||ƒ|¡ qd S )Nr‚   )r÷   z%  Hi.
  This is a test.
  
  Testing.z&  
  Hi.
  This is a test.
  Testing.
rø   z/  
  Hi.
  This is a test.
  
  Testing.
  
c                 S   rå   ræ   r   rç   r   r   r   ré   æ  rê   z6IndentTestCase.test_indent_all_lines.<locals>.<lambda>rù   ©r   rü   rÃ   rì   r   r   r   r   r   Útest_indent_all_lines×  ó   ÿz$IndentTestCase.test_indent_all_linesc                 C   rÿ   )Nr‚   )rÝ   zHi.
This is a test.
  
Testing.z   
Hi.
This is a test.
Testing.
rÞ   z)  
Hi.
This is a test.
  
Testing.
  
c                 S   s
   |   ¡  S r   )Ústriprç   r   r   r   ré   ù  s   
 z8IndentTestCase.test_indent_empty_lines.<locals>.<lambda>rù   r   r   r   r   Útest_indent_empty_linesê  r  z&IndentTestCase.test_indent_empty_linesN)r'   r(   r)   rñ   rá   râ   rã   rí   rî   rò   rô   rõ   rý   rþ   r  r  r   r   r   r   rÜ   x  s    rÜ   c                   @   rÐ   )ÚShortenTestCasec                 K   r   r   )r   r   r   r   r   r   Úcheck_shorten   r#   zShortenTestCase.check_shortenc                 C   s>   d}|   |dd¡ |   |t|ƒ|¡ |   |t|ƒd d¡ d S )Nú<Hello there, how are you this fine day? I'm glad to hear it!é   zHello there, [...]rP   z9Hello there, how are you this fine day? I'm glad to [...]©r  r   r8   r   r   r   r9     s   ÿzShortenTestCase.test_simplec                 C   sn   d}| j |dddd | j |dddd | j |ddd	d | j |t|ƒ|dd | j |t|ƒd
 ddd d S )Nr  r`   zHello there,$$z$$r«   r  zHello there, how$$zHello there, $$z $$rP   z:Hello there, how are you this fine day? I'm glad to hear$$r	  r8   r   r   r   r¬     s   
þz ShortenTestCase.test_placeholderc                 C   s   |   ddd¡ d S )Nr:   r;   ©r  r-   r   r   r   r>     ó   z!ShortenTestCase.test_empty_stringc                 C   sN   d}|   |dd¡ |   |dd¡ |   ddd¡ |   dd	d
¡ |   ddd¡ d S )Nz[
            This is a  paragraph that  already has
            line breaks and 	 tabs too.é>   z>This is a paragraph that already has line breaks and tabs too.é=   z:This is a paragraph that already has line breaks and [...]zhello      world!  r0   zhello world!é   zhello [...]r|   r§   r
  r8   r   r   r   rF     s   ÿÿzShortenTestCase.test_whitespacec                 C   sL   t dddd |  t¡ t dddd W d   ƒ d S 1 sw   Y  d S )NZxxxxxxxxxxxxxxxxxxxxé   z(......))r    rª   z	(.......))r   r”   r•   r-   r   r   r   Ú$test_width_too_small_for_placeholder.  s   "ÿz4ShortenTestCase.test_width_too_small_for_placeholderc                 C   s   |   ddd¡ d S )NZHellooé   r§   r
  r-   r   r   r   Ú-test_first_word_too_long_but_placeholder_fits3  r  z=ShortenTestCase.test_first_word_too_long_but_placeholder_fitsN)
r'   r(   r)   r  r9   r¬   r>   rF   r  r  r   r   r   r   r  þ  s    
r  Ú__main__)ZunittestÚtextwrapr   r   r   r   r   r   ZTestCaser	   r+   r¢   r°   rº   rË   rÑ   rÜ   r  r'   Úmainr   r   r   r   Ú<module>   s$   
    4_EH3z 9ÿ