
    daf                     \   d dl Z d dlmZmZmZmZmZmZ  G d de j                        Z	 G d de	      Z
 G d de	      Z G d	 d
e	      Z G d de	      Z G d de	      Z G d de j                        Z G d de j                        Z G d de	      Zedk(  r e j&                          yy)    N)TextWrapperwrapfilldedentindentshortenc                   (    e Zd ZdZd Zd Zd Zd Zy)BaseTestCasez5Parent class with utility methods for textwrap tests.c                     t        |t              rMg }t        t        |            D ]  }|j	                  d|||   fz          |rdj                  |      }|S d}|S t        |t              rdt        |      z  }S )Nz  %d: %r
z
  no linesz  %s
)
isinstancelistrangelenappendjoinstrrepr)selftextinresultis       -/root/Python-3.12.4/Lib/test/test_textwrap.pyshowzBaseTestCase.show   s    fd#F3v;' ;jAvay>9:;*0TYYv&F  7CF  $V,F    c           
      r    | j                  ||d| j                  |      d| j                  |             y )Nz
expected:
z

but got:
)assertEqualr   )r   r   expects      r   checkzBaseTestCase.check   s0    		&!499V#46	7r   c                 B    t        ||fi |}| j                  ||       y N)r   r   r   textwidthr   kwargsr   s         r   
check_wrapzBaseTestCase.check_wrap#   s!    dE,V,

66"r   c                 l    | j                   j                  |      }| j                  ||d|d|       y )Nz

expected z

but got  )wrapper_splitr   )r   r#   r   r   s       r   check_splitzBaseTestCase.check_split'   s2    $$T**0&:	;r   N)__name__
__module____qualname____doc__r   r   r&   r*    r   r   r
   r
      s    ?7
#;r   r
   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z y) WrapTestCasec                 &    t        d      | _        y )N-   )r$   )r   r(   r   s    r   setUpzWrapTestCase.setUp0   s    ",r   c                     d}| j                  |dg d       | j                  |dddg       | j                  |d|g       y )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#   s     r   test_simplezWrapTestCase.test_simple3   sP     Ob 	! 	bB/1	2 	b4&)r   c                 T    | j                  ddg        | j                  ddg d       y )N    Fdrop_whitespacer?   r4   s    r   test_empty_stringzWrapTestCase.test_empty_stringD   s&    Ar"Ar59r   c                 Z    | j                  ddg d       | j                  ddg dd       y )NrC   rD   ++initial_indentF)rK   rF   r?   r4   s    r   %test_empty_string_with_initial_indentz2WrapTestCase.test_empty_string_with_initial_indentI   s,    Ar$7Ar$Nr   c                 8   d}g d}t        dd      }|j                  |      }| j                  ||       |j                  |      }| j                  |dj	                  |             d}dg}| j                  |d	|       d
}dg}| j                  |d	|d       y )NzThis 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!r3   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   s        r   test_whitespacezWrapTestCase.test_whitespaceN   s     bt<d#

66"d#

6499V,-,<=b&)+45b&!4r   c                    t        dd      }d}dg}| j                  |j                  |      |       d}dg}| j                  |j                  |      |       d}| j                  |j                  |      |       d	}d
g}| j                  |j                  |      |       d|_        g d}| j                  |j                  |      |       d}g d}| j                  |j                  |      |       d|_        dg}| j                  |j                  |      |       d}dg}| j                  |j                  |      |       y )N<   TrN   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   s       r   test_fix_sentence_endingsz&WrapTestCase.test_fix_sentence_endingsn   s,   bt<
 69:

7<<%v.
 256

7<<%v.2

7<<%v.;?@

7<<%v.D

7<<%v.C# 	

7<<%v.FG

7<<%v.&)*

