B
    u9aZ›  ã               @   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   sh   t |tƒrNg }x*tt|ƒƒD ]}| d||| f ¡ qW |rHd |¡nd}nt |tƒrdd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.7/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|Ž}|  ||¡ 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   sD   d}|   |dddddddg¡ |   |d	d
dg¡ |   |d|g¡ d S )Nz=Hello there, how are you this fine day?  I'm glad to hear it!é   zHello there,zhow are youz	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_whitespace)r   )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.   z++)Úinitial_indentF)r1   r/   )r   )r   r   r   r   Ú%test_empty_string_with_initial_indentI   s    z2WrapTestCase.test_empty_string_with_initial_indentc             C   sˆ   d}dddddg}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)Úfix_sentence_endingsr	   z	Test	default		tabsize.z(        Test    default         tabsize.r+   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|_dddg}|  | |¡|¡ d}dddg}|  | |¡|¡ d|_dg}|  | |¡|¡ d}dg}|  | |¡|¡ d S )Né<   T)r3   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   s4    
z&WrapTestCase.test_fix_sentence_endingsc             C   s*   d}|   |dddg¡ |   |ddg¡ d S )NzThis is a
short paragraph.r8   zThis is a shortz
paragraph.é(   zThis is a short paragraph.)r   )r   r   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) )r1   )r   )r   r   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'lyr:   zthis-is-a-useful-feature-for-z%reformatting-posts-from-tim-peters'lyé)   r*   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¬   s"    zWrapTestCase.test_hyphenatedc             C   s’   d}|   |ddddg¡ |   |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.r<   zPython 1.0.0 was released onz1994-01-26.  Python 1.0.1 waszreleased on 1994-02-15.r:   z(Python 1.0.0 was released on 1994-01-26.z(Python 1.0.1 was released on 1994-02-15.r@   F)rA   zI do all my shopping at 7-11.é   zI do all my shopping atz7-11.é   é   )r   rB   )r   r   r   r   r   Útest_hyphenated_numbersÆ   s    



z$WrapTestCase.test_hyphenated_numbersc             C   sZ  d}|   |dddg¡ |   |dddg¡ dd	g}|   |d
|¡ |   |d|¡ |   |ddg¡ d}dddg}|   |d|¡ |   |d|¡ dddg}|   |d|¡ |   |d|¡ ddg}|   |d|¡ |   |d|¡ ddg}|   |d|¡ |   |d|¡ d}ddddd dd!d"dd#d d$dd%d&d#dd'g}|  ||¡ d(}d#dd)d d*d d+dd,dd-g}|  ||¡ d S ).Nz$Em-dashes should be written -- thus.rD   zEm-dashes should bezwritten -- thus.rF   zEm-dashes should be writtenz-- thus.zEm-dashes should be written --zthus.r<   é#   é$   z%You can also do--this or even---this.zYou can also doz--this or evenz---this.é   é   zYou can also do--zthis or even---zthis.é   é   zYou can also do--this or evené   z You can also do--this or even---é    z7Here's an -- em-dash and--here's another---and another!zHere'sú Zanz--zem-ZdashÚandzhere'sZanotherz---zanother!zand then--bam!--he was goneZthenzbam!ÚheZwasZgone)r   r!   )r   r   r   r   r   r   Útest_em_dashÚ   sR    
zWrapTestCase.test_em_dashc             C   sÜ   d}|   |dddddg¡ |   |ddd	d
g¡ ddg}|   |d|¡ |   |d|¡ |   |d|¡ |   |d|¡ ddg}|   |d|¡ |   |d|¡ dd
g}|   |d|¡ d}ddddddddddddddg}|  ||¡ d S ) Nz<You should use the -n option, or --dry-run in its long form.r8   zYou should use thez-n option, or --dry-zrun in its longzform.é   zYou should use the -nzoption, or --dry-runzin its long form.z You should use the -n option, orz--dry-run in its long form.rO   é"   rH   é&   z'You should use the -n option, or --dry-zrun in its long form.é'   r>   z*You should use the -n option, or --dry-runr*   z'the -n option, or --dry-run or --dryrunÚtherP   z-nzoption,Úorz--dry-Úrunz--dryrun)r   r!   )r   r   r   r   r   r   Útest_unix_options  s6    zWrapTestCase.test_unix_optionsc          	   C   s‚   |   ddddddg¡ |   ddddg¡ |   d	ddd
g¡ |   ddg¡ |   ddg¡ |   dddg¡ |   dddddddg¡ d S )Nzwhat the--hey!ZwhatrP   rX   z--zhey!z
what the--zthe--zwhat the--.zthe--.z	--text--.z--optionz--option-optz	--option-Úoptzfoo --option-opt barÚfooÚbar)r!   )r   r   r   r   Útest_funky_hyphens3  s    zWrapTestCase.test_funky_hyphensc          	   C   sv   |   dddddddg¡ |   ddddd	ddg¡ |   d
ddddddg¡ |   dddddddg¡ |   dd d¡¡ d S )Nzthe 'wibble-wobble' widgetrX   rP   z'wibble-zwobble'Zwidgetzthe "wibble-wobble" widgetz"wibble-zwobble"zthe (wibble-wobble) widgetz(wibble-zwobble)zthe ['wibble-wobble'] widgetz	['wibble-zwobble']zwhat-d'you-call-it.zwhat-d'you-|call-|it.r?   )r!   rB   )r   r   r   r   Útest_punct_hyphensD  s    zWrapTestCase.test_punct_hyphensc          
   C   sJ   |   ddddddg¡ |   ddddddg¡ |   d	d
