m
fIc           @   s\  d  k  Z  d  k Z d  k Z d  k Z d k l Z d k l Z d k l Z d k	 l
 Z
 l Z l Z l Z l Z l Z l Z l Z l Z l Z l Z l Z l Z l Z l Z y e e f Wn e j
 o dZ \ Z Z n Xd e f d     YZ d	 e f d
     YZ d e i f d     YZ  d e  f d     YZ! d e  f d     YZ" d e  f d     YZ# d e  f d     YZ$ h  d d <d d <d d d <d d d d <Z% d   Z& d e f d     YZ' d e  f d     YZ( d  e  f d!     YZ) d" e  f d#     YZ* d$ e  f d%     YZ+ d& e  f d'     YZ, d( e  f d)     YZ- d* e  f d+     YZ. d, e  f d-     YZ/ d. e  f d/     YZ0 d0 e  f d1     YZ1 d2 e  f d3     YZ2 d4 e  f d5     YZ3 d6 e  f d7     YZ4 d8 e  f d9     YZ5 d: e  f d;     YZ6 d< e  f d=     YZ7 d> e  f d?     YZ8 d@ e  f dA     YZ9 dB e  f dC     YZ: dD e  f dE     YZ; dF e  f dG     YZ< dH e< f dI     YZ= dJ e< f dK     YZ> dL e  f dM     YZ? dN Z@ dO ZA dP ZB dQ ZC dR e  f dS     YZD dT e  f dU     YZE dV   ZF dW   ZG dX   ZH eI dY j o e iJ   n d  S([   N(   s   StringIO(   s   pprint(   s   test_support(   s   make_options   Options   IndentedHelpFormatters   TitledHelpFormatters   OptionParsers   OptionContainers   OptionGroups   SUPPRESS_HELPs   SUPPRESS_USAGEs   OptionErrors   OptionConflictErrors   BadOptionErrors   OptionValueErrors   Valuess   _match_abbrevi   i    t   InterceptedErrorc           B   s#   t  Z d  d  d  d  Z d   Z RS(   Nc         C   s   | |  _  | |  _ | |  _ d  S(   N(   t   error_messaget   selft   exit_statust   exit_message(   R   R   R   R   (    (    t/   /mit/python/lib/python2.4/test/test_optparse.pyt   __init__!   s    		c         C   s   |  i p |  i p d S(   Ns   intercepted error(   R   R   R   (   R   (    (    R   t   __str__)   s    (   t   __name__t
   __module__t   NoneR   R   (    (    (    R   R        s   t   InterceptingOptionParserc           B   s    t  Z d d  d  Z d   Z RS(   Ni    c         C   s   t  d | d |   d  S(   NR   R   (   R    t   statust   msg(   R   R   R   (    (    R   t   exit-   s    c         C   s   t  d |   d  S(   NR   (   R    R   (   R   R   (    (    R   t   error0   s    (   R   R	   R
   R   R   (    (    (    R   R   ,   s   t   BaseTestc           B   sD   t  Z d   Z d   Z d   Z d d  d  Z d   Z d   Z RS(   Nc         C   sb   |  i i |  \ } } t |  } |  i | | d t
    |  i | | d t
    | | f S(   s  Assert the options are what we expected when parsing arguments.

        Otherwise, fail with a nicely formatted message.

        Keyword arguments:
        args -- A list of arguments to parse with OptionParser.
        expected_opts -- The options expected.
        expected_positional_args -- The positional arguments expected.

        Returns the options and positional args for further testing.
        sJ   
Options are %(optdict)s.
Should be %(expected_opts)s.
Args were %(args)s.sj   
Positional arguments are %(positional_args)s.
Should be %(expected_positional_args)s.
Args were %(args)s.N(   R   t   parsert
   parse_argst   argst   optionst   positional_argst   varst   optdictt   assertEqualt   expected_optst   localst   expected_positional_args(   R   R   R   R   R   R   R   (    (    R   t   assertParseOK5   s     c         C   s   | d j o
 f  } n | d j o
 h  } n y | | |   Wn? | j
 o3 } t |  } |  i	 | | d t    | Sn X|  i d t    d S(   s  
        Assert that the expected exception is raised when calling a
        function, and that the right error message is included with
        that exception.

        Arguments:
          func -- the function to call
          args -- positional arguments to `func`
          kwargs -- keyword arguments to `func`
          expected_exception -- exception that should be raised
          expected_output -- output we expect to see

        Returns the exception raised for further testing.
        sj   expected exception message:
'''%(expected_message)s'''
actual exception message:
'''%(actual_message)s'''
sn   expected exception %(expected_exception)s not raised
called %(func)r
with args %(args)r
and kwargs %(kwargs)r
N(   R   R
   t   kwargst   funct   expected_exceptiont   errt   strt   actual_messageR   R   t   expected_messageR   t   fail(   R   R   R   R   R   R#   R    R"   (    (    R   t   assertRaisesS   s     

		c         C   sP   y |  i i |  Wn( t j
 o } |  i | i |  n X|  i	 d  d S(   s   
        Assert the parser fails with the expected message.  Caller
        must ensure that self.parser is an InterceptingOptionParser.
        s   expected parse failureN(
   R   R   R   t   cmdline_argsR    R    R   R   t   expected_outputt   assertFalse(   R   R&   R'   R    (    (    R   t   assertParseFail   s     i    c         C   s   t  i } y@ z  t   t  _ |  i i |  Wd t  i i   } | t  _ XWnK t
 j
 o? } |  i | |  |  i | i |  |  i | i |  n X|  i d  d S(   s7   Assert the parser prints the expected output on stdout.Ns   expected parser.exit()(   t   syst   stdoutt   save_stdoutt   StringIOR   R   R   R&   t   getvaluet   outputR    R    R   R'   R   t   expected_statusR   t   expected_errorR(   (   R   R&   R'   R0   R1   R,   R    R/   (    (    R   t   assertOutput   s     	 c         G   s   |  i | | d t |  d S(   s4   Assert that TypeError is raised when executing func.N(   R   R%   R   R   R
   t	   TypeErrorR#   (   R   R   R#   R   (    (    R   t   assertTypeError   s     c         C   s@   | i   } | | j o# |  i d | d | d   n d  S(   Ns   help text failure; expected:
"s	   "; got:
"s   "
(   R   t   format_helpt   actual_helpt   expected_helpR   t   failureException(   R   R   R7   R6   (    (    R   t
   assertHelp   s    (	   R   R	   R   R%   R)   R
   R2   R4   R9   (    (    (    R   R   4   s   		1		t   TestOptionChecksc           B   s   t  Z d   Z g  h  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 RS(   Nc         C   s   t  d t  |  _ d  S(   Nt   usage(   t   OptionParsert   SUPPRESS_USAGER   R   (   R   (    (    R   t   setUp   s    c         C   s   |  i t | | t |  d  S(   N(   R   R%   t   make_optionR   R   t   OptionErrorR#   (   R   R#   R   R   (    (    R   t   assertOptionError   s    c         C   s   |  i t d  d  S(   Ns+   at least one option string must be supplied(   R   R4   R?   (   R   (    (    R   t   test_opt_string_empty   s    	c         C   s   |  i d d g  d  S(   Ns?   invalid option string 'b': must be at least two characters longt   b(   R   RA   (   R   (    (    R   t   test_opt_string_too_short   s    	c         C   s   |  i d d g  d  S(   NsO   invalid short option string '--': must be of the form -x, (x any non-dash char)s   --(   R   RA   (   R   (    (    R   t   test_opt_string_short_invalid   s    	c         C   s   |  i d d g  d  S(   NsJ   invalid long option string '---': must start with --, followed by non-dashs   ---(   R   RA   (   R   (    (    R   t   test_opt_string_long_invalid   s    	c         C   s,   |  i d d g h  d d  <d d  < d  S(   Ns.   option -b: invalid keyword arguments: bar, foos   -bt   foot   bar(   R   RA   R
   (   R   (    (    R   t   test_attr_invalid   s    	c         C   s#   |  i d d g h  d d < d  S(   Ns    option -b: invalid action: 'foo's   -bt   actionRG   (   R   RA   (   R   (    (    R   t   test_action_invalid   s    	c         C   sB   |  i d d g h  d d < |  i d d g h  d t < d  S(   Ns%   option -b: invalid option type: 'foo's   -bt   typeRG   s'   option -b: invalid option type: 'tuple'(   R   RA   t   tuple(   R   (    (    R   t   test_type_invalid   s    		c         C   s,   |  i d d g h  d d <d d < d  S(   Ns4   option -b: must not supply a type for action 'count's   -bRJ   t   countRL   t   int(   R   RA   (   R   (    (    R   t   test_no_type_for_action   s    	c         C   s&   |  i d d d g h  d d < d  S(   Ns@   option -b/--bad: must supply a list of choices for type 'choice's   -bs   --badRL   t   choice(   R   RA   (   R   (    (    R   t   test_no_choices_list   s    	c         C   sB   t  d  i } |  i d | d d g h  d d <d d < d  S(	   Nt    sB   option -b/--bad: choices must be a list of strings ('%s' supplied)s   -bs   --badRL   RR   t   choicess   bad choices(   RL   R   t   typenameR   RA   (   R   RV   (    (    R   t   test_bad_choices_list   s    	c         C   s,   |  i d d g h  d d <d d < d  S(   Ns1   option -b: must not supply choices for type 'int's   -bRL   RP   RU   t   bad(   R   RA   (   R   (    (    R   t   test_no_choices_for_type   s    	c         C   s,   |  i d d g h  d d <d d < d  S(   Ns:   option -b: 'const' must not be supplied for action 'store's   -bRJ   t   storet   consti   (   R   RA   (   R   (    (    R   t   test_no_const_for_action   s    	c         C   s,   |  i d d g h  d d <d d < d  S(   Ns:   option -b: 'nargs' must not be supplied for action 'count's   -bRJ   RO   t   nargsi   (   R   RA   (   R   (    (    R   t   test_no_nargs_for_action  s    	c         C   s,   |  i d d g h  d d <d d < d  S(   Ns'   option -b: callback not callable: 'foo's   -bRJ   t   callbackRG   (   R   RA   (   R   (    (    R   t   test_callback_not_callable	  s    	c         C   s   d  S(   N(    (   R   (    (    R   t   dummy  s    c         C   s8   |  i d d g h  d d <d |  i <d d < d  S(   NsA   option -b: callback_args, if supplied, must be a tuple: not 'foo's   -bRJ   R_   t   callback_argsRG   (   R   RA   Ra   (   R   (    (    R   t   test_callback_args_no_tuple  s    	c         C   s8   |  i d d g h  d d <d |  i <d d < d  S(   NsB   option -b: callback_kwargs, if supplied, must be a dict: not 'foo's   -bRJ   R_   t   callback_kwargsRG   (   R   RA   Ra   (   R   (    (    R   t   test_callback_kwargs_no_dict  s    	c         C   s,   |  i d d g h  d d <d d < d  S(   Ns<   option -b: callback supplied ('foo') for non-callback options   -bRJ   RZ   R_   RG   (   R   RA   (   R   (    (    R   t   test_no_callback_for_action"  s    	c         C   s,   |  i d d g h  d d <d d < d  S(   Ns9   option -b: callback_args supplied for non-callback options   -bRJ   RZ   Rb   RG   (   R   RA   (   R   (    (    R   t    test_no_callback_args_for_action(  s    	c         C   s,   |  i d d g h  d d <d d < d  S(   Ns;   option -b: callback_kwargs supplied for non-callback options   -bRJ   RZ   Rd   RG   (   R   RA   (   R   (    (    R   t"   test_no_callback_kwargs_for_action.  s    	(   R   R	   R>   RA   RB   RD   RE   RF   RI   RK   RN   RQ   RS   RW   RY   R\   R^   R`   Ra   Rc   Re   Rf   Rg   Rh   (    (    (    R   R:      s,   																				t   TestOptionParserc           B   sb   t  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d	   Z
 d
   Z RS(   Nc      	   C   sW   t    |  _ |  i i d d d d d d d d |  i i d	 d
 d d d d d d  S(   Ns   -vs	   --verboses   -ns   --noisyRJ   t
   store_truet   destt   verboses   -qs   --quiets   --silentt   store_false(   R<   R   R   t
   add_option(   R   (    (    R   R>   5  s
    c         C   s   |  i |  i i d d   d  S(   Ns   not an Option instance: None(   R   R4   R   Rn   R
   (   R   (    (    R   t   test_add_option_no_Option<  s    c         C   s    |  i |  i i d d  d   d  S(   Ns   invalid arguments(   R   R4   R   Rn   R
   (   R   (    (    R   t!   test_add_option_invalid_arguments@  s    c         C   s   |  i i d  } |  i t | t   |  i | i d d g  |  i | i	 d d g  |  i | i
 d  |  i | i d  d  S(   Ns   -vs   -ns	   --verboses   --noisyRj   Rl   (   R   R   t
   get_optiont   opt1t   assert_t
   isinstancet   OptionR   t   _short_optst
   _long_optsRJ   Rk   (   R   Rr   (    (    R   t   test_get_optionD  s    c         C   s|   |  i i d  } |  i i d  } |  i i d  } |  i i d  } |  i | | j o | j o
 | j n  d  S(   Ns   -vs	   --verboses   -ns   --noisy(   R   R   Rq   Rr   t   opt2t   opt3t   opt4Rs   (   R   R{   Rr   Rz   Ry   (    (    R   t   test_get_option_equalsL  s
    c         C   s6   |  i |  i i d   |  i |  i i d   d  S(   Ns   -vs	   --verbose(   R   Rs   R   t
   has_option(   R   (    (    R   t   test_has_optionS  s    c         C   s  |  i |  i i d  d  j  |  i |  i i d  d  j  |  i |  i i d  d  j  |  i |  i i d  d  j  |  i |  i i d   |  i |  i i d   |  i |  i i d   |  i |  i i d   |  i |  i i d   |  i |  i i d   d  S(   Ns   -vs	   --verboses   -ns   --noisys   -qs   --silent(   R   Rs   R   Rq   R
   t   failIfR}   (   R   (    (    R   t   assert_removedW  s    c         C   s   |  i i d  |  i   d  S(   Ns   -n(   R   R   t   remove_optionR   (   R   (    (    R   t   test_remove_short_opte  s    c         C   s   |  i i d  |  i   d  S(   Ns	   --verbose(   R   R   R   R   (   R   (    (    R   t   test_remove_long_opti  s    c         C   s#   |  i |  i i d d  t d  d  S(   NRG   s   no such option 'foo'(   s   foo(   R   R%   R   R   R
   t
   ValueError(   R   (    (    R   t   test_remove_nonexistentm  s    (   R   R	   R>   Ro   Rp   Rx   R|   R~   R   R   R   R   (    (    (    R   Ri   4  s   									t   TestOptionValuesc           B   s   t  Z d   Z d   Z RS(   Nc         C   s   d  S(   N(    (   R   (    (    R   R>   r  s    c         C   s   t    } |  i t |  h   |  i | h   |  i | h  d d < |  i | d  h  d d <d d <} t  d |  } |  i t |  |  |  i | |  |  i | h  d d < |  i | h   |  i | d  |  i | g   d  S(   NRG   RH   RT   t   bazi*   t   defaults(   t   Valuest   valuesR   R   R   t   assertNotEqualt   dict(   R   R   R   (    (    R   t   test_basicsu  s    	(   R   R	   R>   R   (    (    (    R   R   q  s   	t   TestTypeAliasesc           B   s   t  Z d   Z d   Z RS(   Nc         C   s   t    |  _ d  S(   N(   R<   R   R   (   R   (    (    R   R>     s    c         C   s   |  i i d d t |  i i d d t |  i i d d d |  i |  i i d  i d  |  i |  i i d  i d  |  i |  i i d  i d  d  S(   Ns   -xRL   s   -ss   -tR!   RP   t   string(   R   R   Rn   RP   R!   t   assertEqualsRq   RL   (   R   (    (    R   t   test_type_aliases  s    (   R   R	   R>   R   (    (    (    R   R     s   	t   st   mi<   t   ht   di   c         C   so   y= | d i   o t |  Sn t | d   t | d SWn+ t j
 o } t d | | f   n Xd  S(   Nis   option %s: invalid duration: %r(   t   valuet   isdigitRP   t   _time_unitsR   t
   IndexErrort   OptionValueErrort   opt(   t   optionR   R   R   (    (    R   t   _check_duration  s    t   DurationOptionc           B   s1   t  Z e i d Z e i e i  Z e e d <RS(   Nt   duration(   R   (   R   R	   Ru   t   TYPESt   copyt   TYPE_CHECKERR   (    (    (    R   R     s   t   TestDefaultValuesc           B   s5   t  Z d   Z d   Z d   Z d   Z d   Z RS(   Nc         C   s   t    |  _ |  i i d d d t |  i i d d d d |  i i d d	 d
 d d |  i i d d	 d
 |  i i d d d |  i i d  |  i i d d d  h  d t <d d <d d  <d d <d d  <d d  <|  _ d  S(   Ns   -vs	   --verboset   defaults   -qs   --quietRk   Rl   s   -nRL   RP   i%   s   -ms   -sRG   s   -ts   -ut   nR   R   t   tt   u(   R<   R   R   Rn   t   TrueR
   t   expected(   R   (    (    R   R>     s    c         C   s    |  i |  i i   |  i  d  S(   N(   R   R   R   t   get_default_valuesR   (   R   (    (    R   t   test_basic_defaults  s    c         C   s[   |  i i d d d d  |  i i h  d d <d d < |  i |  i i   |  i  d  S(   NR   i*   R   i(   R   R   t   set_defaultsR   t   updateR   R   (   R   (    (    R   t   test_mixed_defaults_post  s    "c         C   s   |  i i d d d d  |  i i d d d |  i i d  |  i i h  d d <d d < |  i |  i i   |  i  |  i i d  |  i i d d d  |  i i h  d d  < |  i |  i i   |  i  d  S(	   Nt   xt   barft   yt   blahs   -xR   t   frobs   -y(
   R   R   R   Rn   R   R   R   R   R   R
   (   R   (    (    R   t   test_mixed_defaults_pre  s    "c         C   s   t  |  i _ |  i i d d d d d |  i i d d d d d |  i i d d	  |  i i h  d
 d <d d <d d < |  i |  i i	   |  i  |  i i
 t  |  i i h  d
 d <d d <d d	 < |  i |  i i	   |  i  d  S(   Ns   -dRL   R   R   i,  s   -et   6mR   t   42R   t   eih  i*   (   R   R   R   t   option_classRn   R   R   R   R   R   t   set_process_default_valuest   False(   R   (    (    R   t   test_process_default  s    ++(   R   R	   R>   R   R   R   R   (    (    (    R   R     s
   				t   TestProgNamec           B   s2   t  Z d  Z d   Z d   Z d   Z d   Z RS(   s]   
    Test that %prog expands to the right thing in usage, version,
    and help strings.
    c         C   s   |  i | i   |  d  S(   N(   R   R   R   t	   get_usaget   expected_usage(   R   R   R   (    (    R   t   assertUsage  s    c         C   s   |  i | i   |  d  S(   N(   R   R   R   t   get_versiont   expected_version(   R   R   R   (    (    R   t   assertVersion  s    c         C   s   t  i } zs t i i d d d  t  i d <t d d d } d } |  i
 | |  |  i | d	  |  i | | d
 d  Wd  | t  i (Xd  S(   NRG   RH   s   baz.pyi    s   usage: %prog ...t   versions	   %prog 1.2s   usage: baz.py ...
s
   baz.py 1.2s   
sl   options:
  --version   show program's version number and exit
  -h, --help  show this help message and exit
(   R*   t   argvt	   save_argvt   ost   patht   joinR<   R   R   R   R   R   R9   (   R   R   R   R   (    (    R   t   test_default_progname  s    
	 c         C   ss   t  d d d d d d  } | i d  | i d  d	 } |  i | |  |  i | d
  |  i | | d  d  S(   Nt   progt   thingyR   s	   %prog 0.1R;   s   %prog arg args   -hs	   --versions   usage: thingy arg arg
s
   thingy 0.1s   
(   R<   R   R   R   R   R   R   R9   (   R   R   R   (    (    R   t   test_custom_progname  s    	(   R   R	   t   __doc__R   R   R   R   (    (    (    R   R     s
    			t   TestExpandDefaultsc           B   sb   t  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d	   Z
 d
   Z RS(   Nc         C   sH   t  d d  |  _ d |  _ d |  _ |  i d |  _ |  i d |  _ d  S(   NR   t   testsX   usage: test [options]

options:
  -h, --help            show this help message and exit
s"   read from FILE [default: %default]s:     -f FILE, --file=FILE  read from FILE [default: foo.txt]
s7     -f FILE, --file=FILE  read from FILE [default: none]
(   R<   R   R   t   help_prefixt	   file_helpt   expected_help_filet   expected_help_none(   R   (    (    R   R>     s
    		c         C   s<   |  i i d d d d d |  i |  i |  i |  i  d  S(   Ns   -fs   --fileR   s   foo.txtt   help(   R   R   Rn   R   R9   R   (   R   (    (    R   t   test_option_default  s    c         C   sI   |  i i d d d |  i |  i i d d  |  i |  i |  i  d  S(   Ns   -fs   --fileR   t   files   foo.txt(   R   R   Rn   R   t   set_defaultR9   R   (   R   (    (    R   t   test_parser_default_1  s    c         C   sI   |  i i d d d |  i |  i i d d  |  i |  i |  i  d  S(   Ns   -fs   --fileR   R   s   foo.txt(   R   R   Rn   R   R   R9   R   (   R   (    (    R   t   test_parser_default_2  s    c         C   s6   |  i i d d d |  i |  i |  i |  i  d  S(   Ns   -fs   --fileR   (   R   R   Rn   R   R9   R   (   R   (    (    R   t   test_no_default#  s    c         C   s<   |  i i d d d d  d |  i |  i |  i |  i  d  S(   Ns   -fs   --fileR   R   (   R   R   Rn   R
   R   R9   R   (   R   (    (    R   t   test_default_none_1(  s    c         C   sI   |  i i d d d |  i |  i i d d   |  i |  i |  i  d  S(   Ns   -fs   --fileR   R   (   R   R   Rn   R   R   R
   R9   R   (   R   (    (    R   t   test_default_none_2.  s    c         C   sP   |  i i d d d d |  i i d d  |  i d } |  i |  i |  d  S(   Ns   -ps   --probR   s1   blow up with probability PROB [default: %default]t   probf0.42999999999999999sF     -p PROB, --prob=PROB  blow up with probability PROB [default: 0.43]
(   R   R   Rn   R   R   R7   R9   (   R   R7   (    (    R   t   test_float_default4  s
    
c         C   sH   |  i i d d d d d d d |  i i _ |  i |  i |  i  d  S(   Ns   -fs   --fileR   s   foo.txtR   s#   read from FILE [default: *DEFAULT*]s	   *DEFAULT*(   R   R   Rn   t	   formattert   default_tagR9   R   (   R   (    (    R   t   test_alt_expand=  s
    
c         C   sR   |  i i d d d d d d d  |  i i _ |  i d } |  i |  i |  d  S(   Ns   -fs   --fileR   s   foo.txtR   s   read from %default files0     -f FILE, --file=FILE  read from %default file
(	   R   R   Rn   R
   R   R   R   R7   R9   (   R   R7   (    (    R   t   test_no_expandD  s    
(   R   R	   R>   R   R   R   R   R   R   R   R   R   (    (    (    R   R     s   										t   TestStandardc           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 d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   Nc         C   sX   t  d d d t  d d d d d d t  d	 d
 d g } t d t d |  |  _ d  S(   Ns   -aRL   R   s   -bs   --booRP   Rk   t   boos   --fooRJ   t   appendR;   t   option_list(   R?   R   R   R=   R   R   (   R   R   (    (    R   R>   Q  s    <	c         C   s   |  i d g d  d  S(   Ns   -as   -a option requires an argument(   R   R)   (   R   (    (    R   t   test_required_valueY  s    c         C   s   |  i d d g d  d  S(   Ns   -bt   5xs&   option -b: invalid integer value: '5x'(   R   R)   (   R   (    (    R   t   test_invalid_integer\  s    c         C   s   |  i d g d  d  S(   Ns   --boo13s   no such option: --boo13(   R   R)   (   R   (    (    R   t   test_no_such_option`  s    c         C   s   |  i d g d  d  S(   Ns   --boo=x5s)   option --boo: invalid integer value: 'x5'(   R   R)   (   R   (    (    R   t   test_long_invalid_integerc  s    c         C   s2   |  i g  h  d d  <d d  <d d  <g   d  S(   Nt   aR   RG   (   R   R   R
   (   R   (    (    R   t
   test_emptyg  s    c         C   sD   |  i d d d d g h  d d <d d  <d d d g <g   d  S(	   Ns   -aRT   s
   --foo=blahs   --foo=R   R   RG   R   (   R   R   R
   (   R   (    (    R   t"   test_shortopt_empty_longopt_appendj  s    $c         C   sJ   |  i d d d d d g h  d d  <d d  <d d d d g <g   d  S(	   Ns   --fooRH   RT   s   --foo=xR   R   RG   R   (   R   R   R
   (   R   (    (    R   t   test_long_option_appendo  s    'c         C   s5   |  i d g h  d d <d d  <d d  <g   d  S(   Ns   -abcR   t   bcR   RG   (   R   R   R
   (   R   (    (    R   t   test_option_argument_joinedv  s    c         C   s8   |  i d d g h  d d <d d  <d d  <g   d  S(   Ns   -at   34R   R   RG   (   R   R   R
   (   R   (    (    R   t   test_option_argument_split{  s    c         C   s5   |  i d g h  d d  <d d <d d  <g   d  S(   Ns   -b34R   R   i"   RG   (   R   R   R
   (   R   (    (    R   t#   test_option_argument_joined_integer  s    c         C   s8   |  i d d g h  d d  <d d <d d  <g   d  S(   Ns   -bs   -5R   R   iRG   (   R   R   R
   (   R   (    (    R   t+   test_option_argument_split_negative_integer  s    c         C   s5   |  i d g h  d d  <d d <d d  <g   d  S(   Ns   --boo=13R   R   i   RG   (   R   R   R
   (   R   (    (    R   t    test_long_option_argument_joined  s    c         C   s8   |  i d d g h  d d  <d d <d d  <g   d  S(   Ns   --boot   111R   R   io   RG   (   R   R   R
   (   R   (    (    R   t   test_long_option_argument_split  s    c         C   s;   |  i d d g h  d d <d d  <d d g <g   d  S(   Ns	   --foo=bars   -axyzR   t   xyzR   RG   RH   (   R   R   R
   (   R   (    (    R   t   test_long_option_short_option  s    !c         C   s;   |  i d d g h  d d <d d  <d d g <g   d  S(   Ns   --f=bars   -axyzR   R   R   RG   RH   (   R   R   R
   (   R   (    (    R   t   test_abbrev_long_option  s    !c         C   sG   |  i i g   \ } } |  i i   } |  i t |  t |   d  S(   N(	   R   R   R   R   R   R   R   R   R   (   R   R   R   R   (    (    R   t   test_defaults  s    c         C   s9   |  i i d d d d d d d |  i d g d	  d  S(
   Ns   --fozRJ   RZ   RL   R   Rk   RG   s   --f=bars%   ambiguous option: --f (--foo, --foz?)(   R   R   Rn   R)   (   R   (    (    R   t   test_ambiguous_option  s    c         C   sD   |  i d d d d g h  d d <d d  <d d g <g   f d  S(   Ns   -aR   s   --fooRH   R   R   RG   (   R   R   R
   (   R   (    (    R   t    test_short_and_long_option_split  s    !c         C   sG   |  i d d d d d g h  d d  <d d <d	 d
 d g <g   d  S(   Ns	   --foo=bars   -bt   123s   --fooR   R   R   i{   RG   RH   (   R   R   R
   (   R   (    (    R   t*   test_short_option_split_long_option_append  s    $c         C   sA   |  i d d d g h  d d <d d  <d d  <d g  f d  S(   Ns   -aRG   RH   R   R   (   R   R   R
   (   R   (    (    R   t*   test_short_option_split_one_positional_arg  s    c         C   sG   |  i d d d d g h  d d <d d  <d d  <d d g  f d  S(   Ns   -as   --RG   RH   R   R   (   R   R   R
   (   R   (    (    R   t$   test_short_option_consumes_separator  s    c         C   sG   |  i d d d d g h  d d <d d  <d d  <d d g  f d  S(	   Ns   -abs   --s   --fooRH   R   RC   R   RG   (   R   R   R
   (   R   (    (    R   t&   test_short_option_joined_and_separator  s    c         C   sD   |  i d d d d g h  d d <d d  <d d g <d g  d  S(	   Ns   -abt   -s   --fooRH   R   RC   R   RG   (   R   R   R
   (   R   (    (    R   t*   test_invalid_option_becomes_positional_arg  s    !c         C   sJ   |  i d d d d d d g h  d d  <d d	 <d
 d d g <g   d  S(   Ns   -b3s   -bt   5s	   --foo=bars   --fooR   R   R   i   RG   RH   (   R   R   R
   (   R   (    (    R   t   test_no_append_versus_append  s    $c         C   s8   |  i d d g h  d d <d d  <d d  <g   d  S(   Ns   -as   -b3R   R   RG   (   R   R   R
   (   R   (    (    R   t&   test_option_consumes_optionlike_string  s    (   R   R	   R>   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R  R  R  R  (    (    (    R   R   P  s4   																									t   TestBoolc           B   s5   t  Z d   Z d   Z d   Z d   Z d   Z RS(   Nc      	   C   sR   t  d d d d d d d d t  d	 d
 d d d d g } t d |  |  _ d  S(   Ns   -vs	   --verboseRJ   Rj   Rk   Rl   R   RT   s   -qs   --quietRm   R   (   R?   R   R<   R   R   (   R   R   (    (    R   R>     s    c         C   s    |  i g  h  d d <g   d  S(   NRl   RT   (   R   R   (   R   (    (    R   t   test_bool_default  s    	c         C   sU   |  i d g h  d d <g   \ } } t t d  o |  i | i t j  n d  S(   Ns   -qRl   i    R   (	   R   R   R   R   t   hasattrt   __builtins__t
   failUnlessRl   R   (   R   R   R   (    (    R   t   test_bool_false  s
    c         C   sU   |  i d g h  d d <g   \ } } t t d  o |  i | i t j  n d  S(   Ns   -vRl   i   R   (	   R   R   R   R   R  R  R  Rl   R   (   R   R   R   (    (    R   t   test_bool_true  s
    c         C   s)   |  i d d d g h  d d <g   d  S(   Ns   -qvqs   -qs   -vRl   i   (   R   R   (   R   (    (    R   t   test_bool_flicker_on_and_off  s    (   R   R	   R>   R
  R  R  R  (    (    (    R   R	    s
   				t
   TestChoicec           B   s,   t  Z d   Z d   Z d   Z d   Z RS(   Nc         C   sG   t  d t  |  _ |  i i d d d d d d d d d	 d
 d g d  S(   NR;   s   -cRJ   RZ   RL   RR   Rk   RU   t   onet   twot   three(   R   R=   R   R   Rn   (   R   (    (    R   R>     s    c         C   s,   |  i d d d g h  d d <d g  d  S(   Ns   -cR  R   RR   (   R   R   (   R   (    (    R   t   test_valid_choice  s    c         C   s   |  i d d d g d  d  S(   Ns   -ct   fourt   abcsE   option -c: invalid choice: 'four' (choose from 'one', 'two', 'three')(   R   R)   (   R   (    (    R   t   test_invalid_choice  s    c         C   s^   |  i i d d d d d d g |  i i d  } |  i | i d  |  i | i d  d  S(	   Ns   -ds	   --defaultRU   R  t   fivet   sixRR   RZ   (   R   R   Rn   Rq   R   R   RL   RJ   (   R   R   (    (    R   t   test_add_choice_option  s
    (   R   R	   R>   R  R  R  (    (    (    R   R    s   			t	   TestCountc           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 RS(   Nc      	   C   s   t  d t  |  _ t d d d d d |  _ |  i i |  i  |  i i d d d	 d d |  i i d
 d d d d d d d d  S(   NR;   s   -vRJ   RO   Rk   Rl   s	   --verboseRL   RP   s   -qs   --quiett   store_constR[   i    (   R   R=   R   R   R?   t   v_optRn   (   R   (    (    R   R>     s    c         C   s    |  i g  h  d d  <g   d  S(   NRl   (   R   R   R
   (   R   (    (    R   R     s    c         C   s#   |  i d g h  d d <g   d  S(   Ns   -vRl   i   (   R   R   (   R   (    (    R   t   test_count_one  s    c         C   s#   |  i d g h  d d <g   d  S(   Ns   -vvvRl   i   (   R   R   (   R   (    (    R   t   test_count_three  s    c         C   s)   |  i d d d g h  d d <g   d  S(   Ns   -vRl   i   (   R   R   (   R   (    (    R   t   test_count_three_apart   s    c         C   s&   |  i d d g h  d d <g   d  S(   Ns   -vvvs   --verbose=2Rl   i   (   R   R   (   R   (    (    R   t   test_count_override_amount#  s    c         C   s)   |  i d d d g h  d d <g   d  S(   Ns   -vvvs   --verbose=2s   -qRl   i    (   R   R   (   R   (    (    R   t   test_count_override_quiet&  s    c         C   s,   |  i d d d d g h  d d <g   d  S(   Ns   -vvvs   --verbose=2s   -qs   -vRl   i   (   R   R   (   R   (    (    R   t   test_count_overriding)  s    c         C   s,   |  i d d d g h  d d <d g  d  S(   Ns   --quiett   3s   -vRl   i   (   R   R   (   R   (    (    R   t   test_count_interspersed_args-  s    c         C   s<   |  i i   |  i d d d g h  d d <d d g  d  S(   Ns   --quietR%  s   -vRl   i    (   R   R   t   disable_interspersed_argsR   (   R   (    (    R   t   test_count_no_interspersed_args2  s    c         C   s   |  i d d g d  d  S(   Ns   -q3s   -vs   no such option: -3(   R   R)   (   R   (    (    R   t   test_count_no_such_option8  s    c         C   s   |  i d d g d  d  S(   Ns	   --quiet=3s   -vs$   --quiet option does not take a value(   R   R)   (   R   (    (    R   t   test_count_option_no_value;  s    c         C   s3   |  i i d d  |  i g  h  d d <g   d  S(   NRl   i    (   R   R   R   R   (   R   (    (    R   t   test_count_with_default?  s    c         C   s?   |  i i d d  |  i d d d d g h  d d <g   d  S(   NRl   i    s   -vvvs   --verbose=2s   -qs   -vi   (   R   R   R   R   (   R   (    (    R   t   test_count_overriding_defaultC  s    (   R   R	   R>   R   R  R   R!  R"  R#  R$  R&  R(  R)  R*  R+  R,  (    (    (    R   R    s   													t   TestMultipleArgsc           B   s5   t  Z d   Z d   Z d   Z d   Z d   Z RS(   Nc         C   sA   t  d t  |  _ |  i i d d d d d d d d	 d
 d d  S(   NR;   s   -ps   --pointRJ   RZ   R]   i   RL   t   floatRk   t   point(   R   R=   R   R   Rn   (   R   (    (    R   R>   I  s    c         C   s8   |  i d d d d d d g h  d d <d d g  d  S(   NRG   s   -pt   1s   2.5s   -4.3R   R/  f1.0f2.5f-4.2999999999999998(   f1.0f2.5f-4.2999999999999998(   R   R   (   R   (    (    R   t   test_nargs_with_positional_argsN  s    c         C   s<   |  i d d d d d g h  d d d d	 f <d g  d  S(
   Ns   --points   -1s   2.5s   -0R   R/  f-1.0f2.5f0.0(   R   R   (   R   (    (    R   t   test_nargs_long_optS  s    c         C   s    |  i d d d d g d  d  S(   Ns   -ps   1.0t   2xs   3.5s-   option -p: invalid floating-point value: '2x'(   R   R)   (   R   (    (    R   t   test_nargs_invalid_float_valueX  s    c         C   s   |  i d d d g d  d  S(   Ns   --points   1.0s   3.5s#   --point option requires 3 arguments(   R   R)   (   R   (    (    R   t   test_nargs_required_values]  s    (   R   R	   R>   R1  R2  R4  R5  (    (    (    R   R-  H  s
   				t   TestMultipleArgsAppendc           B   s,   t  Z d   Z d   Z d   Z d   Z RS(   Nc         C   sl   t  d t  |  _ |  i i d d d d d d d d	 d
 d |  i i d d d d d d d d d
 d d  S(   NR;   s   -ps   --pointRJ   RZ   R]   i   RL   R.  Rk   R/  s   -fs   --fooR   i   RP   RG   (   R   R=   R   R   Rn   (   R   (    (    R   R>   b  s
    c         C   sG   |  i d d d d d d d g h  d d  <d	 d d g <d g  d  S(   Ns   -ft   4s   -3R   s   --fooR0  t   666R/  RG   i   ii   i  (   i   i(   i   i  (   R   R   R
   (   R   (    (    R   t   test_nargs_appendi  s    c         C   s   |  i d g d  d  S(   Ns   -f4,3s   -f option requires 2 arguments(   R   R)   (   R   (    (    R   t!   test_nargs_append_required_valuesn  s    c         C   s2   |  i d d g h  d d  <d d g <g   d  S(   Ns   --foo=3R7  R/  RG   i   i   (   i   i   (   R   R   R
   (   R   (    (    R   t   test_nargs_append_simpler  s    (   R   R	   R>   R9  R:  R;  (    (    (    R   R6  a  s   			t   TestVersionc           B   s   t  Z d   Z d   Z RS(   Nc         C   sm   t  d t d d  |  _ t i } z9 t i i	 t i
 d d  t i d <|  i d g d  Wd  | t i (Xd  S(	   NR;   R   s	   %prog 0.1RG   RH   i    s	   --versions   bar 0.1
(   R   R=   R   R   R*   R   R   R   R   R   t   curdirR2   (   R   R   (    (    R   t   test_versionx  s    	
" c         C   s)   t  d t  |  _ |  i d g d  d  S(   NR;   s	   --versions   no such option: --version(   R   R=   R   R   R)   (   R   (    (    R   t   test_no_version  s    (   R   R	   R>  R?  (    (    (    R   R<  w  s   	
t   TestConflictingDefaultsc           B   s)   t  Z d  Z d   Z d   Z d   Z RS(   s4   Conflicting default values: the last one should win.c      
   C   s1   t  d t d d d d d d d g  |  _ d  S(	   NR   s   -vRJ   Rj   Rk   Rl   R   i   (   R<   R?   R   R   (   R   (    (    R   R>     s    c         C   sB   |  i i d d d d d d d |  i g  h  d d <g   d  S(   Ns   -qRJ   Rm   Rk   Rl   R   i    (   R   R   Rn   R   (   R   (    (    R   t   test_conflict_default  s    
c         C   sB   |  i i d d d d d d d  |  i g  h  d d  <g   d  S(   Ns   -qRJ   Rm   Rk   Rl   R   (   R   R   Rn   R
   R   (   R   (    (    R   t   test_conflict_default_none  s    
(   R   R	   R   R>   RA  RB  (    (    (    R   R@    s    		t   TestOptionGroupc           B   s>   t  Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   Nc         C   s   t  d t  |  _ d  S(   NR;   (   R<   R=   R   R   (   R   (    (    R   R>     s    c         C   s^   t  |  i d  } |  i i |  | i d d d d d |  i d g h  d d <g   d  S(	   Nt   Spams   --spamRJ   Rj   R   s   spam spam spam spamt   spami   (   t   OptionGroupR   R   t   groupt   add_option_groupRn   R   (   R   RG  (    (    R   t!   test_option_group_create_instance  s
    
c         C   s   |  i |  i i d d   d  S(   Ns!   not an OptionGroup instance: None(   R   R4   R   RH  R
   (   R   (    (    R   t   test_add_group_no_group  s    c         C   s    |  i |  i i d d  d   d  S(   Ns   invalid arguments(   R   R4   R   RH  R
   (   R   (    (    R   t    test_add_group_invalid_arguments  s    c         C   sD   t  |  i d  } t   | _ |  i |  i i | f d  t d  d  S(   NRD  s"   invalid OptionGroup (wrong parser)(	   RF  R   R   RG  R<   R%   RH  R
   R   (   R   RG  (    (    R   t   test_add_group_wrong_parser  s    c         C   sX   |  i i d d d } | i d  | i d d d |  i |  i i d  |  d  S(   Ns   Group 2t   descriptions   Some more optionst   Bacons   --baconRL   RP   (   R   R   RH  RG  t	   set_titleRn   Rs   t   get_option_group(   R   RG  (    (    R   t   test_group_manipulate  s
    (   R   R	   R>   RI  RJ  RK  RL  RQ  (    (    (    R   RC    s   					t   TestExtendAddTypesc           B   sB   t  Z d   Z d e f d     YZ d   Z d   Z d   Z RS(   Nc         C   s]   t  d t d |  i  |  _ |  i i d d  d d d d |  i i d d	 d d
 d d
 d  S(   NR;   R   s   -aRL   R   Rk   R   s   -fs   --fileR   (   R   R=   R   t   MyOptionR   Rn   R
   (   R   (    (    R   R>     s    	RS  c           B   s:   t  Z d   Z e i d Z e i e i  Z e e d <RS(   Nc         C   sR   t  i i |  p t d |   n( t  i i |  p t d |   n | S(   Ns   %s: file does not exists   %s: not a regular file(   R   R   t   existsR   R   t   isfile(   R   R   R   (    (    R   t
   check_file  s
    R   (   s   file(   R   R	   RV  Ru   R   R   R   (    (    (    R   RS    s   	c         C   s^   t  t i d  i   |  i d t i d g h  d t i <d d <g   t i t i  d  S(   Nt   ws   --files   -afooR   R   RG   (   t   opent   test_supportt   TESTFNt   closeR   R   R   t   unlink(   R   (    (    R   t   test_extend_file  s
    c         C   s'   |  i d t i d g d t i  d  S(   Ns   --files   -afoos   %s: file does not exist(   R   R)   RY  RZ  (   R   (    (    R   t   test_extend_file_nonexistent  s    c         C   sG   t  i t i  |  i d t i d g d t i  t  i t i  d  S(   Ns   --files   -afoos   %s: not a regular file(   R   t   mkdirRY  RZ  R   R)   t   rmdir(   R   (    (    R   t   test_file_irregular  s    (   R   R	   R>   Ru   RS  R]  R^  Ra  (    (    (    R   RR    s
   			t   TestExtendAddActionsc           B   s9   t  Z d   Z d e f d     YZ d   Z d   Z RS(   Nc      	   C   s=   |  i d d d d d d d d g } t d	 |  |  _ d  S(
   Ns   -as   --appleRJ   t   extendRL   R   Rk   t   appleR   (   R   RS  R   R<   R   (   R   R   (    (    R   R>     s    RS  c           B   s8   t  Z e i d Z e i d Z e i d Z d   Z RS(   NRc  c         C   s\   | d j o, | i d  } | i | g   i |  n  t i	 |  | | | | | |  d  S(   NRc  t   ,(   RJ   R   t   splitt   lvalueR   t   ensure_valueRk   Rc  Ru   t   take_actionR   R   R   (   R   RJ   Rk   R   R   R   R   Rg  (    (    R   Ri    s
    (   s   extend(   s   extend(   s   extend(   R   R	   Ru   t   ACTIONSt   STORE_ACTIONSt   TYPED_ACTIONSRi  (    (    (    R   RS    s   c         C   s/   |  i d d g h  d d d d g <g   d  S(   Ns	   -afoo,bars   --apple=blahRd  RG   RH   R   (   R   R   (   R   (    (    R   t   test_extend_add_action  s    c      	   C   s8   |  i d d d d g h  d d d d d g <g   d  S(	   Ns   -aRG   s   -abars   --apple=x,yRd  RH   R   R   (   R   R   (   R   (    (    R   t   test_extend_add_action_normal  s    (   R   R	   R>   Ru   RS  Rm  Rn  (    (    (    R   Rb    s   		t   TestCallbackc           B   s,   t  Z d   Z d   Z d   Z d   Z RS(   Nc         C   s^   t  d d  d d d |  i t  d d d d d |  i d d d d	 g } t d
 |  |  _ d  S(   Ns   -xRJ   R_   s   -fs   --fileRL   R   Rk   t   filenameR   (   R?   R
   R   t   process_optR   R<   R   (   R   R   (    (    R   R>     s    	c         C   sJ  | d j o |  i | i d g  |  i | i g   |  i | |  i j  |  i | d  j  |  i t | i  h  d d  < d | i _ n | d j o |  i | i d g  |  i | i d g  |  i | |  i j  |  i | d  |  i t | i  h  d d  <d d < t | i | i |  n |  i d |  d  S(	   Ns   -xRp  i*   s   --files   -fRG   R   s!   Unknown option %r in process_opt.(   R   R   R   R   Rv   Rw   Rs   t   parser_R   R   R
   R   R   R   t   setattrRk   R$   (   R   R   R   R   Rr  (    (    R   Rq    s    "+c         C   s/   |  i d d g h  d d <d d <g   d  S(   Ns   -xs
   --file=fooRp  RG   R   i*   (   R   R   (   R   (    (    R   t   test_callback#  s    c         C   sa   t  d t  } | i d  | i d d d d d d   d d	 d
 d d } |  i | |  d  S(   NR;   s   -hs   -ts   --testRJ   R_   c           C   s   d  S(   N(   R
   (    (    (    R   t   <lambda>/  s    RL   R   R   RG   s%   options:
  -t TEST, --test=TEST  foo
(   R<   R=   R   R   Rn   R7   R   R9   (   R   R   R7   (    (    R   t   test_callback_help(  s    
(   R   R	   R>   Rq  Rt  Rv  (    (    (    R   Ro    s   			t   TestCallbackExtraArgsc           B   s#   t  Z d   Z d   Z d   Z RS(   Nc         C   sU   t  d d d d d |  i d d t f d d d	 d
 d g  g } t d |  |  _ d  S(   Ns   -ps   --pointRJ   R_   Rb   i   RL   R   Rk   t   pointsR   R   (   R?   R   t   process_tupleRP   R   R<   R   (   R   R   (    (    R   R>   8  s
    	c         C   s   |  i | d  |  i | t j  | d j o |  i | d  n" | d j o |  i | d  n t t	 | | i
 d    } t | i | i  i |  d  S(   Ni   s   -ps   1,2,3s   --points   4,5,6Re  (   R   R   t   lenRs   RL   RP   R   R   RM   t   mapRf  t   getattrRr  R   R   Rk   R   (   R   R   R   R   Rr  Rz  RL   (    (    R   Ry  ?  s    c      	   C   s/   |  i d d d g h  d d d g <g   d  S(   Ns   -p1,2,3s   --points   4,5,6Rx  i   i   i   i   i   i   (   i   i   i   (   i   i   i   (   R   R   (   R   (    (    R   t   test_callback_extra_argsK  s    (   R   R	   R>   Ry  R}  (    (    (    R   Rw  7  s   		t   TestCallbackMeddleArgsc           B   s,   t  Z d   Z d   Z d   Z d   Z RS(   Nc         C   sd   g  } t d d d  D]. } | t t |  d d d |  i d d q ~ } t d |  |  _	 d  S(   NiiRJ   R_   Rk   t   thingsR   (
   t   _[1]t   rangeR   R?   R!   R   t	   process_nR   R<   R   (   R   R  R   R   (    (    R   R>   Q  s    2c         C   s   t  | d  } | i } t |  | j  o |  i d | | f  n | i i	 | i g   } | i t | d | !  | i i |  | d | 5d  S(   Ni   s$   Expected %d arguments for %s option.i    (   RP   R   R]   Rr  t   rargsRz  R   R$   R   Rh  R   Rk   R   RM   t   largs(   R   R   R   R   Rr  R]   R  Rk   (    (    R   R  X  s    	c      	   C   s>   |  i d d d d d d g h  d d
 d g <d d	 g  d  S(   Ns   -1RG   s   -3RH   R   t   quxR  i   i   (   s   foo(   s   bars   bazR  (   R   R   (   R   (    (    R   t   test_callback_meddle_argsc  s    c         C   s/   |  i d d d g h  d d g <d g  d  S(   Ns   -2RG   s   --R  i   (   s   foos   --(   R   R   (   R   (    (    R   t#   test_callback_meddle_args_separatorh  s    (   R   R	   R>   R  R  R  (    (    (    R   R~  P  s   			t   TestCallbackManyArgsc           B   s#   t  Z d   Z d   Z d   Z RS(   Nc         C   sj   t  d d d d d d d |  i d d t  d	 d
 d d d d d |  i d d g } t d |  |  _ d  S(   Ns   -as   --appleRJ   R_   R]   i   RL   R   s   -bs   --bobi   RP   R   (   R?   R   t   process_manyR   R<   R   (   R   R   (    (    R   R>   n  s    'c         C   s   | d j o |  i | d  nd | d j o |  i | d  nC | d j o |  i | d  n" | d j o |  i | d  n d  S(   Ns   -aRG   RH   s   --applet   dingt   dongs   -bi   i   i   s   --bobifi*   i    (   s   foos   bar(   R  R  (   i   i   i   (   ifi*   i    (   R   R   R   R   (   R   R   R   R   Rr  (    (    R   R  u  s    c         C   sS   |  i d d d d d d d d d	 d
 d d d d g h  d d  <d d  <g   d  S(   Ns   -aRG   RH   s   --appleR  R  s   -bR0  t   2R%  s   --bobs   -666R   t   0Rd  t   bob(   R   R   R
   (   R   (    (    R   t   test_many_args  s    3(   R   R	   R>   R  R  (    (    (    R   R  m  s   		
t   TestCallbackCheckAbbrevc           B   s#   t  Z d   Z d   Z d   Z RS(   Nc         C   s/   t    |  _ |  i i d d d d |  i d  S(   Ns	   --foo-barRJ   R_   (   R<   R   R   Rn   t   check_abbrev(   R   (    (    R   R>     s    c         C   s   |  i | d  d  S(   Ns	   --foo-bar(   R   R   R   (   R   R   R   R   R   (    (    R   R    s    c         C   s   |  i d g h  g   d  S(   Ns   --foo(   R   R   (   R   (    (    R   t   test_abbrev_callback_expansion  s    (   R   R	   R>   R  R  (    (    (    R   R    s   		t   TestCallbackVarArgsc           B   sG   t  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   Nc         C   ss   t  d d d d d d d t  d d	 d
 d d t  d d d	 d d |  i d d g } t d t d |  |  _ d  S(   Ns   -aRL   RP   R]   i   Rk   R   s   -bRJ   Rj   RC   s   -cs
   --callbackR_   t   cR;   R   (   R?   R   t   variable_argsR   R   R=   R   (   R   R   (    (    R   R>     s    ?	c         C   s   |  i | d  j  d } g  } | i } x | o | d } | d  d j o t |  d j p5 | d  d j o) t |  d j o | d d j o Pq+ | i	 |  | d =q+ Wt
 | i | i |  d  S(   Ni    i   s   --i   R  (   R   Rs   R   R
   t   doneR   R  t   argRz  R   Rs  R   R   Rk   (   R   R   R   R   R   R  R  R  (    (    R   R    s    	 
Yc         C   sG   |  i d d d d d g h  d d <d	 d  <d
 d d g <g   d  S(   Ns   -a3s   -5s
   --callbackRG   RH   R   i   iRC   R  (   i   i(   R   R   R
   (   R   (    (    R   t   test_variable_args  s    $c         C   sP   |  i d d d d d d g h  d d  <d t <d	 d d d g <d g  d  S(
   Ns   -ct   37s   --t   xxxs   -bt   helloR   RC   R  (   R   R   R
   R   (   R   (    (    R   t%   test_consume_separator_stop_at_option  s    'c         C   sM   |  i d d d d d g h  d d  <d d  <d d d d g <d g  d  S(	   NR  s   -cRG   R  RH   R   RC   R  (   R   R   R
   (   R   (    (    R   t%   test_positional_arg_and_variable_args  s    'c         C   s>   |  i d d d g h  d d  <d t <d d g <g   d  S(   Ns   -cRG   s   -bR   RC   R  (   R   R   R
   R   (   R   (    (    R   t   test_stop_at_option  s    !c         C   s    |  i d d d d g d  d  S(   Ns   -cR%  s   -5s   -as   no such option: -5(   R   R)   (   R   (    (    R   t   test_stop_at_invalid_option  s    (	   R   R	   R>   R  R  R  R  R  R  (    (    (    R   R    s   						t   ConflictBasec           B   s   t  Z d   Z d   Z RS(   Nc      	   C   s@   t  d d d d d d d d g } t d	 t d
 |  |  _ d  S(   Ns   -vs	   --verboseRJ   RO   Rk   Rl   R   s   increment verbosityR;   R   (   R?   R   R   R=   R   R   (   R   R   (    (    R   R>     s    	c         C   s   d | i _ d  S(   Ni   (   R   R   t   show_version(   R   R   R   R   R   (    (    R   R    s    (   R   R	   R>   R  (    (    (    R   R    s   	t   TestConflictc           B   s2   t  Z d  Z d   Z d   Z d   Z d   Z RS(   s9   Use the default conflict resolution for Optik 1.2: error.c         C   sc   |  i | d
 h  d d <d |  i <d d <t d  } |  i | i d  |  i | i d	  d  S(   Ns   -vs	   --versionRJ   R_   R   s   show versions5   option -v/--version: conflicting option string(s): -vs    conflicting option string(s): -vs   -v/--version(   s   -vs	   --version(	   R   R%   R   R  t   OptionConflictErrorR    R   R   t	   option_id(   R   R   R    (    (    R   t   assert_conflict_error  s
    -	c         C   s   |  i |  i i  d  S(   N(   R   R  R   Rn   (   R   (    (    R   t   test_conflict_error  s    c         C   s&   t  |  i d  } |  i | i  d  S(   Ns   Group 1(   RF  R   R   RG  R  Rn   (   R   RG  (    (    R   t   test_conflict_error_group  s    c         C   s#   |  i |  i i d d  t d  d  S(   NRG   s'   invalid conflict_resolution value 'foo'(   s   foo(   R   R%   R   t   set_conflict_handlerR
   R   (   R   (    (    R   t   test_no_such_conflict_handler  s    (   R   R	   R   R  R  R  R  (    (    (    R   R    s
    			t   TestConflictResolvec           B   s>   t  Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   Nc      	   C   sI   t  i |   |  i i d  |  i i d d d d d |  i d d d  S(   Nt   resolves   -vs	   --versionRJ   R_   R   s   show version(   R  R>   R   R   R  Rn   R  (   R   (    (    R   R>     s    c         C   s   |  i i d  } |  i i d  } |  i i d  } |  i | | j  |  i | | j	  |  i | i d g  |  i | i	 d g  |  i | i d g  |  i | i	 g   |  i | i d g  d  S(   Ns   -vs	   --verboses	   --version(
   R   R   Rq   R  t   verbose_optt   version_optRs   R   Rw   Rv   (   R   R  R  R  (    (    R   t   test_conflict_resolve  s    c         C   s   |  i d g d  d  S(   Ns   -hs}   options:
  --verbose      increment verbosity
  -h, --help     show this help message and exit
  -v, --version  show version
(   R   R2   (   R   (    (    R   t   test_conflict_resolve_help   s    c         C   s,   |  i d g h  d d  <d d <g   d  S(   Ns   -vRl   R  i   (   R   R   R
   (   R   (    (    R   t   test_conflict_resolve_short_opt  s    c         C   s#   |  i d g h  d d <g   d  S(   Ns	   --verboseRl   i   (   R   R   (   R   (    (    R   t   test_conflict_resolve_long_opt  s    c         C   s/   |  i d d g h  d d <d d <g   d  S(   Ns	   --verboses	   --versionRl   i   R  (   R   R   (   R   (    (    R   t   test_conflict_resolve_long_opts  s    (   R   R	   R>   R  R  R  R  R  (    (    (    R   R    s   					t   TestConflictOverridec           B   s,   t  Z d   Z d   Z d   Z d   Z RS(   Nc         C   sv   t  d t  |  _ |  i i d  |  i i d d d d d d d	 d
 |  i i d d d d d d d d d	 d d  S(   NR;   R  s   -ns	   --dry-runRJ   Rj   Rk   t   dry_runR   s   don't do anythingR  R[   i*   s   dry run mode(   R   R=   R   R   R  Rn   (   R   (    (    R   R>     s    
c         C   sB   |  i i d  } |  i | i d g  |  i | i d g  d  S(   Ns	   --dry-runs   -n(   R   R   Rq   R   R   Rv   Rw   (   R   R   (    (    R   t   test_conflict_override_opts"  s    c         C   s   |  i d g d  d  S(   Ns   -hsX   options:
  -h, --help     show this help message and exit
  -n, --dry-run  dry run mode
(   R   R2   (   R   (    (    R   t   test_conflict_override_help'  s    c         C   s#   |  i d g h  d d <g   d  S(   Ns   -nR  i*   (   R   R   (   R   (    (    R   t   test_conflict_override_args.  s    (   R   R	   R>   R  R  R  (    (    (    R   R    s   	
		sS  usage: bar.py [options]

options:
  -a APPLE           throw APPLEs at basket
  -b NUM, --boo=NUM  shout "boo!" NUM times (in order to frighten away all the
                     evil spirits that cause trouble and mayhem)
  --foo=FOO          store FOO in the foo list for later fooing
  -h, --help         show this help message and exit
sS  usage: bar.py [options]

options:
  -a APPLE           throw APPLEs at basket
  --boo=NUM, -b NUM  shout "boo!" NUM times (in order to frighten away all the
                     evil spirits that cause trouble and mayhem)
  --foo=FOO          store FOO in the foo list for later fooing
  --help, -h         show this help message and exit
sW  Usage
=====
  bar.py [options]

options
=======
-a APPLE           throw APPLEs at basket
--boo=NUM, -b NUM  shout "boo!" NUM times (in order to frighten away all the
                   evil spirits that cause trouble and mayhem)
--foo=FOO          store FOO in the foo list for later fooing
--help, -h         show this help message and exit
s}  usage: bar.py [options]

options:
  -a APPLE           throw APPLEs at basket
  -b NUM, --boo=NUM  shout "boo!" NUM times (in order to
                     frighten away all the evil spirits
                     that cause trouble and mayhem)
  --foo=FOO          store FOO in the foo list for later
                     fooing
  -h, --help         show this help message and exit
t   TestHelpc           B   sY   t  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d	   Z
 RS(
   Nc         C   s   |  i d  |  _ d  S(   NiP   (   R   t   make_parserR   (   R   (    (    R   R>   g  s    c         C   s   t  d d d d d d d d d	 t  d
 d d d d d d d d d t  d d d d d d d d d g } t |  t i d <t d |  S(   Ns   -aRL   R   Rk   R   t   metavart   APPLER   s   throw APPLEs at baskets   -bs   --booRP   R   t   NUMse   shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem)s   --fooRJ   R   RG   s*   store FOO in the foo list for later fooingt   COLUMNSR   (   R?   R   R!   t   columnsR   t   environR   (   R   R  R   (    (    R   R  j  s    $!c         C   sO   t  i } z3 t i i d d  t  i d <|  i d g |  Wd  | t  i (Xd  S(   NRG   s   bar.pyi    s   -h(	   R*   R   R   R   R   R   R   R2   R'   (   R   R'   R   (    (    R   t   assertHelpEqualsy  s    
 c         C   s   |  i t  d  S(   N(   R   R  t   _expected_help_basic(   R   (    (    R   t	   test_help  s    c         C   s!   |  i i d  |  i t  d  S(   Ns   usage: %prog [options](   R   R   t	   set_usageR  R  (   R   (    (    R   t   test_help_old_usage  s    c         C   s    d |  i i _ |  i t  d  S(   Ni    (   R   R   R   t   short_firstR  t   _expected_help_long_opts_first(   R   (    (    R   t   test_help_long_opts_first  s    c         C   s    t    |  i _ |  i t  d  S(   N(   t   TitledHelpFormatterR   R   R   R  t   _expected_help_title_formatter(   R   (    (    R   t   test_help_title_formatter  s    c         C   s#   |  i d  |  _ |  i t  d  S(   Ni<   (   R   R  R   R  t   _expected_help_short_lines(   R   (    (    R   t   test_wrap_columns  s    c         C   s_   |  i i d  t |  i d d  } | i d d d d d |  i i |  |  i d	  d  S(
   Ns`   This is the program description for %prog.  %prog has an option group as well as single options.s   Dangerous OptionssZ   Caution: use of these options is at your own risk.  It is believed that some of them bite.s   -gRJ   Rj   R   s   Group option.sT  usage: bar.py [options]

This is the program description for bar.py.  bar.py has an option group as
well as single options.

options:
  -a APPLE           throw APPLEs at basket
  -b NUM, --boo=NUM  shout "boo!" NUM times (in order to frighten away all the
                     evil spirits that cause trouble and mayhem)
  --foo=FOO          store FOO in the foo list for later fooing
  -h, --help         show this help message and exit

  Dangerous Options:
    Caution: use of these options is at your own risk.  It is believed
    that some of them bite.

    -g               Group option.
(   R   R   t   set_descriptionRF  RG  Rn   RH  R  (   R   RG  (    (    R   t   test_help_description_groups  s    	(   R   R	   R>   R  R  R  R  R  R  R  R  (    (    (    R   R  f  s   									t   TestMatchAbbrevc           B   s   t  Z d   Z d   Z RS(   Nc         C   sA   |  i t d h  d d  <d d  <d d  <d d  < d  d  S(   Ns   --fs   --fozs   --foos   --fie(   R   R   t   _match_abbrevR
   (   R   (    (    R   t   test_match_abbrev  s    *c         C   sJ   d } h  d d  <d d  <d d  <} |  i t | | f d  t d  d  S(   Ns   --fs   --fozs   --foos   --fies,   ambiguous option: --f (--fie, --foo, --foz?)(   R   R
   t   wordmapR   R%   R  t   BadOptionError(   R   R  R   (    (    R   t   test_match_abbrev_error  s    !(   R   R	   R  R  (    (    (    R   R    s   	c          C   sO   t  i t } g  }  t |  D]* } | i d  o |  t | |  q q ~  S(   Nt   Test(	   R*   t   modulesR   t   modR  t   dirt   namet
   startswithR|  (   R  R  R  (    (    R   t   _testclasses  s    c          C   s:   t  i   }  x' t   D] } |  i t  i |   q W|  S(   N(   t   unittestt	   TestSuitet   suiteR  t	   testclasst   addTestt	   makeSuite(   R  R  (    (    R   R    s
    
 c           C   s   t  i t    d  S(   N(   RY  t	   run_suiteR  (    (    (    R   t	   test_main  s    t   __main__(   i   i    (K   R*   R   R   R  t	   cStringIOR-   t   pprintR   RY  t   optparseR?   Ru   t   IndentedHelpFormatterR  R<   t   OptionContainerRF  t   SUPPRESS_HELPR=   R@   R  R  R   R   R  R   R   t	   NameErrort	   ExceptionR    R   t   TestCaseR   R:   Ri   R   R   R   R   R   R   R   R   R   R	  R  R  R-  R6  R<  R@  RC  RR  Rb  Ro  Rw  R~  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R   t   main(C   RY  R  R    R  R  R   R:   R  R  Ro  Rw  R  R  R  R   R	  R   R  R   R   R   Ru   Ri   R  R  R   R  R   R  R~  Rb  R   R   R<   R  R6  R  R  R  R   R*   R   R  R<  R   R-  R   RF  R  R  R  RC  R@   R  R  R-   R   R@  R   R   R  R?   R=   R  R  R  RR  (    (    R   t   ?   sp   				a|=6	
3*N%:"'66
+U			