7<<%v.r   c                 Z    d}| j                  |dddg       | j                  |ddg       y )NzThis is a
short paragraph.rU   zThis is a shortz
paragraph.(   zThis is a short paragraph.r?   r@   s     r   test_wrap_shortzWrapTestCase.test_wrap_short   s8     -b#4#/#1 	2b#?"@Ar   c                 \    d}| j                  |ddg       | j                  |ddgd       y )NzThis is a short line.   z(1) This is a short line.z(1) rJ   r?   r@   s     r   test_wrap_short_1linez"WrapTestCase.test_wrap_short_1line   s;     'b#:";<b#>"?'- 	 	/r   c                    d}| j                  |dddg       | j                  |dddg       | j                  |dddg       d	j                  d
      }| j                  |d|d       | j                  ||       | j                  ddg       | j                  ddg       | j                  ddj                  d
             y )NzBthis-is-a-useful-feature-for-reformatting-posts-from-tim-peters'lyrX   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   s      r   test_hyphenatedzWrapTestCase.test_hyphenated   s    8 	b8@B	C 	b8@B	C 	bE35	6>?DuSz 	a%@v&H:.YK0)9)?)?)DEr   c                 h   d}| j                  |dg d       | j                  |dddg       | j                  |d|j                         d	       d
}| j                  |dddg       | j                  |dddg       | j                  |dd
g       | j                  |d|j                         d	       y )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.rX   z(Python 1.0.0 was released on 1994-01-26.z(Python 1.0.1 was released on 1994-02-15.r`   Fra   zI do all my shopping at 7-11.   zI do all my shopping atz7-11.      )r&   rc   r@   s     r   test_hyphenated_numbersz$WrapTestCase.test_hyphenated_numbers   s    * 	b #> 	? 	b#M#M#O 	PaF.b#<#*#, 	-b#<#*#, 	-b#B"CDaFr   c                    d}| j                  |dddg       | j                  |dddg       dd	g}| j                  |d
|       | j                  |d|       | j                  |ddg       d}g d}| j                  |d|       | j                  |d|       g d}| j                  |d|       | j                  |d|       ddg}| j                  |d|       | j                  |d|       ddg}| j                  |d|       | j                  |d|       d}g d}| j                  ||       d}g d}| j                  ||       y )Nz$Em-dashes should be written -- thus.rg   zEm-dashes should bezwritten -- thus.ri   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 even---this.      )zYou can also do--zthis or even---this.      zYou can also do--this or evenrn      z You can also do--this or even---rq       z7Here's an -- em-dash and--here's another---and another!)zHere's anrv   --rv   zem-dashrv   andrx   zhere'srv   anotherz---rz   rv   zanother!zand then--bam!--he was gone)rz   rv   thenrx   zbam!rx   herv   wasrv   goner&   r*   rd   s      r   test_em_dashzWrapTestCase.test_em_dash   su   5b.+-	. 	b6#%	& 3b&)b&)b?@	B
 7 	b&)b&) 	b&)b&)1b&)b&)4b&)b&) I* 	v&,1v&r   c                    d}| j                  |dg d       | j                  |dg d       ddg}| j                  |d|       | j                  |d	|       | j                  |d
|       | j                  |d|       ddg}| j                  |d|       | j                  |d|       ddg}| j                  |d|       d}g d}| j                  ||       y )Nz<You should use the -n option, or --dry-run in its long form.rU   )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.ru   "   rl   &   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   r=   z'the -n option, or --dry-run or --dryrun)therv   z-nrv   zoption,rv   orrv   z--dry-runrv   r   rv   z--dryrunr   rd   s      r   test_unix_optionszWrapTestCase.test_unix_options  s     Nb"	#
 	b.	/ 5/1b&)b&)b&)b&);)+b&)b&)>%'b&) 9?v&r   c                    | j                  dg d       | j                  dg d       | j                  dg d       | j                  ddg       | j                  ddg       | j                  d	d
dg       | j                  dg d       y )Nzwhat the--hey!)whatrv   r   rx   zhey!z
what the--)r   rv   zthe--zwhat the--.)r   rv   zthe--.z	--text--.z--optionz--option-opt	--option-optzfoo --option-opt bar)foorv   r   r   rv   barr*   r4   s    r   test_funky_hyphenszWrapTestCase.test_funky_hyphens3  s     	)+MN'=>(?@{m4 	j\2+u)=>/E	Gr   c                     | j                  dg d       | j                  dg d       | j                  dg d       | j                  dg d       | j                  d	d
j                  d             y )Nzthe 'wibble-wobble' widget)r   rv   z'wibble-zwobble'rv   widgetzthe "wibble-wobble" widget)r   rv   z"wibble-zwobble"rv   r   zthe (wibble-wobble) widget)r   rv   z(wibble-zwobble)rv   r   zthe ['wibble-wobble'] widget)r   rv   z	['wibble-zwobble']rv   r   zwhat-d'you-call-it.zwhat-d'you-|call-|it.r_   )r*   rc   r4   s    r   test_punct_hyphenszWrapTestCase.test_punct_hyphensD  sy     	5K	M5K	M5K	M7M	O 	.066s;	=r   c                 |    | j                  dg d       | j                  dg d       | j                  dg d       y )Nzfoo (--option) bar)r   rv   z
(--option)rv   r   zfoo (bar) baz)r   rv   z(bar)rv   bazzblah (ding dong), wubba)blahrv   z(dingrv   zdong),rv   wubbar   r4   s    r   test_funky_parenszWrapTestCase.test_funky_parensY  sD     	-?	A 	:	<2(	)r   c                 6    d}| j                  |dg dd       y )Nz0 This is a    sentence with     much whitespace.
   )z
 This is a    z	sentence z	with     z
much whitezspace.FrE   r?   r@   s     r   test_drop_whitespace_falsez'WrapTestCase.test_drop_whitespace_falsef  s'     Bb>(- 	 	/r   c                 0    | j                  dddgd       y )N   rD   FrE   r?   r4   s    r   *test_drop_whitespace_false_whitespace_onlyz7WrapTestCase.test_drop_whitespace_false_whitespace_onlyo  s    q5'5Ar   c                 2    | j                  dddgdd       y )Nr   rD        F  )rF   rK   r?   r4   s    r   6test_drop_whitespace_false_whitespace_only_with_indentzCWrapTestCase.test_drop_whitespace_false_whitespace_only_with_indents  s"     	q7)U'+ 	 	-r   c                 *    | j                  ddg        y )Nr   rD   r?   r4   s    r   $test_drop_whitespace_whitespace_onlyz1WrapTestCase.test_drop_whitespace_whitespace_onlyy  s    a$r   c                 Z    d}| j                  |ddg       | j                  |dddg       y )Nz, This is a sentence with leading whitespace.2   r[   z This is a sentence withzleading whitespace.r?   r@   s     r   'test_drop_whitespace_leading_whitespacez4WrapTestCase.test_drop_whitespace_leading_whitespace}  s:    
 >bGH	Jb35JK	Mr   c                 `    d}| j                  |dg dd       | j                  |dddg       y )Nzabcd    efghrD   )abcdr   efghFrE   r   r   r?   r@   s     r   $test_drop_whitespace_whitespace_linez1WrapTestCase.test_drop_whitespace_whitespace_line  s9     a!9(- 	 	/a&&!12r   c                 .    | j                  ddg d       y )Nr   rD   rI   rJ   r?   r4   s    r   0test_drop_whitespace_whitespace_only_with_indentz=WrapTestCase.test_drop_whitespace_whitespace_only_with_indent  s     	aD9r   c                 4    | j                  ddddgdd       y )Nz	abcd efghrD   z  abcdz  efghr   rK   subsequent_indentr?   r4   s    r   &test_drop_whitespace_whitespace_indentz3WrapTestCase.test_drop_whitespace_whitespace_indent  s&     	Q8(<'+t 	 	Er   c                 f    d}| j                   j                  |      }| j                  |g d       y )Nz0Hello there -- you goof-ball, use the -b option!)Hellorv   thererv   rx   rv   yourv   zgoof-zball,rv   userv   r   rv   z-brv   zoption!)r(   r)   r   )r   r#   r   s      r   
test_splitzWrapTestCase.test_split  s3     B$$T*

6K	Lr   c                 d    d}| j                  |dddgd       | j                  |dddgd	       y )
Nzyaba daba-door   z
yaba daba-dooTbreak_on_hyphensyabazdaba-dooFr?   r@   s     r   test_break_on_hyphensz"WrapTestCase.test_break_on_hyphens  sE    b<"7)- 	 	/b6:"6). 	 	0r   c                 x    d}| j                  t        t        |d       | j                  t        t        |d       y )NzWhatever, it doesn't matter.r   )assertRaises
ValueErrorr   r@   s     r   test_bad_widthzWrapTestCase.test_bad_width  s/    -*dD!4*dD"5r   c                 2    d}| j                  |dg d       y )Nu   Die Empfänger-Auswahl   )Dieu   Empfänger-Auswahlr?   r@   s     r   test_no_split_at_umlautz$WrapTestCase.test_no_split_at_umlaut  s    )b"EFr   c                 2    d}| j                  |dddg       y )Nu   aa ää-ää   u   aa ää-u   äär?   r@   s     r   test_umlaut_followed_by_dashz)WrapTestCase.test_umlaut_followed_by_dash  s    %a.*!=>r   c                 d    d}| j                  |dg dd       | j                  |dg dd       y )Nu,   This is a sentence with non-breaking space.rU   )This is a sentence	with non-u   breaking space.Tr   )r   withu   non-breaking space.Fr?   r@   s     r   test_non_breaking_spacez$WrapTestCase.test_non_breaking_space  sH    Mb= *.	 	 	/ 	bA */	 	 	0r   c                 d    d}| j                  |dg dd       | j                  |dg dd       y )Nu-   This is a sentence with non-breaking space.rU   )r   r   u   breaking space.Tr   )r   r   u   non-breaking space.Fr?   r@   s     r   test_narrow_non_breaking_spacez+WrapTestCase.test_narrow_non_breaking_space  sM    2 	bD *.	 	 	/ 	bH */	 	 	0r   N)!r+   r,   r-   r5   rA   rG   rL   rR   rV   rY   r\   re   rj   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r/   r   r   r1   r1   .   s    -*":
O
5@(/TB/F4G(4'n 'DG"=*)/B-%	M3:E	L06G?00r   r1   c                   (    e Zd ZdZd Zd Zd Zd Zy)MaxLinesTestCaser7   c                    | j                  | j                  ddgd       | j                  | j                  ddgd       | j                  | j                  dddgd       | j                  | j                  d	dd
gd       | j                  | j                  d| j                  gd       | j                  | j                  dg dd       y )Nr8   zHello [...]r   	max_linesr`   r:   z	how [...]   r   zhow are [...]r>   r9   rD   r&   r#   r4   s    r   rA   zMaxLinesTestCase.test_simple  s    		2&"# 	 	% 			2&"# 	 	% 			2'$&"# 	 	% 			2'(*"# 	 	% 			2		{a@		2  #$ 	 	%r   c                     | j                  | j                  dg dd       | j                  | j                  dddgd       | j                  | j                  d	z   dg d
d       y )Nr8   )r:   r;   r<   z
day? [...]rP   r   rD   r   [...]r   z
          r9   r   r4   s    r   test_spaceszMaxLinesTestCase.test_spaces  sx    		2' #$ 	 	% 			1  ""# 	 	%
 			H,b  #$ 	 	%r   c           	      |   | j                  | j                  ddgdd       | j                  | j                  dddgdd       | j                  t              5  t	        | j                  d	d
dd       d d d        | j                  t              5  t	        | j                  d	d
dd       d d d        | j                  | j                  d	ddgdd
dd       | j                  | j                  d	dgddd
d       | j                  | j                  d| j                  gd       y # 1 sw Y   xY w# 1 sw Y   xY w)Nr8   zHello...r`   z...r   placeholderr:   z
how are...r   rp   r   z [truncated]...)rK   r   r   )r   r   r   z    Hello there,z  [truncated]...r   )r   rK   r   r   r>   a  ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................r   )r&   r#   r   r   r   r4   s    r   test_placeholderz!MaxLinesTestCase.test_placeholder  sK   		2#"#$) 	 	+ 			2'%'"#$)	 	 	+ z* 	=Bv*;=	= z* 	=B&*;=	= 			2++-"#'-*.$5 	 	7 			2+,"#'+*0$5 	 	7 			2		{
K'	= 	=	= 	=s   D&D2&D/2D;c                 8    d}| j                  |dddgdd       y )Nz1Good grief Python features are advancing quickly!r8   z
Good griefzPython*****   z*****r   r?   r@   s     r   test_placeholder_backtrackz+MaxLinesTestCase.test_placeholder_backtrack2  s-    
 Cb%}5"#$+ 	 	-r   N)r+   r,   r-   r#   rA   r   r   r   r/   r   r   r   r     s    JD%2%.L@	-r   r   c                   $    e Zd Zd Zd Zd Zd Zy)LongWordTestCasec                 0    t               | _        d| _        y )Nz]Did you say "supercalifragilisticexpialidocious?"
