a
    äzeZ›  ã                   @   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 jƒZG dd„ de jƒZG dd„ de	ƒZedkr¾e  ¡  dS )é    N)ÚTextWrapperÚwrapÚfillÚdedentÚindentÚshortenc                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚBaseTestCasec                 C   sd   t |tƒrJg }tt|ƒƒD ]}| d||| f ¡ q|rDd |¡nd}nt |tƒr`dt|ƒ }|S )Nz  %d: %rÚ
z
  no linesz  %s
)Ú
isinstanceÚlistÚrangeÚlenÚappendÚjoinÚstrÚrepr)ÚselfZtextinÚresultÚi© r   ú(/usr/lib/python3.9/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   s"   t ||fi |¤Ž}|  ||¡ d S ©N)r   r   ©r   ÚtextÚwidthr   Úkwargsr   r   r   r   Ú
check_wrap#   s    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__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_whitespacer3   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 )Nr6   r7   ú++©Úinitial_indentF)r=   r9   r3   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.r2   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é<   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!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.rD   zThis is a shortz
paragraph.é(   zThis is a short paragraph.r3   r4   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<   r3   r4   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'lyrF   zthis-is-a-useful-feature-for-z%reformatting-posts-from-tim-peters'lyé)   r1   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.rH   )zPython 1.0.0 was released onz1994-01-26.  Python 1.0.1 waszreleased on 1994-02-15.rF   z(Python 1.0.0 was released on 1994-01-26.z(Python 1.0.1 was released on 1994-02-15.rL   FrM   zI do all my shopping at 7-11.é   zI do all my shopping atz7-11.é   é   )r    rO   r4   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.rR   zEm-dashes should bezwritten -- thus.rT   zEm-dashes should be writtenz-- thus.zEm-dashes should be written --zthus.rH   é#   é$   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 evenrX   é   z You can also do--this or even---r[   é    z7Here's an -- em-dash and--here's another---and another!)zHere'sú Zanr`   ú--r`   zem-Zdashr`   Úandra   zhere'sr`   Zanotherz---rb   r`   zanother!zand then--bam!--he was gone)rb   r`   Zthenra   zbam!ra   Úher`   Zwasr`   Zgone©r    r#   rP   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.rD   )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.r_   é"   rV   é&   z'You should use the -n option, or --dry-zrun in its long form.é'   rJ   z*You should use the -n option, or --dry-runrg   r1   z'the -n option, or --dry-run or --dryrun)Úther`   z-nr`   zoption,r`   Úorr`   z--dry-Úrunr`   rl   r`   z--dryrunrd   rP   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!)Úwhatr`   rk   ra   zhey!z
what the--)ro   r`   zthe--zwhat the--.)ro   r`   zthe--.z	--text--.z--optionz--option-optú	--option-Úoptzfoo --option-opt bar)Úfoor`   rp   rq   r`   Ú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)rk   r`   z'wibble-zwobble'r`   Úwidgetzthe "wibble-wobble" widget)rk   r`   z"wibble-zwobble"r`   rv   zthe (wibble-wobble) widget)rk   r`   z(wibble-zwobble)r`   rv   zthe ['wibble-wobble'] widget)rk   r`   z	['wibble-zwobble']r`   rv   zwhat-d'you-call-it.zwhat-d'you-|call-|it.rK   )r#   rO   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)rr   r`   z
(--option)r`   rs   zfoo (bar) baz)rr   r`   z(bar)r`   Zbazzblah (ding dong), wubba)Zblahr`   z(dingr`   zdong),r`   Zwubbart   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.Fr8   r3   r4   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ú   r7   Fr8   r3   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|   r7   ú     Fú  )r9   r=   r3   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   r7   r3   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   rH   z This is a sentence withzleading whitespace.r3   r4   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    efghr7   )Úabcdrz   ÚefghFr8   r„   r…   r3   r4   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   r7   r;   r<   r3   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 efghr7   z  abcdz  efghr   ©r=   Úsubsequent_indentr3   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!)ÚHellor`   Ztherer`   ra   r`   Zyour`   zgoof-zball,r`   Zuser`   rk   r`   z-br`   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-doory   z
yaba daba-ZdooT©Zbreak_on_hyphensZyabazdaba-dooFr3   r4   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   r4   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Auswahlr3   r4   r   r   r   Útest_no_split_at_umlaut·  s    z$WrapTestCase.test_no_split_at_umlautc                 C   s   d}|   |dddg¡ d S )Nu   aa Ã¤Ã¤-Ã¤Ã¤é   u   aa Ã¤Ã¤-u   Ã¤Ã¤r3   r4   r   r   r   Útest_umlaut_followed_by_dash»  s    z)WrapTestCase.test_umlaut_followed_by_dashc                 C   s4   d}| j |dg d¢dd | j |dg d¢dd d S )Nu,   This is a sentence with non-breakingÂ space.rD   )úThis is a sentenceú	with non-u   breakingÂ space.Tr   )r—   Úwithu   non-breakingÂ space.Fr3   r4   r   r   r   Útest_non_breaking_space¿  s    üüz$WrapTestCase.test_non_breaking_spacec                 C   s4   d}| j |dg d¢dd | j |dg d¢dd d S )Nu-   This is a sentence with non-breakingâ€¯space.rD   )r—   r˜   u   breakingâ€¯space.Tr   )r—   r™   u   non-breakingâ€¯space.Fr3   r4   r   r   r   Útest_narrow_non_breaking_spaceÎ  s    üüz+WrapTestCase.test_narrow_non_breaking_spaceN)!r$   r%   r&   r*   r5   r:   r>   rB   rE   rG   rI   rQ   rU   re   rn   ru   rw   rx   r{   r}   r€   r   rƒ   r†   r‡   rŠ   rŒ   rŽ   r’   r”   r–   rš   r›   r   r   r   r   r'   .   s<    *

