mò
­fIc           @   sÎ   d  k  Z  d k l Z d k l Z l Z l Z l Z d e  i f d „  ƒ  YZ	 d e	 f d „  ƒ  YZ
 d e	 f d „  ƒ  YZ d	 e	 f d
 „  ƒ  YZ d e  i f d „  ƒ  YZ d „  Z e d j o e ƒ  n d  S(   N(   s   test_support(   s   TextWrappers   wraps   fills   dedentt   BaseTestCasec           B   s2   t  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s5   Parent class with utility methods for textwrap tests.c         C   s‰   t  | t ƒ oQ g  } x5 t t | ƒ ƒ D]! } | i d | | | f ƒ q) Wd i | ƒ } n% t  | t	 ƒ o d t
 | ƒ } n | S(   Ns     %d: %rs   
s     %s
(   t
   isinstancet   textint   listt   resultt   ranget   lent   it   appendt   joint
   basestringt   repr(   t   selfR   R   R   (    (    t/   /mit/python/lib/python2.4/test/test_textwrap.pyt   show   s     c         C   s3   |  i | | d |  i | ƒ |  i | ƒ f ƒ d  S(   Ns   expected:
%s
but got:
%s(   R   t   assertEqualsR   t   expectR   (   R   R   R   (    (    R   t   check   s    c         K   s&   t  | | |  } |  i | | ƒ d  S(   N(   t   wrapt   textt   widtht   kwargsR   R   R   R   (   R   R   R   R   R   R   (    (    R   t
   check_wrap$   s    c         C   s3   |  i i | ƒ } |  i | | d | | f ƒ d  S(   Ns   
expected %r
but got  %r(   R   t   wrappert   _splitR   R   R   R   (   R   R   R   R   (    (    R   t   check_split(   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   (    (    (    R   R       s
    			t   WrapTestCasec           B   s¡   t  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 RS(   Nc         C   s   t  d d ƒ |  _ d  S(   NR   i-   (   t   TextWrapperR   R   (   R   (    (    R   t   setUp1   s    c      	   C   s^   d } |  i | d d d d d d d g ƒ |  i | d	 d
 d g ƒ |  i | d | g ƒ d  S(   Ns=   Hello there, how are you this fine day?  I'm glad to hear it!i   s   Hello there,s   how are yous	   this fines	   day?  I'ms   glad to hears   it!i*   s'   Hello there, how are you this fine day?s   I'm glad to hear it!iP   (   R   R   R   (   R   R   (    (    R   t   test_simple4   s    c         C   sx   d } d d d d d g } t d d t ƒ} | i | ƒ } |  i | | ƒ | i	 | ƒ } |  i | d	 i
 | ƒ ƒ d  S(
   Ns®   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!
s)   This is a paragraph that already has lines'   breaks.  But some of its lines are muchs)   longer than the others, so it needs to bes-   wrapped.  Some lines are  tabbed too.  What as   mess!i-   t   fix_sentence_endingss   
(   R   R   R   t   TrueR   R   R   R   R   t   fillR	   (   R   R   R   R   R   (    (    R   t   test_whitespaceF   s    c         C   s7  t  d d t ƒ} d } d g } |  i | i | ƒ | ƒ d } d g } |  i | i | ƒ | ƒ d } |  i | i | ƒ | ƒ d } d	 g } |  i | i | ƒ | ƒ d
 | _ d d d g } |  i | i | ƒ | ƒ d } d d d g } |  i | i | ƒ | ƒ d | _ d g } |  i | i | ƒ | ƒ d  S(   Ni<   R!   s$   A short line. Note the single space.s%   A short line.  Note the single space.s    Well, Doctor? What do you think?s!   Well, Doctor?  What do you think?s    Well, Doctor?
What do you think?s)   I say, chaps! Anyone for "tennis?"
Hmmph!s+   I say, chaps!  Anyone for "tennis?"  Hmmph!i   s   I say, chaps!s   Anyone for "tennis?"s   Hmmph!s1   And she said, "Go to hell!"
Can you believe that?s   And she said, "Go tos   hell!"  Can yous   believe that?s2   And she said, "Go to hell!"  Can you believe that?(	   R   R"   R   R   R   R   R   R   R   (   R   R   R   R   (    (    R   t   test_fix_sentence_endings^   s*    						c         C   s9   d } |  i | d d d g ƒ |  i | d d g ƒ d  S(   Ns   This is a
short paragraph.i   s   This is a shorts
   paragraph.i(   s   This is a short paragraph.(   R   R   R   (   R   R   (    (    R   t   test_wrap_short„   s    c         C   s<   d } |  i | d d g ƒ |  i | d d g d d ƒd  S(   Ns   This is a short line.i   s   (1) This is a short line.t   initial_indents   (1) (   R   R   R   (   R   R   (    (    R   t   test_wrap_short_1lineŽ   s    c         C   sU   d } |  i | d d d g ƒ |  i | d d d g ƒ |  i | d d d g ƒ d  S(	   NsB   this-is-a-useful-feature-for-reformatting-posts-from-tim-peters'lyi(   s   this-is-a-useful-feature-for-s%   reformatting-posts-from-tim-peters'lyi)   i*   s*   this-is-a-useful-feature-for-reformatting-s   posts-from-tim-peters'ly(   R   R   R   (   R   R   (    (    R   t   test_hyphenated˜   s    c         C   s   d } |  i | d d d d g ƒ |  i | d d d g ƒ d	 } |  i | d
 d d g ƒ |  i | d d d g ƒ |  i | d d	 g ƒ d  S(   NsR   Python 1.0.0 was released on 1994-01-26.  Python 1.0.1 was
released on 1994-02-15.i   s   Python 1.0.0 was released ons   1994-01-26.  Python 1.0.1 wass   released on 1994-02-15.i(   s(   Python 1.0.0 was released on 1994-01-26.s(   Python 1.0.1 was released on 1994-02-15.s   I do all my shopping at 7-11.i   s   I do all my shopping ats   7-11.i   i   (   R   R   R   (   R   R   (    (    R   t   test_hyphenated_numbers¨   s    c         C   sç  d } |  i | d d d g ƒ |  i | d d d g ƒ d d	 g } |  i | d
 | ƒ |  i | d | ƒ |  i | d d g ƒ d } d d d g } |  i | d | ƒ |  i | d | ƒ d d d g } |  i | d | ƒ |  i | d | ƒ d d g } |  i | d | ƒ |  i | d | ƒ d d g } |  i | d | ƒ |  i | d | ƒ d } d d d d d  d d! d" d d# d  d$ d d% d& d# d d' g } |  i | | ƒ d( } d# d d) d  d* d  d+ d d, d d- g } |  i | | ƒ d  S(.   Ns$   Em-dashes should be written -- thus.i   s   Em-dashes should bes   written -- thus.i   s   Em-dashes should be writtens   -- thus.s   Em-dashes should be written --s   thus.i   i#   i$   s%   You can also do--this or even---this.s   You can also dos   --this or evens   ---this.i   i   s   You can also do--s   this or even---s   this.i   i   s   You can also do--this or eveni   s    You can also do--this or even---i    s7   Here's an -- em-dash and--here's another---and another!s   Here'st    t   ans   --s   em-t   dasht   ands   here'st   anothers   ---s   another!s   and then--bam!--he was gonet   thens   bam!t   het   wast   gone(   R   R   R   R   R   (   R   R   R   (    (    R   t   test_em_dashº   s:    
<'c         C   s4  d } |  i | d d d d d g ƒ |  i | d d d	 d
 g ƒ d d g } |  i | d | ƒ |  i | d | ƒ |  i | d | ƒ |  i | d | ƒ d d g } |  i | d | ƒ |  i | d | ƒ d d
 g } |  i | d | ƒ d } d d d d d d d d d d d d d d g } |  i | | ƒ d  S(    Ns<   You should use the -n option, or --dry-run in its long form.i   s   You should use thes   -n option, or --dry-s   run in its longs   form.i   s   You should use the -ns   option, or --dry-runs   in its long form.s    You should use the -n option, ors   --dry-run in its long form.i    i"   i#   i&   s'   You should use the -n option, or --dry-s   run in its long form.i'   i)   s*   You should use the -n option, or --dry-runi*   s'   the -n option, or --dry-run or --dryrunt   theR+   s   -ns   option,t   ors   --dry-t   runs   --dryrun(   R   R   R   R   R   (   R   R   R   (    (    R   t   test_unix_optionsñ   s$    0c         C   s³   |  i d d d d d d g ƒ |  i d d d d g ƒ |  i d	 d d d
 g ƒ |  i d d g ƒ |  i d d g ƒ |  i d d d g ƒ |  i d d d d d d d g ƒ d  S(   Ns   what the--hey!t   whatR+   R5   s   --s   hey!s
   what the--s   the--s   what the--.s   the--.s	   --text--.s   --options   --option-opts	   --option-t   opts   foo --option-opt bart   foot   bar(   R   R   (   R   (    (    R   t   test_funky_hyphens  s    	c         C   sŒ   |  i d d d d d d d g ƒ |  i d d d d d	 d d g ƒ |  i d
 d d d d d d g ƒ |  i d d d d d d d g ƒ d  S(   Ns   the 'wibble-wobble' widgetR5   R+   s   'wibble-s   wobble't   widgets   the "wibble-wobble" widgets   "wibble-s   wobble"s   the (wibble-wobble) widgets   (wibble-s   wobble)s   the ['wibble-wobble'] widgets	   ['wibble-s   wobble'](   R   R   (   R   (    (    R   t   test_punct_hyphens$  s    				c      	   C   sg   |  i d d d d d d g ƒ |  i d d d d d d g ƒ |  i d	 d
 d d d d d d g ƒ d  S(   Ns   foo (--option) barR;   R+   s
   (--option)R<   s   foo (bar) bazs   (bar)t   bazs   blah (ding dong), wubbat   blahs   (dings   dong),t   wubba(   R   R   (   R   (    (    R   t   test_funky_parens5  s    			c         C   s9   d } |  i | d d g ƒ |  i | d d d g ƒ d  S(   Ns,    This is a sentence with leading whitespace.i2   i   s    This is a sentence withs   leading whitespace.(   R   R   R   (   R   R   (    (    R   t   test_initial_whitespaceB  s
    
c         C   s]   d } |  i | d d g ƒ |  i | d d d g ƒ |  i i | ƒ } |  i i | ƒ } d  S(   Nu   Hello there, how are you today?i2   i   u   Hello there, how ares
   you today?(   R   R   R   R   R   t   olinesR#   t   otext(   R   R   RE   RF   (    (    R   t   test_unicodeK  s     c         C   sb   d } |  i i | ƒ } |  i | d d d d d d d d d d d d	 d d
 d d d d g ƒ d  S(   Ns0   Hello there -- you goof-ball, use the -b option!t   HelloR+   t   theres   --t   yous   goof-s   ball,t   useR5   s   -bs   option!(   R   R   R   R   R   R   (   R   R   R   (    (    R   t
   test_splitW  s    	c         C   s6   d } |  i t t | d ƒ |  i t t | d ƒ d  S(   Ns   Whatever, it doesn't matter.i    iÿÿÿÿ(   R   R   t   assertRaisest
   ValueErrorR   (   R   R   (    (    R   t   test_bad_widthb  s    (   R   R   R   R    R$   R%   R&   R(   R)   R*   R4   R8   R=   R?   RC   RD   RG   RL   RO   (    (    (    R   R   /   s"   				&	
	
			7	"							t   LongWordTestCasec           B   s#   t  Z d „  Z d „  Z d „  Z RS(   Nc         C   s   t  ƒ  |  _ d |  _ d  S(   Ns]   Did you say "supercalifragilisticexpialidocious?"
How *do* you spell that odd word, anyways?
(   R   R   R   R   (   R   (    (    R   R   j  s    c      	   C   sy   |  i |  i d d d d d g ƒ |  i |  i d d d g ƒ |  i d	 d
 d d
 d d d d d d g d d d ƒd  S(   Ni   s   Did you say "supercalifragiliss   ticexpialidocious?" How *do*s   you spell that odd word,s   anyways?i2   s1   Did you say "supercalifragilisticexpialidocious?"s*   How *do* you spell that odd word, anyways?t   -i
   t   hellos
   ----------s                  hs                  es                  ls                  ot   subsequent_indentR+   i   (   R   R   R   (   R   (    (    R   t   test_break_longq  s    c         C   s~   d |  i _ d |  i _ d d d d g } |  i i |  i ƒ } |  i | | ƒ t |  i d d d d ƒ} |  i | | ƒ d  S(	   Ni    i   s   Did you says%   "supercalifragilisticexpialidocious?"s   How *do* you spell that odds   word, anyways?R   t   break_long_words(	   R   R   RU   R   R   R   R   R   R   (   R   R   R   (    (    R   t   test_nobreak_longˆ  s    (   R   R   R   RT   RV   (    (    (    R   RP   i  s   		t   IndentTestCasesc           B   s,   t  Z d „  Z d „  Z d „  Z d „  Z RS(   Nc         C   s   d |  _ d  S(   Nsn   This paragraph will be filled, first without any indentation,
and then with some (including a hanging indent).(   R   R   (   R   (    (    R   R   œ  s    c         C   s,   d } t |  i d ƒ } |  i | | ƒ d  S(   Nsn   This paragraph will be filled, first
without any indentation, and then with
some (including a hanging indent).i(   (   R   R#   R   R   R   R   (   R   R   R   (    (    R   t	   test_fill¢  s    c         C   sr   d d d g } t |  i d d d ƒ} |  i | | ƒ d i | ƒ } t |  i d d d ƒ} |  i | | ƒ d  S(   Ns#        This paragraph will be filled,s'   first without any indentation, and thens'   with some (including a hanging indent).i(   R'   s        s   
(   R   R   R   R   R   R   R	   R#   (   R   R   R   (    (    R   t   test_initial_indent®  s    c         C   s8   d } t |  i d d d d d ƒ} |  i | | ƒ d  S(   Ns~     * This paragraph will be filled, first
    without any indentation, and then
    with some (including a hanging
    indent).i(   R'   s     * RS   s       (   R   R#   R   R   R   R   (   R   R   R   (    (    R   t   test_subsequent_indent¼  s    (   R   R   R   RX   RY   RZ   (    (    (    R   RW   ™  s   			t   DedentTestCasec           B   s#   t  Z d „  Z d „  Z d „  Z RS(   Nc         C   st   d } |  i t | ƒ | ƒ d } |  i t | ƒ | ƒ d } |  i t | ƒ | ƒ d } |  i t | ƒ | ƒ d  S(   Ns,   Hello there.
How are you?
Oh good, I'm glad.s   Hello there.

Boo!s    Hello there.
  This is indented.s   Hello there.

  Boo!
(   R   R   R   t   dedent(   R   R   (    (    R   t   test_dedent_nomarginÎ  s    c         C   sj   d } d } |  i t | ƒ | ƒ d } d } |  i t | ƒ | ƒ d } d } |  i t | ƒ | ƒ d  S(   Ns'     Hello there.
  How are ya?
  Oh good.s!   Hello there.
How are ya?
Oh good.s)     Hello there.

  How are ya?
  Oh good.
s#   Hello there.

How are ya?
Oh good.
s+     Hello there.
  
  How are ya?
  Oh good.
(   R   R   R   R   R\   (   R   R   R   (    (    R   t   test_dedent_evenß  s    c         C   sj   d } d } |  i t | ƒ | ƒ d } d } |  i t | ƒ | ƒ d } d } |  i t | ƒ | ƒ d  S(   NsK           def foo():
            while 1:
                return foo
        s+   def foo():
    while 1:
        return foo
s     Foo
    Bar

   Baz
s   Foo
  Bar

 Baz
s     Foo
    Bar
 
   Baz
(   R   R   R   R   R\   (   R   R   R   (    (    R   t   test_dedent_unevenï  s    (   R   R   R]   R^   R_   (    (    (    R   R[   Ì  s   		c           C   s   t  i t t t t ƒ d  S(   N(   t   test_supportt   run_unittestR   RP   RW   R[   (    (    (    R   t	   test_main	  s    	t   __main__(   t   unittestt   testR`   t   textwrapR   R   R#   R\   t   TestCaseR    R   RP   RW   R[   Rb   R   (   R`   R\   R    R   Rd   R   RP   R[   Rb   R   RW   R#   (    (    R   t   ?   s   	ÿ ;03=	