
    <e                     v   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                     dS dS )    N)TextWrapperwrapfilldedentindentshortenc                   *    e Zd ZdZd Zd Zd Zd ZdS )BaseTestCasez5Parent class with utility methods for textwrap tests.c                 4   t          |t                    r[g }t          t          |                    D ]"}|                    d|||         fz             #|rd                    |          nd}n'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       )/usr/lib/python3.11/test/test_textwrap.pyshowzBaseTestCase.show   s    fd## 	-F3v;;'' ; ;jAvay>9::::*0BTYYv&&&lFF$$ 	-V,F    c           
          |                      ||d|                     |          d|                     |                     d S )Nz
expected:
z

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

66"""""r   c                 t    | j                             |          }|                     ||d|d|           d S )Nz

expected z

but got  )wrapper_splitr   )r   r#   r   r   s       r   check_splitzBaseTestCase.check_split'   sO    $$T***0&&&&:	; 	; 	; 	; 	;r   N)__name__
__module____qualname____doc__r   r   r&   r*    r   r   r
   r
      sV        ??  7 7 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 dS ) WrapTestCasec                 0    t          d          | _        d S )N-   )r$   )r   r(   r   s    r   setUpzWrapTestCase.setUp0   s    ",,,r   c                     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#   s     r   test_simplezWrapTestCase.test_simple3   sz     Ob     	! 	! 	! 	bB/1	2 	2 	2 	b4&)))))r   c                 f    |                      ddg            |                      ddg d           d S )N    Fdrop_whitespacer?   r4   s    r   test_empty_stringzWrapTestCase.test_empty_stringD   s8    Ar"""Ar599999r   c                 l    |                      ddg d           |                      ddg dd           d S )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77Ar$NNNNNr   c                 z   d}g d}t          dd          }|                    |          }|                     ||           |                    |          }|                     |d                    |                     d}dg}|                     |d	|           d
}dg}|                     |d	|d           d S )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&!44444r   c                    t          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<   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DD

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

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

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

7<<%%v.....r   c                 l    d}|                      |dddg           |                      |ddg           d S )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   sN     -b#4#/#1 	2 	2 	2b#?"@AAAAAr   c                 n    d}|                      |ddg           |                      |ddgd           d S )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   sU     'b#:";<<<b#>"?'- 	 	/ 	/ 	/ 	/ 	/r   c                    d}|                      |dddg           |                      |dddg           |                      |dddg           d	                    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'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 	C 	C 	b8@B	C 	C 	C 	bE35	6 	6 	6>?DuSzz 	a%@@@v&&&H:...YK000)9)?)?)D)DEEEEEr   c                    d}|                      |dg d           |                      |dddg           |                      |d|                                d	           d
}|                      |dddg           |                      |dddg           |                      |dd
g           |                      |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.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 	P 	PaFFF.b#<#*#, 	- 	- 	-b#<#*#, 	- 	- 	-b#B"CDDDaFFFFFr   c                    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.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   s   5b.+-	. 	. 	. 	b6#%	& 	& 	& 3b&)))b&)))b?@	B 	B 	B
 7   	b&)))b&)))   	b&)))b&)))1b&)))b&)))4b&)))b&))) I* * * 	v&&&,1 1 1v&&&&&r   c                     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.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  sU    Nb" " "	# 	# 	#
 	b. . .	/ 	/ 	/ 5/1b&)))b&)))b&)))b&)));)+b&)))b&)))>%'b&))) 9? ? ?v&&&&&r   c                 R   |                      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!)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+M+MNNN'='='=>>>(?(?(?@@@{m444 	j\222+u)=>>>/EEE	G 	G 	G 	G 	Gr   c                    |                      dg d           |                      dg d           |                      dg d           |                      dg d           |                      d	d
                    d                     d S )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  s     	5KKK	M 	M 	M5KKK	M 	M 	M5KKK	M 	M 	M7MMM	O 	O 	O 	.066s;;	= 	= 	= 	= 	=r   c                     |                      dg d           |                      dg d           |                      dg d           d S )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  s     	-???	A 	A 	A 	:::	< 	< 	<2( ( (	) 	) 	) 	) 	)r   c                 @    d}|                      |dg dd           d S )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  sE     Bb> > >(- 	 	/ 	/ 	/ 	/ 	/r   c                 :    |                      dddgd           d S )N   rD   FrE   r?   r4   s    r   *test_drop_whitespace_false_whitespace_onlyz7WrapTestCase.test_drop_whitespace_false_whitespace_onlyo  s$    q5'5AAAAAr   c                 <    |                      dddgdd           d S )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  s6     	q7)U'+ 	 	- 	- 	- 	- 	-r   c                 4    |                      ddg            d S )Nr   rD   r?   r4   s    r   $test_drop_whitespace_whitespace_onlyz1WrapTestCase.test_drop_whitespace_whitespace_onlyy  s    a$$$$$r   c                 l    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@   s     r   'test_drop_whitespace_leading_whitespacez4WrapTestCase.test_drop_whitespace_leading_whitespace}  s^    
 >bGH	J 	J 	Jb35JK	M 	M 	M 	M 	Mr   c                 r    d}|                      |dg dd           |                      |dddg           d S )Nzabcd    efghrD   )abcdr   efghFrE   r   r   r?   r@   s     r   $test_drop_whitespace_whitespace_linez1WrapTestCase.test_drop_whitespace_whitespace_line  sU     a!9!9!9(- 	 	/ 	/ 	/a&&!122222r   c                 8    |                      ddg d           d S )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99999r   c                 >    |                      ddddgdd           d S )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 	E 	E 	E 	Er   c                 n    d}| j                             |          }|                     |g d           d S )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  sX     B$$T**