7"		r'   c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )Ú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 )Nr,   zHello [...]r   ©Ú	max_linesrL   r.   z	how [...]é   r“   zhow are [...]r2   r-   r7   ©r    r   r)   r   r   r   r5   â  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 )Nr,   )r.   r/   r0   z
day? [...]r@   r   r7   r‹   ú[...]rŸ   z
          r-   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 sf0    Y  |  t¡$ t| jd	d
ddd W d   ƒ n1 s¤0    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 )Nr,   zHello...rL   z...©rž   Úplaceholderr.   z
how are...rŸ   rZ   rz   z [truncated]...)r=   rž   r¤   )r‰   rž   r¤   z    Hello there,z  [truncated]...r   )rž   r=   r‰   r¤   r2   aè  ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................©r¤   )r    r   r   r‘   r   r)   r   r   r   Útest_placeholder  sJ    
ý
ÿü
ÿ$
ÿ$
ÿú
ûz!MaxLinesTestCase.test_placeholderc                 C   s    d}| j |dddgddd d S )Nz1Good grief Python features are advancing quickly!r,   z
Good griefzPython*****é   z*****r£   r3   r4   r   r   r   Útest_placeholder_backtrack2  s    ýz+MaxLinesTestCase.test_placeholder_backtrackN)r$   r%   r&   r   r5   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	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 )NrH   )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----------hellory   )z
----------z               hz               eú               lr«   z               oz               )r‰   r,   )	ú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   rH   )zDid you sayz%"supercalifragilisticexpialidocious?"zHow *do* you spell that oddzword, anyways?)r   rN   )r!   rN   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 )Nr,   )r¬   r­   r®   r¡   r@   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                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
Ú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).rF   ©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).rF   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).rF   z  * rz   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                   @   sD   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 r   ©r   r   r4   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º   r4   r   r   r   Útest_dedent_nomargin¼  s    


z#DedentTestCase.test_dedent_nomarginc                 C   sL   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¹   rP   r   r   r   Útest_dedent_evenÍ  s    zDedentTestCase.test_dedent_evenc                 C   sL   d}d}|   |t|ƒ¡ d}d}|   |t|ƒ¡ d}d}|   |t|ƒ¡ d S )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¹   rP   r   r   r   Útest_dedent_unevenÝ  s    z!DedentTestCase.test_dedent_unevenc                 C   sL   d}d}|   |t|ƒ¡ d}d}|   |t|ƒ¡ d}d}|   |t|ƒ¡ d S )Nz     Foo
    Bar