How *do* you spell that odd word, anyways?
)r   r(   r#   r4   s    r   r5   zLongWordTestCase.setUp?  s    "}	r   c                     | j                  | j                  dg d       | j                  | j                  dddg       | j                  ddg dd	
       | j                  | j                  dg d       y )Nr[   )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   r8   )	Did you say "supercalifragilisticexpzialidocious?z
" How *do*z	you spellzthat oddzword,r   r   r4   s    r   test_break_longz LongWordTestCase.test_break_longF  s|     			2%	&
 			2LEG	H 	- -3 	 	4 			2%		&r   c                    d| j                   _        d| j                   _        g d}| j                   j                  | j                        }| j                  ||       t        | j                  dd      }| j                  ||       y )Nr   r[   )zDid you sayz%"supercalifragilisticexpialidocious?"zHow *do* you spell that oddzword, anyways?)r$   rb   )r(   rb   r$   r   r#   r   r   r   r   s      r   test_nobreak_longz"LongWordTestCase.test_nobreak_longj  sk    ()%
 ""499-

66" diirA>

66"r   c                 F    | j                  | j                  dg dd       y )Nr8   )r   r   r   r   rP   r   r   r4   s    r   test_max_lines_longz$LongWordTestCase.test_max_lines_longz  s%    		2" #$ 	 	%r   N)r+   r,   r-   r5   r   r   r   r/   r   r   r   r   >  s    "&H# %r   r   c                   *    e Zd Zd Zd Zd Zd Zd Zy)LongWordWithHyphensTestCasec                 >    t               | _        d| _        d| _        y )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text2r4   s    r   r5   z!LongWordWithHyphensTestCase.setUp  s    "}

r   c                     ddg}| j                  | j                  d|       g d}| j                  | j                  d|       g d}| j                  | j                  d|       y )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-
cyclohexadziene-1-
carboxylate	synthase.r   
1234567890z
-123456789z
0--this_is
_a_very_lo
ng_option_zindeed-z	good-bye"r&   r   r   r   expecteds     r   test_break_long_words_on_hyphenz;LongWordWithHyphensTestCase.test_break_long_words_on_hyphen  sZ    ><>