6K K K	L 	L 	L 	L 	Lr   c                 v    d}|                      |dddgd           |                      |dddgd	           d S )
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  sc    b<"7)- 	 	/ 	/ 	/b6:"6). 	 	0 	0 	0 	0 	0r   c                     d}|                      t          t          |d           |                      t          t          |d           d S )NzWhatever, it doesn't matter.r   )assertRaises
ValueErrorr   r@   s     r   test_bad_widthzWrapTestCase.test_bad_width  sA    -*dD!444*dD"55555r   c                 <    d}|                      |dg d           d S )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"E"EFFFFFr   c                 <    d}|                      |dddg           d S )Nu   aa ää-ää   u   aa ää-u   äär?   r@   s     r   test_umlaut_followed_by_dashz)WrapTestCase.test_umlaut_followed_by_dash  s(    %a.*!=>>>>>r   c                 v    d}|                      |dg dd           |                      |dg dd           d S )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  s|    Mb= = = *.	 	 	/ 	/ 	/ 	bA A A */	 	 	0 	0 	0 	0 	0r   c                 v    d}|                      |dg dd           |                      |dg dd           d S )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  s    2 	bD D D *.	 	 	/ 	/ 	/ 	bH H H */	 	 	0 	0 	0 	0 	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 O O
5 5 5@(/ (/ (/TB B B/ / /F F F4G G G(4' 4' 4'n '  '  'DG G G"= = =*) ) )/ / /B B B- - -% % %	M 	M 	M3 3 3: : :E E E	L 	L 	L0 0 06 6 6G G G? ? ?0 0 00 0 0 0 0r   r1   c                   *    e Zd ZdZd Zd Zd Zd ZdS )MaxLinesTestCaser7   c                    |                      | j        ddgd           |                      | j        ddgd           |                      | j        dddgd           |                      | j        d	dd
gd           |                      | j        d| j        gd           |                      | j        dg dd           d S )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        dg dd           |                      | j        dddgd           |                      | j        d	z   dg d
d           d S )Nr8   )r:   r;   r<   z
day? [...]rP   r   rD   r   [...]r   z
          r9   r   r4   s    r   test_spaceszMaxLinesTestCase.test_spaces  s    	2' ' ' #$ 	 	% 	% 	% 		1  ""# 	 	% 	% 	%
 		H,b      #$ 	 	% 	% 	% 	% 	%r   c           	         |                      | j        ddgdd           |                      | j        dddgdd           |                     t                    5  t	          | j        d	d
dd           d d d            n# 1 swxY w Y   |                     t                    5  t	          | j        d	d
dd           d d d            n# 1 swxY w Y   |                      | j        d	ddgdd
dd           |                      | j        d	dgddd
d           |                      | j        d| j        gd           d S )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  s   	2#"#$) 	 	+ 	+ 	+ 		2'%'"#$)	 	 	+ 	+ 	+ z** 	= 	=Bv*;= = = =	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= z** 	= 	=B&*;= = = =	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 		2++-"#'-*.$5 	 	7 	7 	7 		2+,"#'+*0$5 	 	7 	7 	7 		2	{
KKKKKs$   BB	B'CCCc                 B    d}|                      |dddgdd           d S )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  sA    
 Cb%}5"#$+ 	 	- 	- 	- 	- 	-r   N)r+   r,   r-   r#   rA   r   r   r   r/   r   r   r   r     sY        JD% % %2% % %.L L L@	- 	- 	- 	- 	-r   r   c                   &    e Zd Zd Zd Zd Zd ZdS )LongWordTestCasec                 :    t                      | _        d| _        d S )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        dg d           |                      | j        dddg           |                      ddg dd	
           |                      | j        dg d           d S )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 	H 	H 	- - - -3 	 	4 	4 	4 		2% % %		& 		& 		& 		& 		&r   c                    d| j         _        d| j         _        g d}| j                             | j                  }|                     ||           t          | j        dd          }|                     ||           d S )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  s    ()%  
 ""49--

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