ddddddg¡ d S )Nzfoo (--option) barr]   rP   z
(--option)r^   zfoo (bar) bazz(bar)Zbazzblah (ding dong), wubbaZblahz(dingzdong),Zwubba)r!   )r   r   r   r   Útest_funky_parensY  s    
zWrapTestCase.test_funky_parensc          	   C   s&   d}| j |dddddddgd	d
 d S )Nz0 This is a    sentence with     much whitespace.é
   z
 This is az    z	sentence z	with     z
much whitezspace.F)r/   )r   )r   r   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 )Nz   r.   F)r/   )r   )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 )Nz   r.   z     Fz  )r/   r1   )r   )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 )Nz  r.   )r   )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   r<   z This is a sentence withzleading whitespace.)r   )r   r   r   r   r   Ú'test_drop_whitespace_leading_whitespace}  s
    z4WrapTestCase.test_drop_whitespace_leading_whitespacec             C   s2   d}| j |ddddgdd |   |dddg¡ d S )Nzabcd    efghr.   Zabcdz    ZefghF)r/   )r   )r   r   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 )Nz  r.   z++)r1   )r   )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  efghz  )r1   Úsubsequent_indent)r   )r   r   r   r   Ú&test_drop_whitespace_whitespace_indent—  s    z3WrapTestCase.test_drop_whitespace_whitespace_indentc             C   sD   d}| j  |¡}|  |dddddddddddd	dd
ddddg¡ d S )Nz0Hello there -- you goof-ball, use the -b option!ÚHellorP   Ztherez--Zyouzgoof-zball,ZuserX   z-bz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-doorb   z
yaba daba-ZdooT)Úbreak_on_hyphensZyabazdaba-dooF)r   )r   r   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   )r   r   r   r   r   Útest_bad_width±  s    zWrapTestCase.test_bad_widthc             C   s   d}|   |ddddg¡ d S )Nu   Die EmpfÃ¤nger-Auswahlé   ZDieu   EmpfÃ¤nger-ZAuswahl)r   )r   r   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   Ã¤Ã¤)r   )r   r   r   r   r   Útest_umlaut_followed_by_dash»  s    z)WrapTestCase.test_umlaut_followed_by_dashc             C   s8   d}| j |ddddgdd | j |dddd	gd
d d S )Nu,   This is a sentence with non-breakingÂ space.r8   zThis is a sentencez	with non-u   breakingÂ space.T)ro   Úwithu   non-breakingÂ space.F)r   )r   r   r   r   r   Útest_non_breaking_space¿  s    z$WrapTestCase.test_non_breaking_spacec             C   s8   d}| j |ddddgdd | j |dddd	gd
d d S )Nu-   This is a sentence with non-breakingâ€¯space.r8   zThis is a sentencez	with non-u   breakingâ€¯space.T)ro   ry   u   non-breakingâ€¯space.F)r   )r   r   r   r   r   Útest_narrow_non_breaking_spaceÎ  s    z+WrapTestCase.test_narrow_non_breaking_spaceN)!r"   r#   r$   r(   r,   r0   r2   r6   r9   r;   r=   rC   rG   rS   r[   r_   r`   ra   rc   rd   re   rf   rh   ri   rj   rl   rn   rp   rt   rv   rx   rz   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 )ÚMaxLinesTestCasez=Hello there, how are you this fine day?  I'm glad to hear it!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ddddddgdd d S )Nr)   zHello [...]r   )Ú	max_linesr@   zHello there,z	how [...]é   ru   zhow are [...]r+   zhow are youz	this finez	day?  I'mzglad to hearzit!r.   )r   r   )r   r   r   r   r,   â  s.    