z	 Foo
Bar
z     Foo

    Bar
z
 Foo

Bar
z     Foo
    
    Bar
r¹   rP   r   r   r   Útest_dedent_decliningõ  s    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¹   rP   r   r   r   Ú"test_dedent_preserve_internal_tabs  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   rP   r   r   r   Ú test_dedent_preserve_margin_tabs  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 ©Nr6   ©ÚCASESr   r   r4   r   r   r   Útest_indent_nomargin_defaultD  s    
z+IndentTestCase.test_indent_nomargin_defaultc                 C   s$   | j D ]}|  t|dd ƒ|¡ qd S rÄ   rÅ   r4   r   r   r   Ú%test_indent_nomargin_explicit_defaultI  s    
z4IndentTestCase.test_indent_nomargin_explicit_defaultc                 C   s,   dd„ }| j D ]}|  t|d|ƒ|¡ qd S )Nc                 S   s   dS ©NTr   ©Úliner   r   r   Ú<lambda>R  ó    z?IndentTestCase.test_indent_nomargin_all_lines.<locals>.<lambda>r6   rÅ   ©r   Ú	predicater   r   r   r   Útest_indent_nomargin_all_linesO  s    
z-IndentTestCase.test_indent_nomargin_all_linesc                 C   s,   dd„ }| j D ]}|  t|d|ƒ|¡ qd S )Nc                 S   s   dS )NFr   rÊ   r   r   r   rÌ   X  rÍ   z5IndentTestCase.test_indent_no_lines.<locals>.<lambda>rz   rÅ   rÎ   r   r   r   Útest_indent_no_linesV  s    
z#IndentTestCase.test_indent_no_linesc                 C   s&   | j D ]}|  tt|dƒƒ|¡ qd S )Nrz   ©ÚROUNDTRIP_CASESr   r   r   r4   r   r   r   Útest_roundtrip_spaces\  s    
z$IndentTestCase.test_roundtrip_spacesc                 C   s&   | j D ]}|  tt|dƒƒ|¡ qd S )Nz		rÒ   r4   r   r   r   Útest_roundtrip_tabsa  s    
z"IndentTestCase.test_roundtrip_tabsc                 C   s&   | j D ]}|  tt|dƒƒ|¡ qd S )Nz 	  	 rÒ   r4   r   r   r   Útest_roundtrip_mixedf  s    
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   ÚprefixÚexpectedr   r   r   r   r   Útest_indent_defaultk  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   s>   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   s   dS 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  s
    z$IndentTestCase.test_indent_all_linesc                 C   s>   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   s
   |   ¡  S r   )ÚstriprÊ   r   r   r   rÌ   ±  rÍ   z8IndentTestCase.test_indent_empty_lines.<locals>.<lambda>rÚ   rá   r   r   r   Ú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ä   r   r   r   r   rÁ   0  s   rÁ   c                   @   sD   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 )ÚShortenTestCasec                 K   s"   t ||fi |¤Ž}|  ||¡ d S r   )r   r   r   r   r   r   Úcheck_shorten¸  s    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, [...]rL   z9Hello there, how are you this fine day? I'm glad to [...]©ræ   r   r4   r   r   r   r5   ¼  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 $$rL   z:Hello there, how are you this fine day? I'm glad to hear$$ré   r4   r   r   r   r¦   Æ  s    þz ShortenTestCase.test_placeholderc                 C   s   |   ddd¡ d S )Nr6   r7   ©ræ   r)   r   r   r   r:   Ñ  s    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!  r,   zhello world!é   zhello [...]ry   r¡   rê   r4   r   r   r   rB   Ô  s    ÿÿzShortenTestCase.test_whitespacec                 C   sJ   t dddd |  t¡ t dddd W d   ƒ n1 s<0    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_fitsë  s    z=ShortenTestCase.test_first_word_too_long_but_placeholder_fitsN)
r$   r%   r&   ræ   r5   r¦   r:   rB   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$   Úmainr   r   r   r   Ú<module>   s       4_E3z 9