66"""""r   c                 F    |                      | j        dg dd           d S )Nr8   )r   r   r   r   rP   r   r   r4   s    r   test_max_lines_longz$LongWordTestCase.test_max_lines_longz  sA    	2" " " #$ 	 	% 	% 	% 	% 	%r   N)r+   r,   r-   r5   r   r   r   r/   r   r   r   r   >  sQ          "& "& "&H# # # % % % % %r   r   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )LongWordWithHyphensTestCasec                 H    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text2r4   s    r   r5   z!LongWordWithHyphensTestCase.setUp  s#    "}}



r   c                     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-
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  s    ><>
B111M M M
B111: : :
B11111r   c                     ddg}|                      | j        d|d           g d}|                      | j        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-c
arboxylater  r   r  r  r  s     r   #test_break_long_words_not_on_hyphenz?LongWordWithHyphensTestCase.test_break_long_words_not_on_hyphen  s    H24
B5IIIK K K
B5III: : :
B11111r   c                     g d}|                      | j        d|d           g d}|                      | j        d|d           g d}|                      | j        d|           d S )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II! ! ! 	
B5III: : :
B11111r   c                     g d}|                      | j        d|dd           g d}|                      | j        d|dd           g d}|                      | j        d|           d S )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  s    ! ! ! 	
B).). 	 	0 	0 	0! ! ! 	
B).). 	 	0 	0 	0: : :
B11111r   N)r+   r,   r-   r5   r	  r  r  r  r/   r   r   r   r     s_          2 2 22 2 22 2 2"2 2 2 2 2r   r   c                   &    e Zd Zd Zd Zd Zd ZdS )IndentTestCasesc                     d| _         d S )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                 `    d}t          | j        d          }|                     ||           d S )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  s6    &
 di$$

66"""""r   c                     g d}t          | j        dd          }|                     ||           d                    |          }t	          | j        dd          }|                     ||           d S )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  s    = = = diG<<<

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

66"""""r   c                 f    d}t          | j        ddd          }|                     ||           d S )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  sG     di%+vG G G

66"""""r   N)r+   r,   r-   r5   r  r  r  r/   r   r   r  r    sP        4 4 4	# 	# 	## # ## # # # #r   r  c                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	DedentTestCasec                 L    |                      |t          |                     dS )z,assert that dedent() has no effect on 'text'Nr   r   r@   s     r   assertUnchangedzDedentTestCase.assertUnchanged   s$    vd||,,,,,r   c                     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@   s     r   test_dedent_nomarginz#DedentTestCase.test_dedent_nomargin  sr    ?T""" &T""" 3T""" *T"""""r   c                     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"  rd   s      r   test_dedent_evenzDedentTestCase.test_dedent_even  s    :6... ?:... A:.....r   c                     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"  rd   s      r   test_dedent_unevenz!DedentTestCase.test_dedent_uneven%  s    

 	... ,'... -'.....r   c                     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"  rd   s      r   test_dedent_decliningz$DedentTestCase.test_dedent_declining=  s~    $... ' ... + .....r   c                     d}d}|                      |t          |                     |                      |t          |                     d S )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  sL    0.... 	00000r   c                    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   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 1 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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                 b    | j         D ]&}|                     t          |d          |           'd S NrC   CASESr   r   r@   s     r   test_indent_nomargin_defaultz+IndentTestCase.test_indent_nomargin_default  s@    J 	5 	5DVD"--t4444	5 	5r   c                 d    | j         D ]'}|                     t          |dd           |           (d S r5  r6  r@   s     r   %test_indent_nomargin_explicit_defaultz4IndentTestCase.test_indent_nomargin_explicit_default  sD     J 	; 	;DVD"d33T::::	; 	;r   c                 j    d }| j         D ]'}|                     t          |d|          |           (d S )Nc                     dS 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  sP     &%	J 	@ 	@DVD"i88$????	@ 	@r   c                 j    d }| j         D ]'}|                     t          |d|          |           (d S )Nc                     dS )NFr/   r>  s    r   r@  z5IndentTestCase.test_indent_no_lines.<locals>.<lambda>  s     r   r   r6  rB  s      r   test_indent_no_linesz#IndentTestCase.test_indent_no_lines  sN    &&	J 	D 	DDVD&)<<dCCCC	D 	Dr   c           	      |    | j         D ]3}|                     t          t          |d                    |           4d S )Nr   ROUNDTRIP_CASESr   r   r   r@   s     r   test_roundtrip_spacesz$IndentTestCase.test_roundtrip_spaces  M    ( 	A 	ADVF4$8$8994@@@@	A 	Ar   c           	      |    | j         D ]3}|                     t          t          |d                    |           4d S )Nz		rI  r@   s     r   test_roundtrip_tabsz"IndentTestCase.test_roundtrip_tabs  rL  r   c           	      |    | j         D ]3}|                     t          t          |d                    |           4d S )Nz 	  	 rI  r@   s     r   test_roundtrip_mixedz#IndentTestCase.test_roundtrip_mixed  sM    ( 	E 	EDVF4$<$<==tDDDD	E 	Er   c                     d}d}t          | j        |          D ])\  }}|                     t          ||          |           *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.