B1M

B1:

B1r   c                     ddg}| j                  | j                  d|d       g d}| j                  | j                  d|d       g d}| j                  | j                  d|       y )	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-c
arboxylater  r   r  r  r  s     r   #test_break_long_words_not_on_hyphenz?LongWordWithHyphensTestCase.test_break_long_words_not_on_hyphen  sb    H24

B5IK

B5I:

B1r   c                     g d}| j                  | j                  d|d       g d}| j                  | j                  d|d       g d}| j                  | j                  d|       y )NzWe used enyzme52-succinyl-6-hydroxy-2,4-cyclohexadiene-1-carboxylater  r   Fra   r   enyzmer  r  r   r  r  r  s     r   'test_break_on_hyphen_but_not_long_wordszCLongWordWithHyphensTestCase.test_break_on_hyphen_but_not_long_words  s_    ! 	

B5I! 	

B5I:

B1r   c                     g d}| j                  | j                  d|dd       g d}| j                  | j                  d|dd       g d}| j                  | j                  d|       y )Nr  r   F)rb   r   r  r   r  r  r  s     r   *test_do_not_break_long_words_or_on_hyphenszFLongWordWithHyphensTestCase.test_do_not_break_long_words_or_on_hyphens  sq    ! 	

B).). 	 	0! 	

