o
    HXîh‹§  ã                   @   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                   @   s.   e Zd Z	 dd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚBaseTestCasec                 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   ú</opt/python-3.10.19/usr/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__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_whitespacer5   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 )Nr8   r9   ú++©Úinitial_indentF)r?   r;   r5   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.r4   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é<   TrA   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.rF   zThis is a shortz
paragraph.é(   zThis is a short paragraph.r5   r6   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>   r5   r6   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'lyrH   zthis-is-a-useful-feature-for-z%reformatting-posts-from-tim-peters'lyé)   r3   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.rJ   )zPython 1.0.0 was released onz1994-01-26.  Python 1.0.1 waszreleased on 1994-02-15.rH   z(Python 1.0.0 was released on 1994-01-26.z(Python 1.0.1 was released on 1994-02-15.rN   FrO   zI do all my shopping at 7-11.é   zI do all my shopping atz7-11.é   é   )r!   rQ   r6   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.rT   zEm-dashes should bezwritten -- thus.rV   zEm-dashes should be writtenz-- thus.zEm-dashes should be written --zthus.rJ   é#   é$   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 evenrZ   é   z You can also do--this or even---r]   é    z7Here's an -- em-dash and--here's another---and another!)zHere'sú Zanrb   ú--rb   zem-Zdashrb   Úandrc   zhere'srb   Zanotherz---rd   rb   zanother!zand then--bam!--he was gone)rd   rb   Zthenrc   zbam!rc   Úherb   Zwasrb   Zgone©r!   r%   rR   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.rF   )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.ra   é"   rX   é&   z'You should use the -n option, or --dry-zrun in its long form.é'   rL   z*You should use the -n option, or --dry-runri   r3   z'the -n option, or --dry-run or --dryrun)Útherb   z-nrb   zoption,rb   Úorrb   z--dry-Úrunrb   rn   rb   z--dryrunrf   rR   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!)Úwhatrb   rm   rc   zhey!z
what the--)rq   rb   zthe--zwhat the--.)rq   rb   zthe--.z	--text--.z--optionz--option-optú	--option-Úoptzfoo --option-opt bar)Úfoorb   rr   rs   rb   Ú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)rm   rb   z'wibble-zwobble'rb   Úwidgetzthe "wibble-wobble" widget)rm   rb   z"wibble-zwobble"rb   rx   zthe (wibble-wobble) widget)rm   rb   z(wibble-zwobble)rb   rx   zthe ['wibble-wobble'] widget)rm   rb   z	['wibble-zwobble']rb   rx   zwhat-d'you-call-it.zwhat-d'you-|call-|it.rM   )r%   rQ   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)rt   rb   z
(--option)rb   ru   zfoo (bar) baz)rt   rb   z(bar)rb   Zbazzblah (ding dong), wubba)Zblahrb   z(dingrb   zdong),rb   Zwubbarv   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:   r5   r6   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ú   r9   Fr:   r5   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~   r9   ú     Fú  )r;   r?   r5   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   r9   r5   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   rJ   z This is a sentence withzleading whitespace.r5   r6   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    efghr9   )Úabcdr|   ÚefghFr:   r†   r‡   r5   r6   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   r9   r=   r>   r5   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 efghr9   z  abcdz  efghr   ©r?   Úsubsequent_indentr5   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!)ÚHellorb   Zthererb   rc   rb   Zyourb   zgoof-zball,rb   Zuserb   rm   rb   z-brb   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-dooFr5   r6   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   r6   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Auswahlr5   r6   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   Ã¤Ã¤r5   r6   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.rF   )úThis is a sentenceú	with non-u   breakingÂ space.Tr   )rœ   Úwithu   non-breakingÂ space.Fr5   r6   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.rF   )rœ   r   u   breakingâ€¯space.Tr   )rœ   rž   u   non-breakingâ€¯space.Fr5   r6   r   r   r   Útest_narrow_non_breaking_spaceÎ  s   ü
üz+WrapTestCase.test_narrow_non_breaking_spaceN)!r&   r'   r(   r,   r7   r<   r@   rD   rG   rI   rK   rS   rW   rg   rp   rw   ry   rz   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_linesrN   r0   z	how [...]é   r–   zhow are [...]r4   r/   r9   ©r!   r   r+   r   r   r   r7   â  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.   )r0   r1   r2   z
day? [...]rB   r¢   r9   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 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 )Nr.   zHello...rN   z...©r£   Úplaceholderr0   z
how are...r¤   r\   r|   z [truncated]...)r?   r£   r©   )r‹   r£   r©   z    Hello there,z  [truncated]...r   )r£   r?   r‹   r©   r4   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!r.   z
Good griefzPython*****é   z*****r¨   r5   r6   r   r   r   Útest_placeholder_backtrack2  s   
ýz+MaxLinesTestCase.test_placeholder_backtrackN)r&   r'   r(   r   r7   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 )NrJ   )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‹   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   rJ   )zDid you sayz%"supercalifragilisticexpialidocious?"zHow *do* you spell that oddzword, anyways?)r   rP   )r#   rP   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¦   rB   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„   FrO   ©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)rP   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).rH   ©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).rH   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).rH   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 r   ©r   r   r6   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Ò   r6   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Ñ   rR   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Ñ   rR   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Ñ   rR   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Ñ   rR   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   rR   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 ©Nr8   ©ÚCASESr   r   r6   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ß   r6   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>r8   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   r6   r   r   r   Útest_roundtrip_spaces¤  ó   
ÿz$IndentTestCase.test_roundtrip_spacesc                 C   rî   )Nz		rï   r6   r   r   r   Útest_roundtrip_tabs©  rò   z"IndentTestCase.test_roundtrip_tabsc                 C   rî   )Nz 	  	 rï   r6   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, [...]rN   z9Hello there, how are you this fine day? I'm glad to [...]©r  r   r6   r   r   r   r7     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 $$rN   z:Hello there, how are you this fine day? I'm glad to hear$$r  r6   r   r   r   r«     s   
þz ShortenTestCase.test_placeholderc                 C   s   |   ddd¡ d S )Nr8   r9   ©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!  r.   zhello world!é   zhello [...]r{   r¦   r	  r6   r   r   r   rD     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  r7   r«   r<   rD   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ÿ