zipr7  r   r   r   prefixr  r#   r   s        r   test_indent_defaultz"IndentTestCase.test_indent_default  s\    
  
H55 	; 	;LD&VD&116::::	; 	;r   c                     d}d}t          | j        |          D ]*\  }}|                     t          ||d           |           +d S rR  rU  rW  s        r   test_indent_explicit_defaultz+IndentTestCase.test_indent_explicit_default  sb    
  
H55 	A 	ALD&VD&$77@@@@	A 	Ar   c                     d}d}d }t          | j        |          D ]*\  }}|                     t          |||          |           +d S )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                     dS 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  sj    
 &%	
H55 	F 	FLD&VD&)<<fEEEE	F 	Fr   c                     d}d}d }t          | j        |          D ]*\  }}|                     t          |||          |           +d S )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                 ,    |                                   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  sj    
 21	
H55 	F 	FLD&VD&)<<fEEEE	F 	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  s        
O   E5 5 5
; ; ;@ @ @D D DA A A
A A A
E E E
; ; ;$A A A$F F F&F F F F Fr   r1  c                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	ShortenTestCasec                 N    t          ||fi |}|                     ||           d S r!   )r   r   r"   s         r   check_shortenzShortenTestCase.check_shorten   s3    u////

66"""""r   c                     d}|                      |dd           |                      |t          |          |           |                      |t          |          dz
  d           d S )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  ss    M4%9:::4TD1114TQ 	! 	! 	! 	! 	!r   c                 >   d}|                      |ddd           |                      |ddd           |                      |ddd	           |                      |t          |          |d           |                      |t          |          d
z
  dd           d S )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HH4%9tLLL4%6EJJJ4TDdCCC4TQ!.2 	 	4 	4 	4 	4 	4r   c                 4    |                      ddd           d S )NrC   rD   rg  r4   s    r   rG   z!ShortenTestCase.test_empty_string  s     2q"%%%%%r   c                     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!  r8   zhello world!   zhello [...]r   r   rn  r@   s     r   rR   zShortenTestCase.test_whitespace  s    , 	44	5 	5 	5 	40	1 	1 	1 	0"nEEE0"mDDD 	0"g>>>>>r   c                     t          ddd           |                     t                    5  t          ddd           d d d            d S # 1 swxY w Y   d S )Nxxxxxxxxxxxxxxxxxxxx   z(......))r$   r   z	(.......))r   r   r   r4   s    r   $test_width_too_small_for_placeholderz4ShortenTestCase.test_width_too_small_for_placeholder.  s    z::::z** 	@ 	@HA;????	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@ 	@s   AAAc                 4    |                      ddd           d S )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00000r   N)
r+   r,   r-   rg  rA   r   rG   rR   rv  rz  r/   r   r   re  re    s        # # #! ! !	4 	4 	4& & &? ? ?$@ @ @
1 1 1 1 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 E E E E E E E E E E E E E E; ; ; ; ;8$ ; ; ;<n0 n0 n0 n0 n0< n0 n0 n0b\- \- \- \- \-| \- \- \-~B% B% B% B% B% B% B% B%JF2 F2 F2 F2 F2, F2 F2 F2P.# .# .# .# .#l .# .# .#fv/ v/ v/ v/ v/X& v/ v/ v/tCF CF CF CF CFX& CF CF CFL61 61 61 61 61l 61 61 61r zHMOOOOO r   