zMaxLinesTestCase.test_simplec          	   C   s\   | j | jdddddgdd | j | jdd	d
gdd | j | jd dddddddgdd d S )Nr)   zHello there,zhow are youz	this finez
day? [...]r4   )r}   r.   rm   z[...]r~   z
          z	day?  I'mzglad to hearzit!)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 Q R X |  t¡ t| jd	d
ddd W d Q R X | 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...r@   z...)r}   ÚplaceholderzHello there,z
how are...r~   rK   z    z [truncated]...)r1   r}   r€   )rk   r}   r€   z    Hello there,z  [truncated]...z  )r}   r1   rk   r€   r+   aè  ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................)r€   )r   r   rr   rs   r   )r   r   r   r   Útest_placeholder  s:    





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}   r€   )r   )r   r   r   r   r   Útest_placeholder_backtrack2  s
    z+MaxLinesTestCase.test_placeholder_backtrackN)r"   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 )
Ú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   sp   |   | jdddddg¡ |   | jdddg¡ | j d	d
ddddddgdd |   | jddddddddddg	¡ d S )Nr<   zDid you say "supercalifragiliszticexpialidocious?" How *do*zyou spell that odd word,zanyways?rg   z1Did you say "supercalifragilisticexpialidocious?"z*How *do* you spell that odd word, anyways?z----------hellorb   z
----------z               hz               ez               lz               oz               )rk   r)   zDid you say z"supercalifrÚagilisticexpzialidocious?z
" How *do*z	you spellzthat oddzword,)r   r   )r   r   r   r   Útest_break_longF  s4    


z LongWordTestCase.test_break_longc             C   sV   d| j _d| j _ddddg}| j  | j¡}|  ||¡ t| jddd}|  ||¡ d S )Nr   r<   zDid you sayz%"supercalifragilisticexpialidocious?"zHow *do* you spell that oddzword, anyways?)r   rA   )r   rA   r   r   r   r   )r   r   r   r   r   r   Útest_nobreak_longj  s    z"LongWordTestCase.test_nobreak_longc             C   s    | j | jdddddgdd d S )Nr)   zDid you say z"supercalifrr…   z[...]r4   )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).r:   )r   r   r   )r   r   r   r   r   r   Ú	test_fillŒ  s    zIndentTestCases.test_fillc             C   sP   dddg}t | jddd}|  ||¡ d |¡}t| jddd}|  ||¡ d S )Nz#     This paragraph will be filled,z'first without any indentation, and thenz'with some (including a hanging indent).r:   z     )r1   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).r:   z  * z    )r1   rk   )r   r   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   )r   r   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Ž   )r   r   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   r   )r   r   r   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   r   )r   r   r   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   r   )r   r   r   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   r   )r   r   r   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   )r   r   r   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)zHi.
This is a test.
Testing.zHi.
This is a test.

Testing.z
Hi.
This is a test.
Testing.
)z Hi.
This is a test.
Testing.
z#
Hi.
This is a test.

Testing.

