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                   @   s0   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   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__Ú__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_whitespacer4   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 )Nr7   r8   ú++©Úinitial_indentF)r>   r:   r4   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.r3   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.rE   zThis is a shortz
paragraph.é(   zThis is a short paragraph.r4   r5   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=   r4   r5   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'lyrG   zthis-is-a-useful-feature-for-z%reformatting-posts-from-tim-peters'lyé)   r2   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.rI   )zPython 1.0.0 was released onz1994-01-26.  Python 1.0.1 waszreleased on 1994-02-15.rG   z(Python 1.0.0 was released on 1994-01-26.z(Python 1.0.1 was released on 1994-02-15.rM   FrN   zI do all my shopping at 7-11.é   zI do all my shopping atz7-11.é   é   )r    rP   r5   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.rS   zEm-dashes should bezwritten -- thus.rU   zEm-dashes should be writtenz-- thus.zEm-dashes should be written --zthus.rI   é#   é$   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 evenrY   é   z You can also do--this or even---r\   é    z7Here's an -- em-dash and--here's another---and another!)zHere'sú Zanra   ú--ra   zem-Zdashra   Úandrb   zhere'sra   Zanotherz---rc   ra   zanother!zand then--bam!--he was gone)rc   ra   Zthenrb   zbam!rb   Úhera   Zwasra   Zgone©r    r#   rQ   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.rE   )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`   é"   rW   é&   z'You should use the -n option, or --dry-zrun in its long form.é'   rK   z*You should use the -n option, or --dry-runrh   r2   z'the -n option, or --dry-run or --dryrun)Úthera   z-nra   zoption,ra   Úorra   z--dry-Úrunra   rm   ra   z--dryrunre   rQ   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!)Úwhatra   rl   rb   zhey!z
what the--)rp   ra   zthe--zwhat the--.)rp   ra   zthe--.z	--text--.z--optionz--option-optú	--option-Úoptzfoo --option-opt bar)Úfoora   rq   rr   ra   Ú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)rl   ra   z'wibble-zwobble'ra   Úwidgetzthe "wibble-wobble" widget)rl   ra   z"wibble-zwobble"ra   rw   zthe (wibble-wobble) widget)rl   ra   z(wibble-zwobble)ra   rw   zthe ['wibble-wobble'] widget)rl   ra   z	['wibble-zwobble']ra   rw   zwhat-d'you-call-it.zwhat-d'you-|call-|it.rL   )r#   rP   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)rs   ra   z
(--option)ra   rt   zfoo (bar) baz)rs   ra   z(bar)ra   Zbazzblah (ding dong), wubba)Zblahra   z(dingra   zdong),ra   Zwubbaru   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.Fr9   r4   r5   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ú   r8   Fr9   r4   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}   r8   ú     Fú  )r:   r>   r4   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€   r8   r4   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   rI   z This is a sentence withzleading whitespace.r4   r5   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    efghr8   )Úabcdr{   ÚefghFr9   r…   r†   r4   r5   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€   r8   r<   r=   r4   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 efghr8   z  abcdz  efghr€   ©r>   Úsubsequent_indentr4   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!)ÚHellora   Ztherera   rb   ra   Zyoura   zgoof-zball,ra   Zusera   rl   ra   z-bra   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-doorz   z
yaba daba-ZdooT©Zbreak_on_hyphensZyabazdaba-dooFr4   r5   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   r5   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Auswahlr4   r5   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   Ã¤Ã¤r4   r5   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.rE   )úThis is a sentenceú	with non-u   breakingÂ space.TrŽ   )r˜   Úwithu   non-breakingÂ space.Fr4   r5   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.rE   )r˜   r™   u   breakingâ€¯space.TrŽ   )r˜   rš   u   non-breakingâ€¯space.Fr4   r5   r   r   r   Útest_narrow_non_breaking_spaceÎ  s    üüz+WrapTestCase.test_narrow_non_breaking_spaceN)!r$   r%   r&   r+   r6   r;   r?   rC   rF   rH   rJ   rR   rV   rf   ro   rv   rx   ry   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_linesrM   r/   z	how [...]é   r”   zhow are [...]r3   r.   r8   ©r    r   r*   r   r   r   r6   â  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/   r0   r1   z
day? [...]rA   rž   r8   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...rM   z...©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¥   r3   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¤   r4   r5   r   r   r   Útest_placeholder_backtrack2  s    ýz+MaxLinesTestCase.test_placeholder_backtrackN)r$   r%   r&   r   r6   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 )NrI   )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----------hellorz   )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   rI   )zDid you sayz%"supercalifragilisticexpialidocious?"zHow *do* you spell that oddzword, anyways?)r   rO   )r!   rO   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¢   rA   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).rG   ©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).rG   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).rG   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                   @   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 )z,assert that dedent() has no effect on 'text'N©r   r   r5   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»   r5   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º   rQ   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º   rQ   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º   rQ   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º   rQ   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   rQ   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 ©Nr7   ©ÚCASESr   r   r5   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Æ   r5   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>r7   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>r{   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 )Nr{   ©ÚROUNDTRIP_CASESr   r   r   r5   r   r   r   Útest_roundtrip_spaces\  s    
z$IndentTestCase.test_roundtrip_spacesc                 C   s&   | j D ]}|  tt|dƒƒ|¡ qd S )Nz		rÓ   r5   r   r   r   Útest_roundtrip_tabsa  s    
z"IndentTestCase.test_roundtrip_tabsc                 C   s&   | j D ]}|  tt|dƒƒ|¡ qd S )Nz 	  	 rÓ   r5   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, [...]rM   z9Hello there, how are you this fine day? I'm glad to [...]©rç   r   r5   r   r   r   r6   ¼  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 $$rM   z:Hello there, how are you this fine day? I'm glad to hear$$rê   r5   r   r   r   r§   Æ  s    þz ShortenTestCase.test_placeholderc                 C   s   |   ddd¡ d S )Nr7   r8   ©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 [...]rz   r¢   rë   r5   r   r   r   rC   Ô  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ç   r6   r§   r;   rC   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