B).). 	 	0:

B1r   N)r+   r,   r-   r5   r	  r  r  r  r/   r   r   r   r     s    222"2r   r   c                   $    e Zd Zd Zd Zd Zd Zy)IndentTestCasesc                     d| _         y )NznThis paragraph will be filled, first without any indentation,
and then with some (including a hanging indent).)r#   r4   s    r   r5   zIndentTestCases.setUp  s    4	r   c                 X    d}t        | j                  d      }| j                  ||       y )NznThis paragraph will be filled, first
without any indentation, and then with
some (including a hanging indent).rX   r   r#   r   r   s      r   	test_fillzIndentTestCases.test_fill  s)    &
 dii$

66"r   c                     g d}t        | j                  dd      }| j                  ||       dj                  |      }t	        | j                  dd      }| j                  ||       y )N)z#     This paragraph will be filled,z'first without any indentation, and thenz'with some (including a hanging indent).rX   r   rJ   r   )r   r#   r   r   r   r   s      r   test_initial_indentz#IndentTestCases.test_initial_indent  sY    = diiG<

66"6"diiG<

66"r   c                 ^    d}t        | j                  ddd      }| j                  ||       y )Nz~  * This paragraph will be filled, first
    without any indentation, and then
    with some (including a hanging
    indent).rX   z  * r   r   r  r   s      r   test_subsequent_indentz&IndentTestCases.test_subsequent_indent  s1     dii%+vG