c             C   s&   x | j D ]}|  t|dƒ|¡ qW d S )Nr-   )ÚCASESr   r   )r   r   r   r   r   Útest_indent_nomargin_defaultD  s    z+IndentTestCase.test_indent_nomargin_defaultc             C   s(   x"| j D ]}|  t|dd ƒ|¡ qW d S )Nr-   )r–   r   r   )r   r   r   r   r   Ú%test_indent_nomargin_explicit_defaultI  s    z4IndentTestCase.test_indent_nomargin_explicit_defaultc             C   s0   dd„ }x"| j D ]}|  t|d|ƒ|¡ qW d S )Nc             S   s   dS )NTr   )Úliner   r   r   Ú<lambda>R  ó    z?IndentTestCase.test_indent_nomargin_all_lines.<locals>.<lambda>r-   )r–   r   r   )r   Ú	predicater   r   r   r   Útest_indent_nomargin_all_linesO  s    z-IndentTestCase.test_indent_nomargin_all_linesc             C   s0   dd„ }x"| j D ]}|  t|d|ƒ|¡ qW d S )Nc             S   s   dS )NFr   )r™   r   r   r   rš   X  r›   z5IndentTestCase.test_indent_no_lines.<locals>.<lambda>z    )r–   r   r   )r   rœ   r   r   r   r   Útest_indent_no_linesV  s    z#IndentTestCase.test_indent_no_linesc             C   s*   x$| j D ]}|  tt|dƒƒ|¡ qW d S )Nz    )ÚROUNDTRIP_CASESr   r   r   )r   r   r   r   r   Útest_roundtrip_spaces\  s    z$IndentTestCase.test_roundtrip_spacesc             C   s*   x$| j D ]}|  tt|dƒƒ|¡ qW d S )Nz		)rŸ   r   r   r   )r   r   r   r   r   Útest_roundtrip_tabsa  s    z"IndentTestCase.test_roundtrip_tabsc             C   s*   x$| j D ]}|  tt|dƒƒ|¡ qW d S )Nz 	  	 )rŸ   r   r   r   )r   r   r   r   r   Útest_roundtrip_mixedf  s    z#IndentTestCase.test_roundtrip_mixedc             C   s8   d}d}x*t | j|ƒD ]\}}|  t||ƒ|¡ qW d S )Nz  )z"  Hi.
  This is a test.
  Testing.z#  Hi.
  This is a test.

  Testing.z$
  Hi.
  This is a test.
  Testing.
z&  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   s:   d}d}x,t | j|ƒD ]\}}|  t||d ƒ|¡ qW d S )Nz  )z"  Hi.
  This is a test.
  Testing.z#  Hi.
  This is a test.

  Testing.z$
  Hi.
  This is a test.
  Testing.
z&  Hi.
  This is a test.
  Testing.
z)
  Hi.
  This is a test.

  Testing.

)r£   r–   r   r   )r   r¤   r¥   r   r   r   r   r   Útest_indent_explicit_default}  s    
z+IndentTestCase.test_indent_explicit_defaultc             C   sB   d}d}dd„ }x,t | j|ƒD ]\}}|  t|||ƒ|¡ qW d S )Nz  )z"  Hi.
  This is a test.
  Testing.z%  Hi.
  This is a test.
  
  Testing.z&  
  Hi.
  This is a test.
  Testing.
z&  Hi.
  This is a test.
  Testing.
z/  
  Hi.
  This is a test.
  
  Testing.
  
c             S   s   dS )NTr   )r™   r   r   r   rš   ž  r›   z6IndentTestCase.test_indent_all_lines.<locals>.<lambda>)r£   r–   r   r   )r   r¤   r¥   rœ   r   r   r   r   r   Útest_indent_all_lines  s
    
z$IndentTestCase.test_indent_all_linesc             C   sB   d}d}dd„ }x,t | j|ƒD ]\}}|  t|||ƒ|¡ qW d S )Nz  )zHi.
This is a test.
Testing.zHi.
This is a test.
  
Testing.z   
Hi.
This is a test.
Testing.
z Hi.
This is a test.
Testing.
z)  
Hi.
This is a test.
  
Testing.
  
c             S   s
   |   ¡  S )N)Ústrip)r™   r   r   r   rš   ±  r›   z8IndentTestCase.test_indent_empty_lines.<locals>.<lambda>)r£   r–   r   r   )r   r¤   r¥   rœ   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|Ž}|  ||¡ d S )N)r   r   )r   r   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 )Nz<Hello there, how are you this fine day? I'm glad to hear it!é   zHello there, [...]r@   z9Hello there, how are you this fine day? I'm glad to [...])r¬   r   )r   r   r   r   r   r,   ¼  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 )Nz<Hello there, how are you this fine day? I'm glad to hear it!rL   zHello there,$$z$$)r€   r­   zHello there, how$$zHello there, $$z $$r@   z:Hello there, how are you this fine day? I'm glad to hear$$)r¬   r   )r   r   r   r   r   r   Æ  s    z ShortenTestCase.test_placeholderc             C   s   |   ddd¡ d S )Nr-   r.   )r¬   )r   r   r   r   r0   Ñ  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 [...]rb   z[...])r¬   )r   r   r   r   r   r6   Ô  s    zShortenTestCase.test_whitespacec          	   C   s6   t dddd |  t¡ t dddd W d Q R X d S )NZxxxxxxxxxxxxxxxxxxxxé   z(......))r   r€   z	(.......))r   rr   rs   )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é   z[...])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¬   r,   r   r0   r6   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