66"r   N)r+   r,   r-   r5   r  r  r  r/   r   r   r  r    s    4	###r   r  c                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	DedentTestCasec                 :    | j                  |t        |             y)z,assert that dedent() has no effect on 'text'Nr   r   r@   s     r   assertUnchangedzDedentTestCase.assertUnchanged   s    vd|,r   c                     d}| j                  |       d}| j                  |       d}| j                  |       d}| j                  |       y )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@   s     r   test_dedent_nomarginz#DedentTestCase.test_dedent_nomargin  sT    ?T" &T" 3T" *T"r   c                     d}d}| j                  |t        |             d}d}| j                  |t        |             d}d}| j                  |t        |             y )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"  rd   s      r   test_dedent_evenzDedentTestCase.test_dedent_even  sa    :6. ?:. A:.r   c                     d}d}| j                  |t        |             d}d}| j                  |t        |             d}d}| j                  |t        |             y )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"  rd   s      r   test_dedent_unevenz!DedentTestCase.test_dedent_uneven%  sf    

 	. ,'. -'.r   c                     d}d}| j                  |t        |             d}d}| j                  |t        |             d}d}| j                  |t        |             y )Nz     Foo
    Bar
z	 Foo
Bar
z     Foo

    Bar
z
 Foo

Bar
z     Foo
    
    Bar
r"  rd   s      r   test_dedent_decliningz$DedentTestCase.test_dedent_declining=  s`    $. ' . + .r   c                 x    d}d}| j                  |t        |             | j                  |t        |             y )Nz  hello	there
  how are	you?zhello	there
how are	you?r"  rd   s      r   "test_dedent_preserve_internal_tabsz1DedentTestCase.test_dedent_preserve_internal_tabsN  s6    0.. 	0r   c                 ~   d}| j                  |       d}| j                  |       d}d}| j                  |t        |             d}| j                  |t        |             d}| j                  |t        |             d}d}| j                  |t        |             d	}d
}| j                  |t        |             y )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   rd   s      r    test_dedent_preserve_margin_tabsz/DedentTestCase.test_dedent_preserve_margin_tabsZ  s    .T" 5T" /,.2.6.4.. IG.r   N)
r+   r,   r-   r#  r%  r'  r)  r+  r-  r/  r/   r   r   r   r     s%    -#"/ /0/"1/r   r   c                   \    e Zd ZdZedz   Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zy)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                 ^    | j                   D ]  }| j                  t        |d      |         y NrC   CASESr   r   r@   s     r   test_indent_nomargin_defaultz+IndentTestCase.test_indent_nomargin_default  s,    JJ 	5DVD"-t4	5r   c                 `    | j                   D ]  }| j                  t        |dd       |       ! y r5  r6  r@   s     r   %test_indent_nomargin_explicit_defaultz4IndentTestCase.test_indent_nomargin_explicit_default  s0     JJ 	;DVD"d3T:	;r   c                 f    d }| j                   D ]  }| j                  t        |d|      |       ! y )Nc                      yNTr/   lines    r   <lambda>z?IndentTestCase.test_indent_nomargin_all_lines.<locals>.<lambda>      r   rC   r6  r   	predicater#   s      r   test_indent_nomargin_all_linesz-IndentTestCase.test_indent_nomargin_all_lines  s7     &	JJ 	@DVD"i8$?	@r   c                 f    d }| j                   D ]  }| j                  t        |d|      |       ! y )Nc                      y)NFr/   r>  s    r   r@  z5IndentTestCase.test_indent_no_lines.<locals>.<lambda>  rA  r   r   r6  rB  s      r   test_indent_no_linesz#IndentTestCase.test_indent_no_lines  s5    &	JJ 	DDVD&)<dC	Dr   c           	      p    | j                   D ]'  }| j                  t        t        |d            |       ) y )Nr   ROUNDTRIP_CASESr   r   r   r@   s     r   test_roundtrip_spacesz$IndentTestCase.test_roundtrip_spaces  5    (( 	ADVF4$894@	Ar   c           	      p    | j                   D ]'  }| j                  t        t        |d            |       ) y )Nz		rI  r@   s     r   test_roundtrip_tabsz"IndentTestCase.test_roundtrip_tabs  rL  r   c           	      p    | j                   D ]'  }| j                  t        t        |d            |       ) y )Nz 	  	 rI  r@   s     r   test_roundtrip_mixedz#IndentTestCase.test_roundtrip_mixed  s5    (( 	EDVF4$<=tD	Er   c                     d}d}t        | j                  |      D ]!  \  }}| j                  t        ||      |       # y 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.

zipr7  r   r   r   prefixr  r#   r   s        r   test_indent_defaultz"IndentTestCase.test_indent_default  sE    
  

H5 	;LD&VD&16:	;r   c                     d}d}t        | j                  |      D ]"  \  }}| j                  t        ||d       |       $ y rR  rU  rW  s        r   test_indent_explicit_defaultz+IndentTestCase.test_indent_explicit_default  sI    
  

H5 	ALD&VD&$7@	Ar   c                     d}d}d }t        | j                  |      D ]"  \  }}| j                  t        |||      |       $ y )Nr   )rS  z%  Hi.
  This is a test.
  
  Testing.z&  
  Hi.
  This is a test.
  Testing.
rT  z/  
  Hi.
  This is a test.
  
  Testing.
  
c                      yr=  r/   r>  s    r   r@  z6IndentTestCase.test_indent_all_lines.<locals>.<lambda>  rA  r   rU  r   rX  r  rC  r#   r   s         r   test_indent_all_linesz$IndentTestCase.test_indent_all_lines  sN    
 &	

H5 	FLD&VD&)<fE	Fr   c                     d}d}d }t        | j                  |      D ]"  \  }}| j                  t        |||      |       $ y )Nr   )r2  zHi.
This is a test.
  
Testing.z   
Hi.
This is a test.
Testing.
r3  z)  
Hi.
This is a test.
  
Testing.
  
c                 $    | j                          S r!   )stripr>  s    r   r@  z8IndentTestCase.test_indent_empty_lines.<locals>.<lambda>  s    TZZ\!1 r   rU  r^  s         r   test_indent_empty_linesz&IndentTestCase.test_indent_empty_lines  sN    
 2	

H5 	FLD&VD&)<fE	Fr   N)r+   r,   r-   rJ  r7  r8  r:  rD  rG  rK  rN  rP  rY  r[  r_  rc  r/   r   r   r1  r1  x  sY    
O   E5
;@DA
A
E
;$A$F&Fr   r1  c                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	ShortenTestCasec                 B    t        ||fi |}| j                  ||       y r!   )r   r   r"   s         r   check_shortenzShortenTestCase.check_shorten   s!    u//

66"r   c                     d}| j                  |dd       | j                  |t        |      |       | j                  |t        |      dz
  d       y )N<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 [...]rg  r   r@   s     r   rA   zShortenTestCase.test_simple  sO    M4%9:4TD14TQ 	!r   c                    d}| j                  |ddd       | j                  |ddd       | j                  |ddd	       | j                  |t        |      |d       | j                  |t        |      d
z
  dd       y )Nri  rr   zHello there,$$z$$r   rj  zHello there, how$$zHello there, $$z $$r`   z:Hello there, how are you this fine day? I'm glad to hear$$rk  r@   s     r   r   z ShortenTestCase.test_placeholder  s    M4%54H4%9tL4%6EJ4TDdC4TQ!.2 	 	4r   c                 *    | j                  ddd       y )NrC   rD   rg  r4   s    r   rG   z!ShortenTestCase.test_empty_string  s    2q"%r   c                     d}| j                  |dd       | j                  |dd       | j                  ddd       | j                  dd	d
       | j                  ddd       y )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!  r8   zhello world!   zhello [...]r   r   rn  r@   s     r   rR   zShortenTestCase.test_whitespace  sx    , 	44	5 	40	1 	0"nE0"mD 	0"g>r   c                     t        ddd       | j                  t              5  t        ddd       d d d        y # 1 sw Y   y xY w)Nxxxxxxxxxxxxxxxxxxxx   z(......))r$   r   z	(.......))r   r   r   r4   s    r   $test_width_too_small_for_placeholderz4ShortenTestCase.test_width_too_small_for_placeholder.  sA    z:z* 	@HA;?	@ 	@ 	@s	   <Ac                 *    | j                  ddd       y )NHelloo   r   rn  r4   s    r   -test_first_word_too_long_but_placeholder_fitsz=ShortenTestCase.test_first_word_too_long_but_placeholder_fits3  s    8Q0r   N)
r+   r,   r-   rg  rA   r   rG   rR   rv  rz  r/   r   r   re  re    s&    #!	4&?$@
1r   re  __main__)unittesttextwrapr   r   r   r   r   r   TestCaser
   r1   r   r   r   r  r   r1  re  r+   mainr/   r   r   <module>r     s     E E;8$$ ;<n0< n0b\-| \-~B% B%JF2, F2P.#l .#fv/X&& v/tCFX&& CFL61l 61r zHMMO r   