
    ;e                       d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlmZ d dlmZ  G d dej                  Z G d dej                  Z G d d	ej                  Zej         G d
 de                      Z G d de          Z G d de          Z G d de          Zd Z G d dej                  Z G d de          Z efZ! e de!i           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"          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"          Z. G d0 d1e"          Z/ G d2 d3e"          Z0 G d4 d5e"          Z1 G d6 d7e"          Z2 G d8 d9e"          Z3 G d: d;e"          Z4 G d< d=e"          Z5 G d> d?e"          Z6 G d@ dAe"          Z7 G dB dCe"          Z8 G dD dEe"          Z9 G dF dGe"          Z: G dH dIe"          Z; G dJ dKe"          Z< G dL dMe"          Z= G dN dOe"          Z> G dP dQe"          Z? G dR dSe"          Z@ G dT dUe"          ZA G dV dWe"          ZB G dX dYe"          ZC G dZ d[e"          ZD G d\ d]e"          ZE G d^ d_e"          ZF G d` dae"          ZG G db dce"          ZH G dd dee"          ZI G df dge"          ZJ G dh die"          ZK G dj dke"          ZL G dl dme"          ZM G dn doe"          ZN G dp dqe"          ZO G dr dse"          ZP G dt due"          ZQ G dv dwe"          ZR G dx dye"          ZS G dz d{e"          ZT G d| d}e"          ZU G d~ de"          ZV G d de"          ZW G d de"          ZX G d de"          ZY G d de"          ZZ G d de"          Z[ G d de"          Z\ G d de"          Z] G d de"          Z^ G d de"          Z_ G d de"          Z` G d de"          Za G d de"          Zb G d de"          Zc G d de"          Zd G d de"          Ze G d de"          Zf G d de"          Zg G d de"          Zh G d de"          Zi G d de"          Zj G d de"          Zk G d de"          Zl G d de"          Zm G d de"          Zn G d de"          Zo G d de"          Zp G d de"          Zq G d de"          Zr G d de"          Zs G d de"          Zt G d de"          Zu G d de"          Zv G d dee"          Zw G d dee"          Zx G dĄ de          Zy e            Zz e            Z{ G dƄ dǦ          Z| e|dȦ          Z} e|dɦ          Z~ e|dʦ          Z e|d˦          Z e|d̦          Z e|dͦ          Z G d΄ de          Z G dЄ dee"          Z G d҄ dee"          Z G dԄ dee"          Z G dք de          Zej         G d؄ dee"                      Zej         G dڄ dee"                      Zej         G d܄ dee"                      Zej         G dބ de                      Z G d de          Z G d de          Z G d de"          Z G d de"          Z G d de"          Z G d de          Z G d de"          Z G d de          Z G d de"          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d dee          Z G d dee          Z G d  dee          Z G d dee          Z G d dee          Z G d dee          Z G d d	ee          Z G d
 dee          Z G d dee          Z G d de          Z G d dee          Z G d dee          Z G d dee          Z G d dee          Z G d dee          Z G d dee          Z G d dee          Z G d dee          Z G d  d!e          Z G d" d#e          Z G d$ d%e          Z G d& d'e          ZefZ! ed(e!i           Z G d) d*e          Z G d+ d,e          Z G d- d.e          Z G d/ d0e          Z G d1 d2e          Z G d3 d4e          Z G d5 d6e          Z G d7 d8e          Z G d9 d:e          Z G d; d<e          Z G d= d>e          Z G d? d@e          Z G dA dBe          Z G dC dDe          Z G dE dFe          Z G dG dHe          Z G dI dJe          Z G dK dLe          Z G dM dNe          Z G dO dPe          Z G dQ dRe          Z G dS dTe          Z G dU dVe          Z G dW dXe          Z G dY dZe          Z G d[ d\e          Z G d] d^e          Z G d_ d`e          Z G da dbe          Z G dc dde          Z G de dfe          Z G dg dhe          Z G di dje          Z G dk dle          Z G dm dne          Z G do dpe          Z G dq dre          Z G ds dte          Z G du dve          Z G dw dxe          Z G dy dze          Z G d{ d|e          Z G d} d~e          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Zd Zedk    r ej                     dS dS (      N)	os_helper)mockc                   *     e Zd ZdZd fd	Zd Z xZS )StdIOBufferzReplacement for writable io.StringIO that behaves more like real file

    Unlike StringIO, provides a buffer attribute that holds the underlying
    binary data, allowing it to replace sys.stdout/sys.stderr in more
    contexts.
     
c                     |                     d          }t                                          t          j        t          j        |                    d|           d S )Nutf-8)newline)encodesuper__init__ioBufferedWriterBytesIO)selfinitial_valuer   	__class__s      )/usr/lib/python3.11/test/test_argparse.pyr   zStdIOBuffer.__init__   s]    %,,W55*2:m+D+DEE ' 	 	3 	3 	3 	3 	3    c                     |                                   | j        j                                                            d          S )Nr
   )flushbufferrawgetvaluedecoder   s    r   r   zStdIOBuffer.getvalue#   s3    

{''))00999r   )r   r   )__name__
__module____qualname____doc__r   r   __classcell__r   s   @r   r   r      sV         3 3 3 3 3 3
: : : : : : :r   r   c                       e Zd Zd Zd ZdS )StdStreamTestc                    t          j                    }t          j        d           5  t	          j        d          5  |                    dd           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nargparse._sys.exitr   foo)statusmessage)argparseArgumentParser
contextlibredirect_stderrr   patchexitr   parsers     r   test_skip_invalid_stderrz&StdStreamTest.test_skip_invalid_stderr*   s   (**&t,,	1 	1J+,,	1 	1 KKq%K000		1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s4   A9A!A9!A%	%A9(A%	)A99A= A=c                    t          j                    }|j        |j        t	          j        |j        dg          fD ]}|                     |          5  t          j	        d           5  t                      5 }t          j        |          5  t          j        d          5   |             |                     |                                d           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d S )N-h)funcr'   zusage:)r+   r,   print_usage
print_help	functoolspartial
parse_argssubTestr-   redirect_stdoutr   r.   r   r/   assertRegexr   )r   r2   r6   mocked_stderrs       r   test_skip_invalid_stdoutz&StdStreamTest.test_skip_invalid_stdout2   s   (**f/$88
 	F 	FD $''	F 	F*400	F 	F 		F "/*=99	F 	F 
/00	F 	F   !7!7!9!99EEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F	F 	Fs   D>*D'9D	C9#3C"C9"C&&C9)C&*C9-D	9C==D	 C=D	D'DD'DD'D>'D++D>.D+/D>>E	E	N)r   r   r    r3   r@    r   r   r%   r%   (   s7        1 1 1F F F F Fr   r%   c                       e Zd Zd ZdS )TestCasec                 \    |                      t          j                              }d|d<   d S )N80COLUMNS)enterContextr   EnvironmentVarGuardr   envs     r   setUpzTestCase.setUpG   s-     	 = ? ?@@Ir   N)r   r   r    rK   rA   r   r   rC   rC   E   s#            r   rC   c                   &    e Zd Zd Zd Zd Zd ZdS )TempDirMixinc                     t          j                    | _        t          j                    | _        t          j        | j                   d S N)tempfilemkdtemptemp_dirosgetcwdold_dirchdirr   s    r   rK   zTempDirMixin.setUpR   s7     (**y{{
r   c                 >   t          j        | j                   t          j        | j        d          D ]M\  }}}|D ]D}t          j        t           j                            | j        |          t          j	                   ENt          j        | j        d           d S )NF)topdownT)rS   rV   rU   walkrR   chmodpathjoinstatS_IWRITEshutilrmtree)r   rootdirsfilesnames        r   tearDownzTempDirMixin.tearDownW   s    
!#!F!F!F 	K 	KD$ K KdmT::DMJJJJKdmT*****r   c                     t           j                            | j        |          }t	          |dd          5 }|                    |           d d d            n# 1 swxY w Y   |S )Nwr
   encoding)rS   r[   r\   rR   openwrite)r   filename	file_pathfiles       r   create_writable_filez!TempDirMixin.create_writable_file^   s    GLL99	)S7333 	!tJJx   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s   AA!Ac                 j    t          j        |                     |          t          j                   d S rO   )rS   rZ   ro   r]   S_IREAD)r   rl   s     r   create_readonly_filez!TempDirMixin.create_readonly_filed   s*    
**844dlCCCCCr   N)r   r   r    rK   re   ro   rr   rA   r   r   rM   rM   O   sU             
+ + +  D D D D Dr   rM   c                       e Zd Zd ZdS )Sigc                 "    || _         || _        d S rO   )argskwargsr   rv   rw   s      r   r   zSig.__init__i   s    	r   Nr   r   r    r   rA   r   r   rt   rt   g   s#            r   rt   c                        e Zd Zd Zd Zd ZdS )NSc                 :    | j                             |           d S rO   )__dict__update)r   rw   s     r   r   zNS.__init__p   s    V$$$$$r   c                     t          | j                                                  }d                    d |D                       }t	          |           j        d|dS )Nz, c                     g | ]}d |z  S )z%s=%rrA   ).0tups     r   
<listcomp>zNS.__repr__.<locals>.<listcomp>u   s    EEEw}EEEr   ())sortedr}   itemsr\   typer   )r   sorted_items	kwarg_strs      r   __repr__zNS.__repr__s   s[    dm113344IIEEEEEFF	::...			::r   c                 B    t          |           t          |          k    S rO   )varsr   others     r   __eq__z	NS.__eq__x   s    DzzT%[[((r   N)r   r   r    r   r   r   rA   r   r   r{   r{   n   sA        % % %; ; ;
) ) ) ) )r   r{   c                       e Zd ZddZdS )ArgumentParserErrorNc                 x    t                               | |||           || _        || _        || _        || _        d S rO   )	Exceptionr   r*   stdoutstderr
error_code)r   r*   r   r   r   s        r   r   zArgumentParserError.__init__~   s<    4&&999$r   )NNNry   rA   r   r   r   r   |   s(        % % % % % %r   r   c           
      0   t          t          j        t                    st          t          j        t                    r | |i |S t          j        }t          j        }t                      t          _        t                      t          _        	 	  | |i |}t          t          |                    D ]}t          ||          }|t          j        u rt          |||           2|t          j        j	        u r&t          ||t          |dt                               k|t          j        u rt          |||           |t          j        j	        u r%t          ||t          |dt                               ||t          _        |t          _        S # t          $ r[}|j        }	t          j                                        }
t          j                                        }t          d|
||	          d d }~ww xY w# |t          _        |t          _        w xY w)Nr   
SystemExit)
isinstancesysr   r   r   listr   getattrsetattrr   BIN_STDOUT_SENTINELBIN_STDERR_SENTINELr   coder   r   )r;   rv   rw   
old_stdout
old_stderrresultkeyattrer   r   r   s               r   stderr_to_parser_errorr      s    #*k** +j[.Q.Q +z4*6*** JJCJCJ 	>Z000FDLL)) 	] 	]vs++3:%%FC4444SZ...FCXGZ)[)[\\\\SZ''FC4444SZ...FCXGZ)[)[\\\  


  	> 	> 	>6DZ((**FZ((**F%ffd4 49=>		>  

s&   C)F 
G8AG33G88G; ;Hc                   2     e Zd Z fdZ fdZ fdZ xZS )ErrorRaisingArgumentParserc                 X    t          t          |           j        }t          |g|R i |S rO   )r   r   r;   r   )r   rv   rw   r;   r   s       r   r;   z%ErrorRaisingArgumentParser.parse_args   s4    5t<<G
%jB4BBB6BBBr   c                 X    t          t          |           j        }t          |g|R i |S rO   )r   r   r0   r   )r   rv   rw   r0   r   s       r   r0   zErrorRaisingArgumentParser.exit   s4    /66;%d<T<<<V<<<r   c                 X    t          t          |           j        }t          |g|R i |S rO   )r   r   errorr   )r   rv   rw   r   r   s       r   r   z ErrorRaisingArgumentParser.error   s4    0$77=%e=d===f===r   )r   r   r    r;   r0   r   r"   r#   s   @r   r   r      so        C C C C C= = = = => > > > > > > > >r   r   c                       e Zd ZdZd ZdS )ParserTesterMetaclassa}  Adds parser tests using the class attributes.

    Classes of this type should specify the following attributes:

    argument_signatures -- a list of Sig objects which specify
        the signatures of Argument objects to be created
    failures -- a list of args lists that should cause the parser
        to fail
    successes -- a list of (initial_args, options, remaining_args) tuples
        where initial_args specifies the string args to be parsed,
        options is a dict that should match the vars() of the options
        parsed out of initial_args, and remaining_args should be any
        remaining unparsed arguments
    c                    |dk    rd S t          | d          st                      | _        t          | d          st          | _        d }d }d }d }d } G d	 d
t
                    }	|||fD ]}
||fD ]} |	| |
|           d S )NParserTestCaseparser_signatureparser_classc                 >    |D ]} | j         |j        i |j         dS )z(Add all arguments directly to the parserN)add_argumentrv   rw   )r2   argument_signaturessigs      r   	no_groupsz1ParserTesterMetaclass.__init__.<locals>.no_groups   s:    * = =##SX<<<<<= =r   c                 h    |                      d          }|D ]} |j        |j        i |j         dS )z4Add all arguments under a single group in the parserr(   N)add_argument_groupr   rv   rw   )r2   r   groupr   s       r   	one_groupz1ParserTesterMetaclass.__init__.<locals>.one_group   sM    --e44E* < <""CH;
;;;;< <r   c                     t          |          D ]4\  }}|                     d|z            } |j        |j        i |j         5dS )z0Add each argument in its own group to the parserzfoo:%iN)	enumerater   r   rv   rw   )r2   r   ir   r   s        r   many_groupsz3ParserTesterMetaclass.__init__.<locals>.many_groups   s^    #$788 < <311(Q,??""CH;
;;;;< <r   c                 ,    |                      |          S )z#Parse the args by passing in a list)r;   )r2   rv   s     r   listargsz0ParserTesterMetaclass.__init__.<locals>.listargs   s    $$T***r   c                     t           j        }|d         g|z   t           _        	 |                                 |t           _        S # |t           _        w xY w)z(Parse the args by defaulting to sys.argvr   )r   argvr;   )r2   rv   old_sys_argvs      r   sysargsz/ParserTesterMetaclass.__init__.<locals>.sysargs   sL    8L$Q(4/CH(((**'<''''s   A Ac                   &    e Zd Zd Zd Zd Zd ZdS )0ParserTesterMetaclass.__init__.<locals>.AddTestsc                    || _         || _        | j         j        }| j        j        }| j        | j        fD ]R}|j        }|||f}d                    |          }	|fd}
	 |	|
_        n# t          $ r Y nw xY wt          ||	|
           Sd S )N_c                      ||            d S rO   rA   r   	test_funcs     r   wrapperzJParserTesterMetaclass.__init__.<locals>.AddTests.__init__.<locals>.wrapper      !	$r   )_add_arguments_parse_argsr   test_failurestest_successesr\   	TypeErrorr   )r   
tester_clsadd_argumentsr;   add_arguments_nameparse_args_namer   	func_namenames	test_namer   s              r   r   z9ParserTesterMetaclass.__init__.<locals>.AddTests.__init__   s    &3##- %)%8%A""&"2";"&"4d6I!J < <I ) 2I%'9?JE #I09 ( ( ( (+4(($   J	7;;;;< <s   A&&
A32A3c                     |j         j        }|j         j        } |j        |i |}|                     ||j                   |S rO   )r   rv   rw   r   r   r   )r   testerrv   rw   r2   s        r   _get_parserz<ParserTesterMetaclass.__init__.<locals>.AddTests._get_parser  sM    .307,,d=f==##FF,FGGGr   c                     |                      |          }|j        D ]_}|                                }|                    t          |          5  |                    |           d d d            n# 1 swxY w Y   `d S )N)msg)r   failuressplitassertRaisesr   r;   )r   r   r2   args_strrv   s        r   r   z>ParserTesterMetaclass.__init__.<locals>.AddTests.test_failures  s    ))&11 & 0 0H#>>++D,,-@d,KK 0 0))$///0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0s   A11A5	8A5	c                     |                      |          }|j        D ]Z\  }}t          |t                    r|                                }|                     ||          }|                    ||           [d S rO   )r   	successesr   strr   r   assertEqual)r   r   r2   rv   expected_ns	result_nss         r   r   z?ParserTesterMetaclass.__init__.<locals>.AddTests.test_successes  s    ))&11)/)9 ? ?%D+!$,, ,#zz|| $ 0 0 > >I&&{I>>>>	? ?r   N)r   r   r    r   r   r   r   rA   r   r   AddTestsr      sP        < < <&  0 0 0? ? ? ? ?r   r   )hasattrrt   r   r   r   object)clsrd   basesbodydictr   r   r   r   r   r   r   r;   s               r   r   zParserTesterMetaclass.__init__   s   ###F s.// 	)#&55C sN++ 	:9C
	= 	= 	=
	< 	< 	<	< 	< 	<	+ 	+ 	+	( 	( 	()	? )	? )	? )	? )	?v )	? )	? )	?Z (K@ 	9 	9M'1 9 9
mZ88889	9 	9r   N)r   r   r    r!   r   rA   r   r   r   r      s2         _9 _9 _9 _9 _9r   r   r   c                       e Zd ZdZ ed          gZg dZd ed          fd ed          fd	 ed          fd
 ed          fd ed          fgZdS )TestOptionalsSingleDash1Test an Optional with a single-dash option string-x)r   a--foo-x --fooz-x -yr   Nx-x ar   -xaz-x -1-1z-x-1	r   r   r    r!   rt   r   r   r{   r   rA   r   r   r   r   3  s        ;;3t99+888H	RR$ZZZ	c	S				""t***	dIIIr   r   c                      e Zd ZdZ edd           eddd           ed	          gZg d
Zd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fgZdS )TestOptionalsSingleDashCombinedr   r   
store_trueactionz-yyystore_const*   r  const-z)r   r   r   r   z-x -zz-z -xz-yxz-yz az-yyyxz-yyyzaz-xyzaz-x=r   FN)r   yyyzT-zar   -z az-xzaz-xz az-x -zaz-x -z a-yz-x -yyy -zaz-x -yyy -z ar   rA   r   r   r   r   A  s       ;; 	D&&&F=333D		
C C CH 
RR%TT***+	rrDdd+++,	U,,,-	e---.	d,,,-	""t---.	22$#.../	BB43///0	rrErT***+	et,,,-	TrS1112	dc2223IIIr   r   c                       e Zd ZdZ ed          gZg dZd ed          fd ed          fd	 ed
          fd ed          fd ed          fgZdS )TestOptionalsSingleDashLongzATest an Optional with a multi-character single-dash option string-foo)r  r   r   z
-foo --fooz-foo -y-fooar   Nr(   z-foo ar   z-foo -1r   z-fo a-f ar   rA   r   r   r  r  [  s        KK3v;;-GGGH	RRD\\\	22#;;;	BB4LLL!	""+++	IIIr   r  c                   0   e Zd ZdZ ed           ed           ed          gZg dZd eddd          fd	 ed
dd          fd ed
dd          fd eddd          fd eddd          fd edd
d          fd eddd
          fgZdS )&TestOptionalsSingleDashSubsetAmbiguousz=Test Optionals where option strings are subsets of each other-f-foobar-foorab)r  r  -fo-foo bz-foobz-foobaz-foorar   N)ffoobarfoorabr  r   -fa-foaoar  ooa	-foobar a	-foorab ar   rA   r   r   r  r  i  s        GG3t99cc)nncc)nnEKKKH	RR$tD1112	c$t4445	Sd3334	d45556	""uT$7778	bb4D999:	bb4S999:IIIr   r  c                      e Zd ZdZ ed           ed          gZg dZd edd          fd ed	d          fd
 edd	          fd ed	d          fd edd	          fd ed	d          fd edd	          fgZdS ) TestOptionalsSingleDashAmbiguousz7Test Optionals that partially match but are not subsetsr  r  )r  r  r  r  r  r  r  r   N)r  r  z-foob ar   z-foor az-fooba az-foora ar"  r#  r   rA   r   r   r%  r%  y  s        AA3y>>33y>>:EEEH	RRtD)))*	BBc$///0	BBd3///0	RRs40001	RRtC0001	bbD1112	bbS1112IIIr   r%  c                       e Zd ZdZ edd          gZg dZd ed          fd	 ed
          fd ed
          fd ed          fgZdS )TestOptionalsNumericz(Test an Optional with a short opt stringr   onedest)r   r   z-1 --fooz-1 -yz-1 -1z-1 -2r   N)r(  z-1 ar   z-1az-1-2-2r   rA   r   r   r'  r'    s        223t%0001AAAH	RRD\\\		s		IIIr   r'  c                       e Zd ZdZ ed          gZg dZd ed          fd ed          fd	 ed          fd
 ed          fd ed          fgZdS )TestOptionalsDoubleDashz1Test an Optional with a double-dash option stringr   )r   r  r  r   z--foo -xz--foo --barr   Nr  z--foo ar   z--foo=az
--foo -2.5z-2.5z
--foo=-2.5r   rA   r   r   r-  r-    s        ;;3w<<.FFFH	RRD\\\	BB3KKK 	BB3KKK 	rrf~~~&	rrf~~~&IIIr   r-  c            
           e Zd ZdZ edd           ed          gZg dZd edd	
          fd edd
          fd edd	
          fd edd	
          fd edd	
          fd edd	
          fgZd	S )#TestOptionalsDoubleDashPartialMatchz7Tests partial matching with a double-dash option string--badgerr  r  z--bat)--bar--b--ba--b=2z--ba=4	--badge 5r   FN)badgerbatz--bat XX--badT--badg--badger   rA   r   r   r/  r/    s        AA 	J|,,,G HGGH	RRu$'''(	BBe---.	""Dd+++,	22Tt,,,-	BBd---.	RRt.../IIIr   r/  c                      e Zd ZdZ edd           ed          gZg dZd edd	
          fd edd
          fd edd
          fd edd	
          fd edd	
          fd edd	
          fd edd	
          fgZd	S )"TestOptionalsDoubleDashPrefixMatchz?Tests when one double-dash option string is a prefix of anotherr0  r  r  r3  )r1  r2  r3  r4  r5  r   FN)r6  baz--ba Xr8  z--ba=Xr9  Tr:  r;  r   rA   r   r   r=  r=    s        II 	J|,,,F >==H	RRu&&&'	22Us+++,	22Us+++,	""DT***+	22Td+++,	BBdt,,,-	RRt---.IIIr   r=  c                      e Zd ZdZ edd           ed           eddd	          gZg d
Zd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fgZdS )TestOptionalsSingleDoubleDashz<Test an Optional with single- and double-dash option stringsr  r  r  r1  -bazr  r  r  )r1  -fbarz-fbazz-bazf-b BBr   FNr  barbazTz--ba BrD  z
-f --bar Bz-f -bz-ba -fr   rA   r   r   r@  r@    s        FF 	D&&&GF=333
 A@@H	RR%Tt,,,-	rrDd---.	223D1112	rrDct4445	""t2.../	22$B///0IIIr   r@  c                   6   e Zd ZdZ edd          Z edd           ed           ed	d
d          gZg dZd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fgZ	dS )!TestOptionalsAlternatePrefixCharsz9Test an Optional with option strings with custom prefixes+:/Fprefix_charsadd_help+fr  r  ::bar/bazr  r  r  )r1  rB  rC  rD  r  --bar BrA  r5   --helpz+hz::helpz/helpr   NrE  T::ba BrD  
+f ::bar B+f /b/ba +f
r   r   r    r!   rt   r   r   r   r{   r   rA   r   r   rI  rI    s       CCs>>>D&&&GF=333
 qppH	RR%Tt,,,-	rrDd---.	223D1112	rrDct4445	""t2.../	22$B///0IIIr   rI  c                   6   e Zd ZdZ edd          Z edd           ed           ed	d
d          gZg dZd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fd eddd          fgZ	dS )*TestOptionalsAlternatePrefixCharsAddedHelpzWhen ``-`` not in prefix_chars, default operators created for help
       should use the prefix_chars in use rather than - or --
       http://bugs.python.org/issue9444rJ  TrK  rN  r  r  rO  rP  r  r  r  )r1  rB  rC  rD  r  rQ  rA  r   FNrE  rS  rD  rT  rU  rV  rW  rA   r   r   rY  rY    s       + + s===D&&&GF=333
 HGGH	RR%Tt,,,-	rrDd---.	223D1112	rrDct4445	""t2.../	22$B///0IIIr   rY  c            	           e Zd ZdZ edd          Z edd           edd           ed	d          gZg d
Zd eddd          fd eddd          fd eddd          fd eddd          fgZ	dS )2TestOptionalsAlternatePrefixCharsMultipleShortArgsz@Verify that Optionals must be called with their defined prefixesz+-FrK  r   r  r  z+yz+z)-wz-xyzz+xr  z+xyzr   r   yr
  Tz+y -xz+yz -xNrW  rA   r   r   r[  r[    s        JJsu===D&&&D&&&D&&&
  H 
RR%5E***+	rrDEU+++,	""ttu---.	22---.	IIIr   r[  c                       e Zd ZdZ eddddd          gZg dZd	 ed
          fd ed          fd ed          fd ed          fd ed          fgZdS )TestOptionalsShortLongz<Test a combination of single- and double-dash option strings-vz	--verbosez-nz--noisyr  r  )z--x --verbosez-Nr   z-v xr   F)verboseTNr   rA   r   r   r`  r`    s        FF 	D+tY|DDD 433H	RR	rr$ 	bb&&&'	rr$ 	BBt$$$%IIIr   r`  c                       e Zd ZdZ ed           edd          gZdgZd edd	
          fd ed	d
          fd edd
          fd edd
          fgZd	S )TestOptionalsDestz*Tests various means of setting destinationz	--foo-bar--bazzabbazr)  r   z--foo-bar fr  N)foo_barrf  z--baz ggz--foo-bar h --baz ihr   z--baz j --foo-bar kkjr   rA   r   r   rd  rd  -  s        443{++SSx-H-H-HIuH	3t4445	BBtC0001	3s ; ; ;<	3s ; ; ;<	IIIr   rd  c                       e Zd ZdZ ed           edd          gZdgZd edd	          fd
 edd	          fd edd	          fgZdS )TestOptionalsDefaultz*Tests specifying a default for an Optionalr   r  r  defaultr   r   Nr   r^  z-xxr   z-yyr^  r   rA   r   r   rm  rm  :  s        443t99cc$&;&;&;<uH	RR$"	SB 	TS!!!"IIIr   rm  c                   j    e Zd ZdZ ed          gZddgZd ed          fd ed          fgZdS )TestOptionalsNargsDefaultz7Tests not specifying the number of args for an Optionalr   r   r   Nr   r   r   rA   r   r   rr  rr  F  sX        AA3t99+T{H	RR$ZZZ	cIIIr   rr  c                   p    e Zd ZdZ edd          gZddgZd ed          fd	 edg          fgZdS )
TestOptionalsNargs1z&Tests specifying 1 arg for an Optionalr      nargsr   r   Nr   r   r   rA   r   r   rt  rt  Q  sb        003t1---.T{H	RR$ZZZ	seIIIr   rt  c                   r    e Zd ZdZ edd          gZg dZd ed          fd	 eg d
          fgZdS )TestOptionalsNargs3z'Tests specifying 3 args for an Optionalr      rv  )r   r   r   -x a ba -xa -x br   Nr   z-x a b cr   bcr   rA   r   r   ry  ry  \  si        113t1---.>>>H	RR$ZZZ	RR///***+IIIr   ry  c                      e Zd ZdZ edd           eddd           eddd	
           eddedd          gZdgZd eddd	d          fd eddd	d          fd eddd	d          fd eddd	d          fd eddd	d          fd edddd          fd edddd          fd eddd	d          fd eddd	d          fg	Z	dS )TestOptionalsNargsOptionalz0Tests specifying an Optional arg for an Optionalr\  ?rv  r   r  )rw  r  r  spamrw  ro  r  4284)rw  r   r  ro  2r   NT   rg   r   r^  r
  z-w 2z-x 2z-y 2z-z 2   
r   r   r    r!   rt   intr   r   r{   r   rA   r   r   r  r  g  ss       :: 	DD2&&&DV,,,D#T4@@@	 uH	RR$$&B///0	rrDDFb1112	cTVr2223	rrDB&B///0	dcVr2223	rrDDDB///0	ddcR0001	rrDDFb1112	ddf2223
IIIr   r  c                   "   e Zd ZdZ edd           eddd          gZdgZd	 ed
d          fd eg d          fd edgd          fd eddgd          fd ed
g           fd ed
dg          fd ed
ddg          fgZd
S )TestOptionalsNargsZeroOrMore?Tests specifying args for an Optional that accepts zero or morer   *rv  r  r  r  r   r   Nrp  r   r{  r  -y a-y a br   rA   r   r   r  r  ~  s       II 	DDV,,, uH	RR$&!!!"	rrB&!!!"	sev&&&'	22c
f---.	rrDB 	dse$$$%	22c
+++,IIIr   r  c            
           e Zd ZdZ edd           eddd          gZg dZd	 ed
d          fd edgd          fd eddgd          fd ed
dg          fd ed
ddg          fgZd
S )TestOptionalsNargsOneOrMorez>Tests specifying args for an Optional that accepts one or morer   +rv  r  r  r  )r   r   r  r|  za -y br   Nrp  r   r   r{  r  r  r  r   rA   r   r   r  r    s        HH 	DDV,,, 322H	RR$&!!!"	sev&&&'	22c
f---.	dse$$$%	22c
+++,IIIr   r  c            
          e Zd ZdZ edd           ede ed                    gZg dZd	 e	d
d
          fd e	dd
          fd e	dd
          fd e	d
d          fd e	d
d          fd e	dd          fgZ
d
S )TestOptionalsChoicesz,Tests specifying the choices for an Optionalr  abcchoicesz-g   r   r  )r   z-f dz-fadz-gaz-g 6r   N)r  rh  r  r   z-f cr  z-g 0r   z-g 03rz  z-fb -g4r     r   r   r    r!   rt   r  ranger   r   r{   r   rA   r   r   r  r    s        66 	D%   DsEE!HH---/ 433H	RR$$ 	cT"""#	cT"""#	da!	""tq///"	BBNNN#IIIr   r  c                   p    e Zd ZdZ eded          gZddgZd ed	          fd
 ed	          fgZ	dS )TestOptionalsRequiredz)Tests an optional action that is requiredr   Tr   requiredr   r   -x 1ru  r   z-x42r  Nr  rA   r   r   r  r    sh        33 	DsT*** RyH	a	bIIIr   r  c                   n    e Zd ZdZ edd          gZddgZd ed	          fd
 ed	          fgZdS )TestOptionalsActionStorez&Tests the store action for an Optionalr   storer  r   r|  r   Nr   z-xfoor(   r   rA   r   r   r  r    s`        003tG4445V}H	RR$ZZZ	""u+++IIIr   r  c                   n    e Zd ZdZ edde          gZdgZd ed          fd ee          fgZ	dS )	TestOptionalsActionStoreConstz,Tests the store_const action for an Optionalr  r  r  r   r   Nr^  )
r   r   r    r!   rt   r   r   r   r{   r   rA   r   r   r  r    s`        663tMHHHIuH	RR$ZZZ	rrF|||IIIr   r  c                   n    e Zd ZdZ edd          gZg dZd ed          fd ed	          fgZd
S )TestOptionalsActionStoreFalsez,Tests the store_false action for an Optionalr  store_falser  )r   r  r  r   T)r
  FNr   rA   r   r   r  r    sb        663tM:::;###H	RR$ZZZ	rrE{{{IIIr   r  c                   n    e Zd ZdZ edd          gZg dZd ed          fd ed	          fgZd
S )TestOptionalsActionStoreTruez+Tests the store_true action for an Optionalz--appler  r  )r   z	--apple=bz	--apple br   F)appleTNr   rA   r   r   r  r    sb        553y>>>?...H	RRe___	BBTNNN#IIIr   r  c                       e Zd ZdZ edej                  gZddgZd e	d          fd e	d	          fd
 e	d          fd e	d          fd e	d	          fgZ
d ZdS )TestBooleanOptionalActionzTests BooleanOptionalActionr   r  	--foo bar	--foo=barr   Nr  T--no-fooFz--foo --no-fooz--no-foo --fooc                 $   t          j                    }|                     t                    5 }|                    ddt           j                   d d d            n# 1 swxY w Y   |                     dt          |j                             d S )Nr   Tr  r  z*got an unexpected keyword argument 'const')	r+   r,   r   r   r   BooleanOptionalActionassertInr   	exceptionr   r2   cms      r   
test_constz$TestBooleanOptionalAction.test_const  s    (**y)) 	\RtH<Z[[[	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	\ 	BCDUDUVVVVVs   #AA!$A!)r   r   r    r!   rt   r+   r  r   r   r{   r   r  rA   r   r   r  r    s        %%3wx/MNNNO[)H	RRD\\\	"",,,	RRE]]]#	22%===)	22$<<<(IW W W W Wr   r  c                   x    e Zd ZdZ eddej                  gZdgZd e	d          fd e	d          fgZ
d	S )
!TestBooleanOptionalActionRequiredz$Tests BooleanOptionalAction requiredr   T)r  r  r   r  r  FN)r   r   r    r!   rt   r+   r  r   r   r{   r   rA   r   r   r  r     si        .. 	Gd8+IJJJ tH	"",,,	RRE]]]#IIIr   r  c                       e Zd ZdZ edd          gZg dZd ed          fd	 ed
g          fd ed
dg          fgZdS )TestOptionalsActionAppend'Tests the append action for an Optionalre  appendr  r   re  a --baz	--baz a br   NrG  --baz ar   --baz a --baz br  r   rA   r   r   r  r    s}        113wx8889555H	RRD\\\	BBC5MMM"	BBC:.../IIIr   r  c                       e Zd ZdZ edddg          gZg dZd edg          fd	 edd
g          fd eg d          fgZdS )$TestOptionalsActionAppendWithDefaultr  re  r  r8  r  ro  r  r   r  r  r   r  )r8  r   r  Nr   rA   r   r   r  r    s        113wx#GGGH555H	RRSE]]]	BBC:&&&'	BB???3334IIIr   r  c                   &   e Zd ZdZ edd           edd           edd           edd          gZg d	Zd
 edddd          fd edgddd          fd eddgdd          fd edddd          fd edddd          fgZdS )!TestConstActionsMissingConstKwargz=Tests that const gets default value of None when not providedr  append_constr  r   -br  r1  )z-f vr  r  r   N)r  r(   r  rF  r   rA   r   r   r  r  $  s       GG 	D(((GN+++D'''GM***	 211H	RR$DDd3334	rrTF$7778	""t$4T:::;	rrDdd5556	""t48889IIIr   r  c            	           e Zd ZdZ edde           eddd          gZg d	Zd
 ed          fd eeg          fd eededg          fgZ	dS )TestOptionalsActionAppendConst-Tests the append_const action for an Optionalr  r  r  -cr  r  r  r*  r   r  za -cz-bxz-b xr   Nr  -b -cx -b -cyzr   yz
r   r   r    r!   rt   r   r   r   r{   r   rA   r   r   r  r  7  s        77 	Dy999D,,, 211H	RR$ZZZ	rrYK   !	22CD ABBBCIIIr   r  c            
           e Zd ZdZ eddedg           eddd	          gZg d
Zd edg          fd edeg          fd edededg          fgZ	dS ))TestOptionalsActionAppendConstWithDefaultr  r  r  r8  )r  r  ro  r  r  r  r  r  r   r  r  r   r  Nr  rA   r   r   r  r  F  s        77 	Dy3%HHHD,,, 211H	RR3%[[[	rrS)$%%%&	22ii FGGGHIIIr   r  c                   n    e Zd ZdZ edd          gZg dZd ed          fd ed	          fgZdS )
TestOptionalsActionCountz&Tests the count action for an Optionalr   countr  )r   r   z-x bz	-x a -x br   Nr   ru  r   rA   r   r   r  r  U  sa        003tG4445111H	RR$ZZZ	rrAwwwIIIr   r  c            	           e Zd ZdZ ed           ed           edd          gZddgZd	 ed
d
d          fd edd
d          fd ed
dd          fd edd
d          fgZd
S )"TestOptionalsAllowLongAbbreviationz2Allow long options to be abbreviated unambiguouslyr   z--foobazz--foobler  r  z--foob 5z--foobr   NF)r(   foobazfooblez--foo 77z	--fooba ar   z--foobl --foo grh  Tr   rA   r   r   r  r  `  s        << 	GJJ|,,,
 H%H	RRDe4445	BB3tE:::;	bbT#e<<<=	BB3tDAAAB	IIIr   r  c                       e Zd ZdZ ed          Z ed           edd           ed          gZg d	Zd
 eddd          fd eddd          fd eddd          fgZ	dS )%TestOptionalsDisallowLongAbbreviation1Do not allow abbreviations of long options at allFallow_abbrevr   z--foodler  r  z--foonly)z-foon 3z--foon 3z--foodz--food --foo 2r   Nr(   foodlefoonlyz--foo 33z--foonly 7 --foodle --foo 2r  Tr  rW  rA   r   r   r  r  q  s        ;;s...GJ|,,,J
 CBBH	RRDt4445	BB3uT:::;	&s4(L(L(LMIIIr   r  c                       e Zd ZdZ edd          Z ed           edd           ed	          gZg d
Zd eddd          fd eddd          fd eddd          fgZ	dS )0TestOptionalsDisallowLongAbbreviationPrefixCharszBDisallowing abbreviations works with alternative prefix charactersr  FrL  r  z++fooz++foodler  r  z++foonly)z+foon 3z++foon 3z++foodz++food ++foo 2r   Nr  z++foo 3r  z++foonly 7 ++foodle ++foo 2r  Tr  rW  rA   r   r   r  r    s        LLs%@@@GJ|,,,J
 CBBH	RRDt4445	BB3uT:::;	&s4(L(L(LMIIIr   r  c            
          e Zd ZdZ ed          Z ed           edd          gZddgZd	 ed
d
          fd edd
          fd edd
          fd ed
d          fd edd          fd edd          fgZ	d
S )/TestDisallowLongAbbreviationAllowsShortGroupingr  Fr  z-rr  r  r  z-c -rr   Nrr  z-rar   z-rccccz-ccr  z-cc -raz-ccrccrW  rA   r   r   r  r    s        ;;s...D		D!!! gH	RR$$ 	SD!!!"	dd###$	TQ 	BBNNN#	22???#IIIr   r  c            
          e Zd ZdZ edd          Z ed           edd          gZdd	gZd
 edd          fd edd          fd edd          fd edd          fd edd          fd edd          fgZ	dS )5TestDisallowLongAbbreviationAllowsShortGroupingPrefixzEShort option grouping works with custom prefix and allow_abbrev=Falser  Fr  z+rz+cr  r  z+c +rr   Nr  z+rar   z+rccr  z+ccr  z+cc +raz+ccrccrW  rA   r   r   r  r    s        OOs%@@@D		D!!! gH	RR$$ 	SD!!!"	dd###$	TQ 	BBNNN#	22???#IIIr   r  c                   P    e Zd ZdZ ed          gZg dZd ed          fgZdS )TestPositionalsNargsNonez,Test a Positional that doesn't specify nargsr(   r   r   a br   r  Nr   rA   r   r   r  r    sH        663u::,   H	bbSkkkIIIr   r  c                   V    e Zd ZdZ edd          gZg dZd edg          fgZdS )	TestPositionalsNargs1z.Test a Positional that specifies an nargs of 1r(   ru  rv  r  r   r  Nr   rA   r   r   r  r    sR        883uA.../   H	bbcUmmmIIIr   r  c                   X    e Zd ZdZ edd          gZg dZd eddg	          fgZd
S )TestPositionalsNargs2z.Test a Positional that specifies an nargs of 2r(   r  rv  )r   r   r   a b cr  r   r  r  Nr   rA   r   r   r   r     sW        883uA.../'''H	Sz"""#IIIr   r   c                       e Zd ZdZ edd          gZdgZd eg           fd edg          fd	 edd
g          fgZdS )TestPositionalsNargsZeroOrMorez0Test a Positional that specifies unlimited nargsr(   r  rv  r   r   r  r   r  r  Nr   rA   r   r   r  r    sy        ::3uC0001vH	RRBZZZ	bbcUmmm	Sz"""#IIIr   r  c                       e Zd ZdZ eddd          gZdgZd ed          fd	 ed	g          fd
 ed	dg          fgZdS )%TestPositionalsNargsZeroOrMoreDefaultz>Test a Positional that specifies unlimited nargs and a defaultr(   r  rF  r  r   r   r  r   r  r  Nr   rA   r   r   r  r    s{        HH3uC???@vH	RRE]]]	bbcUmmm	Sz"""#IIIr   r  c                   t    e Zd ZdZ edd          gZddgZd edg          fd	 edd
g          fgZdS )TestPositionalsNargsOneOrMorez2Test a Positional that specifies one or more nargsr(   r  rv  r   r   r   r  r  r  Nr   rA   r   r   r  r    si        <<3uC0001DzH	bbcUmmm	Sz"""#IIIr   r  c                   n    e Zd ZdZ edd          gZddgZd ed	          fd
 ed
	          fgZdS )TestPositionalsNargsOptionalzTests an Optional Positionalr(   r  rv  r   r  r   Nr  r   r   rA   r   r   r	  r	    s`        &&3uC0001e}H	RRD\\\	bbSkkkIIIr   r	  c                   p    e Zd ZdZ eddd          gZddgZd ed	          fd
 ed
	          fgZdS )#TestPositionalsNargsOptionalDefaultz1Tests an Optional Positional with a default valuer(   r  r  r  r   r  r   r  r   Nr   rA   r   r   r  r  	  sb        ;;3uC<<<=e}H	RRBZZZ	bbSkkkIIIr   r  c                   r    e Zd ZdZ edded          gZg dZd ed	          fd
 ed	          fgZ	dS ),TestPositionalsNargsOptionalConvertedDefaultznTests an Optional Positional with a default value
    that needs to be converted to the appropriate type.
    r(   r  r  )rw  r   ro  )r   r  1 2r   r  r  1ru  Nr  rA   r   r   r  r    sp         
 	E3555 $##H	RRBZZZ	bbQiiiIIIr   r  c                   f    e Zd ZdZ ed           ed          gZg dZd edd          fgZd	S )
TestPositionalsNargsNoneNonez-Test two Positionals that don't specify nargsr(   rF  )r   r   r   r  r  r   r  r(   rF  Nr   rA   r   r   r  r  #  sX        773u::ss5zz2'''H	s$$$%IIIr   r  c                   l    e Zd ZdZ ed           edd          gZg dZd edd	g
          fgZdS )TestPositionalsNargsNone1z6Test a Positional with no nargs followed by one with 1r(   rF  ru  rv  )r   r   r   r  r  r   r  r  Nr   rA   r   r   r  r  -  sa        @@3u::ss5':':':;***H	s&&&'IIIr   r  c                   n    e Zd ZdZ edd           ed          gZg dZd edd	gd
          fgZdS )TestPositionalsNargs2Nonez8Test a Positional with 2 nargs followed by one with noner(   r  rv  rF  r   r   r   r  a b c dr  r   r  r  r  Nr   rA   r   r   r  r  7  sc        BB3uA...E

;333H	""#s---.IIIr   r  c                       e Zd ZdZ ed           edd          gZddgZd edg 	          fd
 eddg	          fd edddg	          fgZdS )"TestPositionalsNargsNoneZeroOrMorez>Test a Positional with no nargs followed by one with unlimitedr(   rF  r  rv  r   r   r   r  r  r  r  r  Nr   rA   r   r   r  r  A  s        HH3u::ss5'<'<'<=G}H	bbSb!!!"	s&&&'	""3*---.IIIr   r  c                       e Zd ZdZ ed           edd          gZg dZd edd	g
          fd edd	dg
          fgZdS )!TestPositionalsNargsNoneOneOrMorez@Test a Positional with no nargs followed by one with one or morer(   rF  r  rv  r   r   r   r  r   r  r  r  r  Nr   rA   r   r   r  r  M  s|        JJ3u::ss5'<'<'<=!!!H	s&&&'	""3*---.IIIr   r  c                       e Zd ZdZ ed           edd          gZg dZd edd	          fd
 edd	          fgZdS ) TestPositionalsNargsNoneOptionalz@Test a Positional with no nargs followed by one with an Optionalr(   rF  r  rv  r   r   r  r   Nr  r  r  r   rA   r   r   r  r  X  sv        JJ3u::ss5'<'<'<=%%%H	bbSd###$	s$$$%IIIr   r  c                       e Zd ZdZ edd           ed          gZddgZd eg d	          fd
 edgd	          fd eddgd	          fgZdS )"TestPositionalsNargsZeroOrMoreNonez@Test a Positional with unlimited nargs followed by one with noner(   r  rv  rF  r   r   r   r  r  r  r  r  Nr   rA   r   r   r"  r"  c  s        JJ3uC000##e**=G}H	bbRS!!!"	u#&&&'	""#s---.IIIr   r"  c                       e Zd ZdZ edd           ed          gZg dZd edgd	
          fd edd	gd
          fgZdS )!TestPositionalsNargsOneOrMoreNonezBTest a Positional with one or more nargs followed by one with noner(   r  rv  rF  r  r  r   r  r  r  r  Nr   rA   r   r   r$  r$  o  s|        LL3uC000##e**=!!!H	u#&&&'	""#s---.IIIr   r$  c                       e Zd ZdZ eddd           ed          gZg dZd edd	          fd
 edd	          fgZdS ) TestPositionalsNargsOptionalNonezBTest a Positional with an Optional nargs followed by one with noner(   r  r  r  rF  r   r   r  r  r  Nr   rA   r   r   r&  r&  z  sx        LL3uC<<<cc%jjI%%%H	bbRS!!!"	s$$$%IIIr   r&  c                       e Zd ZdZ edd           edd          gZg dZd ed	d
gg           fd ed	d
gdg          fgZdS )TestPositionalsNargs2ZeroOrMorez=Test a Positional with 2 nargs followed by one with unlimitedr(   r  rv  rF  r  r  r  r   r  r  r  r  Nr   rA   r   r   r(  r(    s        GG3uA...E0E0E0EF!!!H	Szr***+	""#s#///0IIIr   r(  c                   t    e Zd ZdZ edd           edd          gZg dZd ed	d
gdg          fgZdS )TestPositionalsNargs2OneOrMorez?Test a Positional with 2 nargs followed by one with one or morer(   r  rv  rF  r  )r   r   r   r  r  r   r  r  r  Nr   rA   r   r   r*  r*    sl        II3uA...E0E0E0EF(((H	""#s#///0IIIr   r*  c                       e Zd ZdZ edd           edd          gZg dZd ed	d
gd          fd ed	d
gd          fgZdS )TestPositionalsNargs2Optionalz7Test a Positional with 2 nargs followed by one optionalr(   r  rv  rF  r  )r   r   r   r  r  r   r  Nr  r  r  r   rA   r   r   r,  r,    s        AA3uA...E0E0E0EF,,,H	Szt,,,-	""#s---.IIIr   r,  c                       e Zd ZdZ edd           edd          gZddgZd	 eg d	g
          fd ed	gdg
          fd ed	dgdg
          fgZdS )TestPositionalsNargsZeroOrMore1z=Test a Positional with unlimited nargs followed by one with 1r(   r  rv  rF  ru  r   r   r   r  r  r  r  r  Nr   rA   r   r   r.  r.    s        GG3uC000##e12E2E2EFGH	bbRcU###$	u3%((()	""#s#///0IIIr   r.  c                       e Zd ZdZ edd           edd          gZg dZd ed	gd
g          fd ed	d
gdg          fgZdS )TestPositionalsNargsOneOrMore1z?Test a Positional with one or more nargs followed by one with 1r(   r  rv  rF  ru  r  r  r   r  r  r  r  Nr   rA   r   r   r0  r0    s        II3uC000##e12E2E2EF!!!H	u3%((()	""#s#///0IIIr   r0  c                       e Zd ZdZ edd           edd          gZg dZd ed	dg
          fd eddg
          fgZd	S )TestPositionalsNargsOptional1z?Test a Positional with an Optional nargs followed by one with 1r(   r  rv  rF  ru  r   r   Nr  r  r  r   rA   r   r   r2  r2    s        II3uC000##e12E2E2EF%%%H	bbTu%%%&	s&&&'IIIr   r2  c                       e Zd ZdZ ed           edd           edd          gZg dZd	 ed
g dg          fd ed
dgdg          fgZdS )#TestPositionalsNargsNoneZeroOrMore1z=Test three Positionals: no nargs, unlimited nargs and 1 nargsr(   rF  r  rv  rG  ru  r  r  r   r  r(   rF  rG  r  r  Nr   rA   r   r   r4  r4    s        GG 	E

EE
 "!!H	s.../	""3%cU3334IIIr   r4  c                       e Zd ZdZ ed           edd           edd          gZg dZd	 ed
dgdg          fd ed
ddgdg          fgZdS )"TestPositionalsNargsNoneOneOrMore1z?Test three Positionals: no nargs, one or more nargs and 1 nargsr(   rF  r  rv  rG  ru  )r   r   r   r  r  r   r  r  r5  r  dNr   rA   r   r   r7  r7    s        II 	E

EE
 '&&H	""3%cU3334	BB3S#JSE:::;IIIr   r7  c                       e Zd ZdZ ed           eddd           edd	          gZg d
Zd edddg          fd edddg          fgZdS )!TestPositionalsNargsNoneOptional1z;Test three Positionals: no nargs, optional narg and 1 nargsr(   rF  r        ?r  rG  ru  rv  r  r  r   r  r5  r  r  Nr   rA   r   r   r:  r:    s        EE 	E

Ee,,,E
 "!!H	sC51112	""#C51112IIIr   r:  c                       e Zd ZdZ edd           eddd          gZdd	gZd
 edd          fd edd          fd edd          fgZdS )$TestPositionalsNargsOptionalOptionalzTest two optional nargsr(   r  rv  rF  r  r  r   r  r   Nr  r   r  r  r   rA   r   r   r=  r=    s        !! 	EEb))) !H	RRDb!!!"	bbSb!!!"	s$$$%IIIr   r=  c            	           e Zd ZdZ edd           edd          gZdgZd ed	g 
          fd edg 
          fd eddg
          fd edddg
          fgZd	S )&TestPositionalsNargsOptionalZeroOrMorez1Test an Optional narg followed by unlimited nargsr(   r  rv  rF  r  r   r   Nr  r   r  r  r  r  r   rA   r   r   r?  r?    s        ;;3uC000##e32G2G2GHyH	RRDb!!!"	bbSb!!!"	s&&&'	""3*---.	IIIr   r?  c                       e Zd ZdZ edd           edd          gZddgZd	 ed
d	g          fd ed	dg          fd ed	ddg          fgZd
S )%TestPositionalsNargsOptionalOneOrMorez3Test an Optional narg followed by one or more nargsr(   r  rv  rF  r  r   r   r   Nr  r  r  r  r  r   rA   r   r   rA  rA    s        ==3uC000##e32G2G2GHG}H	bbTu%%%&	s&&&'	""3*---.IIIr   rA  c                       e Zd ZdZ ed ed                    gZg dZd ed          fd ed          fgZ	d	S )
TestPositionalsChoicesStringz&Test a set of single-character choicesr  abcdefgr  r   r   ri  r  efr   r  rh  N)
r   r   r    r!   rt   setr   r   r{   r   rA   r   r   rC  rC    sj        003vss9~~>>>?---H	bbclll	bbclllIIIr   rC  c                       e Zd ZdZ ede ed                    gZg dZd e	d          fd	 e	d
          fgZ
dS )TestPositionalsChoicesIntzTest a set of integer choicesr     r  rE  4r  rG  15   Nr  rA   r   r   rJ  rJ  '  sl        ''3vCrCCCD---H	bbajjj	rrr{{{IIIr   rJ  c                   v    e Zd ZdZ edd           eddd          gZg dZd ed	d
dgg          fgZdS )TestPositionalsActionAppendzTest the 'append' actionr  r  r  r  )r  rw  r  r  r   r  r  rG  Nr   rA   r   r   rP  rP  2  sv        "" 	F8$$$F81--- 433H	""3c
+,,,-IIIr   rP  c                       e Zd ZdZ edd           eddd          gZd	d
gZd edd          fd edd          fd edd          fd edd          fgZdS )"TestOptionalsNumericAndPositionalsz;Tests negative number args when numeric options are presentr   r  rv  z-4r^  r  r*  r  r+  z-315r   NFrp  r   Tz-4 ar   rA   r   r   rR  rR  B  s        EE 	CsDs<000 f~H	RR$%   !	bb3%   !	rrDD!!!"	cT"""#	IIIr   rR  c            	           e Zd ZdZ edd           eddd          gZd	gZd
 edd          fd edd          fd edd          fd edd          fd edd          fgZdS )(TestOptionalsAlmostNumericAndPositionalszBTests negative number args when almost numeric options are presentr   r  rv  z-k4r^  r  rS  z-k3r   NFrp  r+  r   Tz-k4 ar   rA   r   r   rU  rU  R  s        LL 	CsEL111 wH	RR$%   !	rrDE"""#	bb3%   !	TT"""#	""sd###$IIIr   rU  c                   D   e Zd Z edd           eddd          gZdgZdg edd	
          fdg edd	
          fdg edd	
          fddg ed	d
          fddg ed	d
          fddg ed	d
          fdg ed	d
          fdg ed	d
          fgZd	S )$TestEmptyAndSpaceContainingArgumentsr   r  rv  r  z--yyyr^  r)  r   Nrp  za badgerz	-a badgerz--yyy=a badgerz--yyy=-a badger)r   r   r    rt   r   r   r{   r   rA   r   r   rW  rW  c  s         	CsD'$$$ vH
rrB$ 
rrJ$///0
[D1112
RR$"%%%&

	RR$*5556
	bb4;7778
	RR$*5556
	bb4;7778	IIIr   rW  c                   <   e Zd Z ed          Z edddd           edd	ed
           eddd          gZddgZd edd
d          fd edd
d          fd edd
d          fd eddd          fd edd
d          fd edd
d          fgZ	dS ) TestPrefixCharacterOnlyArgumentsz-+rL  -r   r  r6  )r*  rw  r  r  r^  r  )r*  r   ro  z-+-r
  r  rS  r  z+ -r   NFr]  z- Xr8  z+ -3Tz- ===z===)
r   r   r    rt   r   r  r   r   r{   r   rA   r   r   rY  rY  v  s       s---CcH555CcR000EL111
 e}H	RR$"&&&'	bb8rU+++,	SB%((()	dbE***+	TR4((()	""ue,,,-IIIr   rY  c                       e Zd ZdZ edd           edd          gZg Zd edg           fd eg g           fd	 ed
gg           fd ed
gdg          fd
 edd
g          fd eg d
g          fd edgd
g          fgZdS )TestNargsZeroOrMorer  r   r  rv  r^  r   Nrp  r   r   z	-x a -- br  r|  r}  r   rA   r   r   r^  r^    s        II3t3///S1D1D1DEH	RR$"	rrB"~~~	ser"""#	bbC5SE***+	bb4C5!!!"	bSE"""#	22#'''(IIIr   r^  c            	           e Zd ZdZ ed           edd           ed          gZg dZd edg d	
          fd edg d
          fd edg dd	
          fd edddgd	
          fgZd	S )TestNargsRemainderz2Tests specifying a positional with nargs=REMAINDERr   r^  ...rv  r  )r   r  z-z Zr8  Nr]  z-z Z XZ
X A B -z Z)ArD  r  rb  z	X Y --fooYr   r   rA   r   r   r`  r`    s        <<3s88SSE%:%:%:CCIIF!!!H	bb3"%%%&	22rS)))*	rrC#8#8#8DAAAB	bb33.D999:	IIIr   r`  c                      e Zd ZdZ ede           eded           edd	          gZg d
Zd eddg           fd eddg           fd edddg          fd eddg           fd eddg           fd eddg           fd edddg          fd edddg          fd edddg          fd edddg          fd edddg          fgZ	dS )TestOptionLikez.Tests options that may or may not be argumentsr   r   z-3r^  )r   r*  r
  r  rv  )r   z-y2.5r   z-x -az-x -3z-x -3.5z-3 -3.5z-x -2.5z	-x -2.5 az-3 -.5za x -1z-x -1 az-3 -1 ar   Nr]  z-x 2.5      @z-x 2.5 ar   z-3.5      ?z-3-.5g      z-3 .5za -3.5za -x 1g      ?z-x 1 az-3 1 a)
r   r   r    r!   rt   floatr   r   r{   r   rA   r   r   rg  rg    s       88 	DuDu3'''Cs
0 0 0H
 
RR$$"%%%&	22tr***+	RR##///0	dcR((()	""ttr***+	""tsb)))*	22u---.	bb44C5)))*	22tu---.	22tu---.	22u---.IIIr   rg  c                   0   e Zd ZdZ eddej                   eddej                   eddej        	          gZd
gZd e	            fd e	d          fd e	ddg          fd e	d          fd e	dd          fd e	ddgd          fgZ
dS )TestDefaultSuppressz%Test actions with suppressed defaultsr(   r  r  rF  r  re  r  r  r   r   r   r  r  r  r  Tr  r  r(   rG  r  r5  N)r   r   r    r!   rt   r+   SUPPRESSr   r   r{   r   rA   r   r   rm  rm    s        // 	Eh&7888Eh&7888GL(2CDDD
 vH	RRTT
	bbSkkk	s&&&'	"",,,	BB3D)))*	bbSse6667IIIr   rm  c                   .   e Zd ZdZ eej                  Z edd           edd           edd	
          gZdgZ	d e
            fd e
d          fd e
ddg          fd e
d          fd e
dd          fd e
ddgd          fgZdS )TestParserDefaultSuppressz4Test actions with a parser-level default of SUPPRESSargument_defaultr(   r  rv  rF  r  re  r  r  r   r   r   r  r  r  r  Tr  r  rn  r  r5  N)r   r   r    r!   rt   r+   ro  r   r   r   r{   r   rA   r   r   rq  rq    s        >>sH,=>>>EEGL)))
 vH	RRTT
	bbSkkk	s&&&'	"",,,	BB3D)))*	bbSse6667IIIr   rq  c                   ^   e Zd ZdZ ed          Z eddd           edd	
           edd
           edd          gZdgZd edddd          fd edddd          fd eddgdd          fd edddd          fd edddd          fd eddgdd          fgZ	dS )TestParserDefault42z.Test actions with a parser-level default of 42r  rr  	--versionversion1.0r  rw  r(   r  rv  rF  r  re  r  r  r   r   )r(   rF  rG  rw  r   r  r  Tr  r  NrW  rA   r   r   ru  ru    s/       88sB///K	5999EEGL)))	 vH	RRBBB3334	bbSbb"5556	s2r:::;	""r:::;	BB3BD"===>	bbSserBBBCIIIr   ru  c                   t    e Zd ZdZ fdZ ed          Z ed           ed           edd	          gZg d
Zd e	dddg          fd e	ddddg          fd e	dddg          fd e	dddg          fd e	ddddg          fd e	ddddg          fg d e	dddg          fgZ
 xZS )TestArgumentsFromFile"Test reading arguments from a filec                     t          t          |                                            g d}|D ]D\  }}t          |dd          5 }|                    |           d d d            n# 1 swxY w Y   Ed S )N)hellozhello world!
)	recursivez-a
A
@hello)invalidz@no-such-path
rg   r
   rh   )r   r{  rK   rj   rk   r   
file_textsr[   textrn   r   s        r   rK   zTestArgumentsFromFile.setUp   s    #T**00222
 
 

 % 	! 	!JD$dC'222 !d

4   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !	! 	!s   A((A,	/A,	@fromfile_prefix_chars-ar   r^  r  rv  )r   r  r8  z@invalidz@missingzX YNr8  re  )r   r   r^  z
X -a A Y Zrd  rb  @hello Xzhello world!zX @helloz-a B @recursive Y ZzX @recursive Z -a BrD  )r  r   r8  re  r   )r   r   r    r!   rK   rt   r   r   r   r{   r   r"   r#   s   @r   r{  r{    sV       ,,! ! ! ! ! s555D		CCs
 766H	TSSE***+	rrC33*5556	RR$.SE:::;	RR$#.)9:::;	SNsCj I I IJ	SCNC3H I I IJ			rrB##7778IIIIIr   r{  c                        e Zd ZdZ fdZ G d de          ZeZ ed          Z	 edd	          gZ
g Zd
 eg d          fgZ xZS )TestArgumentsFromFileConverterr|  c                     t          t          |                                            dg}|D ]D\  }}t          |dd          5 }|                    |           d d d            n# 1 swxY w Y   Ed S )Nr~  rg   r
   rh   )r   r  rK   rj   rk   r  s        r   rK   z$TestArgumentsFromFileConverter.setUp"  s    ,d3399;;;'

 % 	! 	!JD$dC'222 !d

4   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !	! 	!s   A''A+	.A+	c                       e Zd Zd ZdS )>TestArgumentsFromFileConverter.FromFileConverterArgumentParserc              #   j   K   |                                 D ]}|                                s|V  d S rO   )r   strip)r   arg_lineargs      r   convert_arg_line_to_argszWTestArgumentsFromFileConverter.FromFileConverterArgumentParser.convert_arg_line_to_args-  sG      ~~''  yy{{ 				 r   N)r   r   r    r  rA   r   r   FromFileConverterArgumentParserr  +  s#        	 	 	 	 	r   r  r  r  r^  r  rv  r  )r  zworld!r8  r  )r   r   r    r!   rK   r   r  r   rt   r   r   r   r{   r   r"   r#   s   @r   r  r    s        ,,! ! ! ! !    *D    3Ls555Cs H	RR2223334IIIIIr   r  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )TestFileTypeReprc                 t    t          j        d          }|                     dt          |                     d S )Nr  zFileType('r')r+   FileTyper   reprr   r   s     r   test_rzTestFileTypeRepr.test_rC  s4     %%$t**55555r   c                 v    t          j        dd          }|                     dt          |                     d S )Nwbru  zFileType('wb', 1)r  r  s     r   	test_wb_1zTestFileTypeRepr.test_wb_1G  s7     q)),d4jj99999r   c                 x    t          j        dd          }|                     dt          |                     d S )Nr  latin_1rh   z!FileType('r', encoding='latin_1')r  r  s     r   test_r_latinzTestFileTypeRepr.test_r_latinK  s:     y999<d4jjIIIIIr   c                 z    t          j        ddd          }|                     dt          |                     d S )Nrg   big5ignore)ri   errorsz/FileType('w', encoding='big5', errors='ignore')r  r  s     r   test_w_big5_ignorez#TestFileTypeRepr.test_w_big5_ignoreO  sG     vhGGGJd	% 	% 	% 	% 	%r   c                 z    t          j        ddd          }|                     dt          |                     d S )Nr  ru  replacer  z"FileType('r', 1, errors='replace')r  r  s     r   test_r_1_replacez!TestFileTypeRepr.test_r_1_replaceT  s<     a	:::=tDzzJJJJJr   N)r   r   r    r  r  r  r  r  rA   r   r   r  r  A  sg        6 6 6: : :J J J% % %
K K K K Kr   r  c                       e Zd Zd Zd ZdS )StdStreamComparerc                     t          j        |          | _        |dk    rt          | _        d S |dk    rt
          | _        d S t                      | _        d S )Nstdout.bufferstderr.buffer)operator
attrgetterr   r   
backupattrr   r   )r   r   s     r   r   zStdStreamComparer.__init__^  sQ      *400?""1DOOO_$$1DOOO$hhDOOOr   c                 v    	 ||                      t                    k    S # t          $ r || j        k    cY S w xY wrO   )r   r   AttributeErrorr  r   s     r   r   zStdStreamComparer.__eq__l  sL    	,DLL---- 	, 	, 	,DO++++	,s     88Nr   r   r    r   r   rA   r   r   r  r  ]  s2        ' ' ', , , , ,r   r  stdinr   r   zstdin.bufferr  r  c                       e Zd Zi Zd Zd ZdS )RFilec                     || _         d S rO   rd   r   rd   s     r   r   zRFile.__init__~      			r   c                    || j         v r| j         |         }n2|                                x}| j         |<   |                                 t          |t                    s|                    d          }| j        |j        cxk    o|k    nc S )Nascii)seenreadcloser   r   r   rd   r   r   r  s      r   r   zRFile.__eq__  s    DI9U#DD&+jjll2D49U#KKMMM$$$ 	(;;w''DyEJ....$.....r   N)r   r   r    r  r   r   rA   r   r   r  r  {  s7        D  / / / / /r   r  c                       e Zd ZdZ fdZ ed ej                               ed ej        d                    gZg dZ	d e
d	 ed          
          fd e
 ed           ed          
          fd e
 ed           ed          
          fd e
ee
          fd e
d	 ed          
          fgZ xZS )TestFileTypeR8Test the FileType option/argument type for reading filesc                 N   t          t          |                                            dD ]d}t          t          j                            | j        |          dd          5 }|                    |           d d d            n# 1 swxY w Y   e| 	                    d           d S )Nr  rg   r
   rh   readonly)
r   r  rK   rj   rS   r[   r\   rR   rk   rr   r   	file_namern   r   s      r   rK   zTestFileTypeR.setUp  s    mT""((***' 	& 	&Ibgll4=)<<G- - - &04

9%%%& & & & & & & & & & & & & & & 	!!*-----   "BB	B	r   rh  r  r  )r   r   znon-existent-file.txtr(   Nr   r  
-x foo barrF  
bar -x foo-x - -r  )r   r   r    r!   rK   rt   r+   r  r   r   r{   r  eq_stdinr   r"   r#   s   @r   r  r    s3       BB. . . . . 	D(x(**+++F**3//000 322H	Te---.	rrEE%LLuuU||<<<=	rrEE%LLuuU||<<<=	22x0001	RR$UU:%6%67778IIIIIr   r  c                        e Zd ZdZ fdZ ed ej        d          d          gZdgZ	d e
 ed	          
          fgZ xZS )TestFileTypeDefaultsz<Test that a file is not created unless the default is neededc                    t          t          |                                            t          t          j                            | j        d          dd          }|                    d           |	                                 d S )Ngoodrg   r
   rh   )
r   r  rK   rj   rS   r[   r\   rR   rk   r  )r   rn   r   s     r   rK   zTestFileTypeDefaults.setUp  si    "D))//111BGLL77wOOO

6

r   r  r  zno-file.txtr   ro  r   z-c goodr  )r  )r   r   r    r!   rK   rt   r+   r  r   r   r{   r  r   r"   r#   s   @r   r  r    s        FF     	D(x(--}EEE tHRR%%--00012IIIIIr   r  c            	       d    e Zd ZdZ fdZ ed ej        d                     ed ej        d                    gZddgZ	d e
d	 ed          
          fd e
 ed           ed          
          fd e
 ed           ed          
          fd e
ee
          fgZ xZS )TestFileTypeRBr  c                 $   t          t          |                                            dD ]d}t          t          j                            | j        |          dd          5 }|                    |           d d d            n# 1 swxY w Y   ed S )Nr  rg   r
   rh   )	r   r  rK   rj   rS   r[   r\   rR   rk   r  s      r   rK   zTestFileTypeRB.setUp  s    nd##))+++' 	& 	&Ibgll4=)<<G- - - &04

9%%%& & & & & & & & & & & & & & &	& 	&r  r   rbrh  r  r   r(   Nr  r  rF  r  r  )r   r   r    r!   rK   rt   r+   r  r   r   r{   r  	eq_bstdinr   r"   r#   s   @r   r  r    s       BB& & & & & 	D(x(..///F**400111 bzH	Te---.	rrEE%LLuuU||<<<=	rrEE%LLuuU||<<<=	22		2223	IIIIIr   r  c                   .    e Zd Z e            Zd Zd ZdS )WFilec                     || _         d S rO   r  r  s     r   r   zWFile.__init__  r  r   c                     || j         vrcd}d|j        v r|                    d          }|                    |           |                                 | j                             |           | j        |j        k    S )NzCheck that file is writable.r  r  )r  moder   rk   r  addrd   r  s      r   r   zWFile.__eq__  st    	!!1Dej  {{7++KKKKMMMIMM%   yEJ&&r   N)r   r   r    rH  r  r   r   rA   r   r   r  r    s=        355D  ' ' ' ' 'r   r  c            
           e Zd ZdZ fdZ ed ej        d                     ed ej        d                    gZg dZ	d e
d	 ed          
          fd e
d	 ed          
          fd e
 ed           ed          
          fd e
 ed           ed          
          fd e
ee
          fgZ xZS )TestFileTypeWz8Test the FileType option/argument type for writing filesc                     t                                                       |                     d           |                     d           d S Nr  writabler   rK   rr   ro   r   r   s    r   rK   zTestFileTypeW.setUp  B    !!*---!!*-----r   r   rg   rh  r  )r   r   r  r(   Nr  r  r  rF  r  r  r   r   r    r!   rK   rt   r+   r  r   r   r{   r  	eq_stdoutr   r"   r#   s   @r   r  r    s5       BB. . . . . 	D(x(--...F**3//000 &%%H	Te---.	RR$UU:%6%67778	rrEE%LLuuU||<<<=	rrEE%LLuuU||<<<=	22		2223IIIIIr   r  c                        e Zd ZdZ fdZ ed ej        d                     ed ej        d                    gZg dZ	d e
 ed	           ed
                    fd e
ee          fgZ xZS )TestFileTypeXzATest the FileType option/argument type for writing new files onlyc                     t                                                       |                     d           |                     d           d S r  r  r  s    r   rK   zTestFileTypeX.setUp  r  r   r   r   rh  r  )r   r   r  r  r  r(   rF  r  r  r  r#   s   @r   r  r    s        KK. . . . . 	D(x(--...F**3//000 211H	rrEE%LLuuU||<<<=	22		2223IIIIIr   r  c            	       T   e Zd ZdZ ed ej        d                     ed ej        d                    gZddgZd e	d e
d          	          fd
 e	 e
d           e
d          	          fd e	 e
d           e
d          	          fd e	ee	          fgZdS )TestFileTypeWBz?Test the FileType option/argument type for writing binary filesr   r  rh  r  r   r(   Nr  r  rF  r  r  )r   r   r    r!   rt   r+   r  r   r   r{   r  
eq_bstdoutr   rA   r   r   r  r    s        II 	D(x(..///F**400111 bzH	Te---.	rrEE%LLuuU||<<<=	rrEE%LLuuU||<<<=	22
4445	IIIr   r  c                       e Zd ZdZ ed ej        d                     ed ej        d                    gZd e e	d           e	d          	          fd
 ee
e
	          fgZdS )TestFileTypeXBzHTest the FileType option/argument type for writing new binary files onlyr   xbrh  r  r  r(   rF  r  r  N)r   r   r    r!   rt   r+   r  r   r{   r  r  r   rA   r   r   r  r    s        NN 	D(x(..///F**400111
 
rrEE%LLuuU||<<<=	22
4445IIIr   r  c                       e Zd ZdZd ZdS )TestFileTypeOpenArgsz0Test that open (the builtin) is correctly calledc           
      H   t           j        } |d          df |dd          df |dd          df |d	d
          df |dddd          dfg}t          j        d          5 }|D ]\  }} |d            |j        dg|R   	 d d d            d S # 1 swxY w Y   d S )Nr  )r  NNrg   ru  )rg   ru  NNr  r  )rg   r  Nr  r  r  rh   )r  r  r  Nr   l1strict)rg   r   r  r  zbuiltins.openr(   )r+   r  r   r/   assert_called_with)r   FTcasesmr   rv   s         r   test_open_argsz#TestFileTypeOpenArgs.test_open_args*  s4   RXX-.RQZZ-.RI&&&(BCRv&&&(@ARQh'')AB
 Z(( 	3A# 3 3
dU$$U2T222223	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3s   '"BBBN)r   r   r    r!   r  rA   r   r   r  r  '  s)        ::3 3 3 3 3r   r  c                       e Zd ZdZd ZdS )!TestFileTypeMissingInitializationzx
    Test that add_argument throws an error if FileType class
    object was passed instead of instance of FileType
    c                 <   t          j                    }|                     t                    5 }|                    dt           j                   d d d            n# 1 swxY w Y   |                     t           j        dt          |j                             d S )Nr   rh  z: is a FileType class object, instance of it must be passed)	r+   r,   r   
ValueErrorr   r  r   r   r  r  s      r   testz&TestFileTypeMissingInitialization.test?  s    (**z** 	>b8+<===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	   #	
 	
 	
 	
 	
s   "AA #A Nr   r   r    r!   r  rA   r   r   r   r   9  s-         
	
 	
 	
 	
 	
r   r   c                       e Zd ZdZ ede           ede          gZg dZd e	dd	          fd
 e	dd	          fd e	dd	          fgZ
dS )TestTypeCallablez,Test some callables as option/argument typesz--eggsrh  r  )r   42jz--eggs az	--eggs 2iz--eggs=42 42r  g      E@)eggsr  z--eggs 2j -- -1.5y               @      z1024.675Ng3333@)r   r   r    r!   rt   complexrk  r   r   r{   r   rA   r   r   r  r  K  s        66 	H7###F 544H	$///0	bbbt4445	RRT1112IIIr   r  c                       e Zd ZdZ G d de          Z ede           ede          gZg Zd e	 ed           ed	          
          fd e	 ed           ed          
          fgZ
dS )TestTypeUserDefinedz(Test a user-defined option/argument typec                       e Zd Zd Zd ZdS )TestTypeUserDefined.MyTypec                     || _         d S rO   valuer   r  s     r   r   z#TestTypeUserDefined.MyType.__init___      DJJJr   c                 ^    t          |           | j        ft          |          |j        fk    S rO   r   r  r   s     r   r   z!TestTypeUserDefined.MyType.__eq__b  '    JJ
+UU[/IIIr   Nr  rA   r   r   MyTyper  ]  7        	 	 		J 	J 	J 	J 	Jr   r  r   rh  r  r}  r  r   r  -xf gr  rh  N)r   r   r    r!   rC   r  rt   r   r   r{   r   rA   r   r   r  r  Z  s        22J J J J J J J J 	DvF    H	22s&&++6667	""vvc{{5556IIIr   r  c                       e Zd ZdZ G d d          Z ede           ede          gZg Zd e ed           ed	          
          fd e ed           ed          
          fgZ	dS )TestTypeClassicClasszTest a classic class typec                       e Zd Zd Zd ZdS )TestTypeClassicClass.Cc                     || _         d S rO   r  r  s     r   r   zTestTypeClassicClass.C.__init__u  r  r   c                 ^    t          |           | j        ft          |          |j        fk    S rO   r  r   s     r   r   zTestTypeClassicClass.C.__eq__x  r  r   Nr  rA   r   r   Cr  s  r  r   r   r   rh  r  r}  r  r   r  r  r  rh  N)
r   r   r    r!   r   rt   r   r   r{   r   rA   r   r   r  r  p  s        ##J J J J J J J J 	DqF H	22#QQsVV,,,-	""qqvvAAcFF+++,IIIr   r  c                       e Zd ZdZd ZdS )TestTypeRegistrationz*Test a user-defined type by registering itc                    d }t          j                    }|                    dd|           |                    dd           |                    dd           |                     |                    d                                          t          d d	                     |                     |                    d
                                          t          dd	                     d S )Nc                     d| z  S )Nzmy_type{%s}rA   strings    r   get_my_typez.TestTypeRegistration.test.<locals>.get_my_type  s     6))r   r   my_typer   rh  r^  r  z
my_type{1}rp  z-x 1 42zmy_type{42})r+   r,   registerr   r   r;   r   r{   )r   r'  r2   s      r   r  zTestTypeRegistration.test  s    	* 	* 	* (**	;777Dy111Ci000**399;;77dl333	5 	5 	5**9??+<+<==lm<<<	> 	> 	> 	> 	>r   Nr  rA   r   r   r"  r"    s)        44> > > > >r   r"  c                      e Zd ZdZ G d dej                  Z G d dej                  Z eddee	d	           ed
ee
dd          gZg Zd edd          fd edd          fd edd          fd edd          fgZdS )TestActionUserDefinedz*Test a user-defined option/argument actionc                       e Zd ZddZdS )$TestActionUserDefined.OptionalActionNc                     	 t          d          }|dv rd|_        n|dv rd|_        nt          d|z            n$# t          $ r}t          d|z            d }~ww xY wt	          |d	|           d S )
N      ?rG  )      ?r;  r  )       @r  	value: %szopt_action failed: %sr  )r{   r6  AssertionErrorr   r   r   r2   	namespacer  option_stringr   r   s          r   __call__z-TestActionUserDefined.OptionalAction.__call__  s    G !dmmmN**)*K&&e^^)+K&&(u)<=== " G G G)*AA*EFFFGIvu-----s   := 
AAArO   r   r   r    r7  rA   r   r   OptionalActionr-    s(        	. 	. 	. 	. 	. 	.r   r9  c                       e Zd ZddZdS )&TestActionUserDefined.PositionalActionNc                     	 t          d          }|dv rd|_        n*|dv rd|_        n|dv rd|_        nt          d	|z            n$# t          $ r}t          d
|z            d }~ww xY wt	          |d|           d S )Nr  r6  )r  r  r/  )ru  r;  )r  r0  r2  zarg_action failed: %sr6  )r{   r  r3  r   r   r4  s          r   r7  z/TestActionUserDefined.PositionalAction.__call__  s    G !lllH$$'+K$$c\\',K$$c\\',K$$(u)<=== " G G G)*AA*EFFFGIx/////s   AA	 	
A*A%%A*rO   r8  rA   r   r   PositionalActionr;    s(        	0 	0 	0 	0 	0 	0r   r>  z-sr  r/  )r*  r  r   ro  r6  r  r  )r  r   rw  ro  z-s0.125r0  )r  r6  r  r  z
-s 0.625 1r;  ru  z84 -s2r1  r  N)r   r   r    r!   r+   Actionr9  r>  rt   rk  r  r   r   r{   r   rA   r   r   r+  r+    s       44. . . . . . . .,0 0 0 0 08? 0 0 04 	Dvn	& 	& 	&H-C	, 	, 	, H	BBE!,,,-	rrtB'''(	rruQ///0	223r***+	IIIr   r+  c                   >    e Zd ZdZ G d dej                  Zd ZdS )TestActionRegistrationz5Test a user-defined action supplied by registering itc                       e Zd ZddZdS )TestActionRegistration.MyActionNc                 8    t          || j        d|z             d S )Nzfoo[%s])r   r*  )r   r2   r5  valuesr6  s        r   r7  z(TestActionRegistration.MyAction.__call__  s!    Ity)f*<=====r   rO   r8  rA   r   r   MyActionrC    s(        	> 	> 	> 	> 	> 	>r   rF  c                 r   t          j                    }|                    dd| j                   |                    dd           |                     |                    dg          t          d                     |                     |                    dg          t          d	                     d S )
Nr  	my_actionr6  r  r  zfoo[1]r=  r  zfoo[42])r+   r,   r)  rF  r   r   r;   r{   r1   s     r   r  zTestActionRegistration.test  s    (**+t}===H[999**C5112X3F3F3FGGG**D622Bi4H4H4HIIIIIr   N)r   r   r    r!   r+   r?  rF  r  rA   r   r   rA  rA    sZ        ??> > > > >8? > > >
J J J J Jr   rA  c                   T    e Zd Z eddde          gZdZd eg d          fgZd	S )
TestActionExtendr   extendr  )r  rw  r   rA   z--foo f1 --foo f2 f3 f4)f1f2f3f4r  N)	r   r   r    rt   r   r   r   r{   r   rA   r   r   rJ  rJ    sV        GHCc::: H	"BB+C+C+C$D$D$DEIIIr   rJ  c                        e Zd ZdZd Z	 	 ddZ f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 xZS ) TestAddSubparserszTest the add_subparsers methodc                 2     | j         t          g|R i | d S rO   r   r   rx   s      r   assertArgumentParserErrorz+TestAddSubparsers.assertArgumentParserError   ,    -?????????r   FNc                    |r7t          dd|          }|                    |d         dz  dz   dd	           n)t          dd
          }|                    ddd	           |                    dt          d           ddi}|rd|d<   d|d<   nd|d<    |j        d7i |}|                     |j                   t          d          }|rd|d<   |rddg|d<    |j        d8i |}|                    dt          d           |                    d d!d"#           t          d$          }	|rd%|	d<    |j        d9i |	}
|
                    d'd(d)#           |
                    d*t          d+d,-           t          d.          }|rd/|d<    |j        d:i |}|                    d1t          d2           |                    d3d4d56           |S );NPROGmain description)progdescriptionrL  r   r  r(   r  foo helpr  helprY  rZ  r   rF  bar helpr   r]  r  FCOMMANDmetavarcommandstitlecommand helpr]  z1 descriptionrZ  z1 help1alias11alias2aliasesr  r\  zw helpr   r  x helpr  r]  z2 descriptionz2 helpr  r  123y helpr
  r  zz help)r   rw  r]  z3 descriptionz3 helpr  tzt helpura  zu helprw  r]  rA   r  )r  )r  )	r   r   rk  add_subparsersrT  dict
add_parserr  r
  )r   subparser_helprL  ri  r2   subparsers_kwargs
subparsersparser1_kwargsparser1parser2_kwargsparser2parser3_kwargsparser3s                r   r   zTestAddSubparsers._get_parser  s     		?/);,X X XFQ!#e+Lz   S S S S 0);= = =F:   ? ? ?J 	 	0 	0 	0 (/ 	7+4i()3g&&(6f%*V*??->??
&&v'<=== /::: 	.%-N6" 	?)2I(>N9%'*'>>~>>T(;;;S%h??? /::: 	.%-N6"'*'>>~>>T5x@@@SwcIII /::: 	.%-N6"'*'>>~>>Ss:::SH=== r   c                     t                                                       |                                 | _        |                     d          | _        d S )NT)ru  )r   rK   r   r2   command_help_parserr  s    r   rK   zTestAddSubparsers.setUp:  sF    &&((#'#3#34#3#H#H   r   c                 x    dD ]6}|                                 }|                     | j        j        |           7d S )N)r   r   za az0.5 az0.5 1z0.5 1 -yz0.5 2 -w)r   rT  r2   r;   )r   r   rv   s      r   test_parse_args_failuresz*TestAddSubparsers.test_parse_args_failures?  sN    1 	I 	IH>>##D**4;+A4HHHH	I 	Ir   c           
         |                      | j                            d                                          t	          dddd                     |                      | j                            d                                          t	          dd	d
ddg                     |                      | j                            d                                          t	          ddd d                     |                      | j                            d                                          t	          dddg d                     d S )N0.5 1 b -w 7Frj     r  r(   rF  rg   r   z0.25 --foo 2 -y 2 3j -- -1jTr/  r  y              @y             )r(   rF  r^  r
  z--foo 0.125 1 cr0  r  z-1.5 3 11 -- a --foo 7 -- br	     )r   r   r  --r  )r(   rF  rn  ro  )r   r2   r;   r   r{   r   s    r   test_parse_argsz!TestAddSubparsers.test_parse_argsF  sL   K"">#7#7#9#9::5cQ#...	
 	
 	
 	K""#@#F#F#H#HII4TSRI666	
 	
 	
 	K""#4#:#:#<#<==4Udc222	
 	
 	
 	K""#@#F#F#H#HII5db,J,J,JKKK	
 	
 	
 	
 	
r   c           	      P   |                      | j                            d                                          t	          dddd          g f           |                      | j                            d                                          t	          dddd          dgf           |                      | j                            d	                                          t	          dddd          dgf           |                      | j                            d
                                          t	          dddd          ddgf           |                      | j                            d                                          t	          dddd          g df           d S )Nr  Frj  r  r  r  z0.5 -p 1 b -w 7-pz0.5 1 b -w 7 -pz0.5 1 b -q -rs -w 7z-qz-rsz0.5 -W 1 b -X Y -w 7 Z)z-Wz-Xre  rb  )r   r2   parse_known_argsr   r{   r   s    r   test_parse_known_argsz'TestAddSubparsers.test_parse_known_argsY  s   K(()=)=)?)?@@Esa3///4	
 	
 	
 	K(():)@)@)B)BCCEsa3///$8	
 	
 	
 	K(():)@)@)B)BCCEsa3///$8	
 	
 	
 	K(()>)D)D)F)FGGEsa3///$?	
 	
 	
 	K(()A)G)G)I)IJJEsa3///1G1G1GH	
 	
 	
 	
 	
r   c                 f   t                      }|                    dd           |                    d          }|                    d          }|                    d           |                     t          ddd	
          |                    d                                                     d S )Nr   r  r  rF  r)  r  rG  Fr  r5  r  )r   r   rr  rt  r   r{   r;   r   )r   r2   rw  ry  s       r   	test_destzTestAddSubparsers.test_desto  s    +--GL999***66
'',,U###3C888**5;;==99	; 	; 	; 	; 	;r   c                     |                     dg          }|                     |j        d           |                     |j         d           d S )NrunrA   )r;   r   commandrT  )r   r2   rets      r   _test_required_subparsersz+TestAddSubparsers._test_required_subparsersx  sP    ((e,,, 	&&v'8"=====r   c                     t                      }|                    d          }d|_        |                    d           |                     |           d S )Nr  r)  Tr  )r   rr  r  rt  r  r   r2   rw  s      r   &test_required_subparsers_via_attributez8TestAddSubparsers.test_required_subparsers_via_attribute  sY    +--**	*::
"
e$$$&&v.....r   c                     t                      }|                    dd          }|                    d           |                     |           d S )Nr  Tr*  r  r  )r   rr  rt  r  r  s      r   "test_required_subparsers_via_kwargz4TestAddSubparsers.test_required_subparsers_via_kwarg  sS    +--**	D*II
e$$$&&v.....r   c                     t                      }|                    d          }|                    d           |                    d          }|                     |j                   d S )Nr  r)  r  rA   r   rr  rt  r;   assertIsNoner  r   r2   rw  r  s       r    test_required_subparsers_defaultz2TestAddSubparsers.test_required_subparsers_default  sf    +--**	*::
e$$$###+&&&&&r   c                 p   t                      }|                    d          }|                    d           |                    d           |                     t                    5 }|                    d           d d d            n# 1 swxY w Y   |                     |j        j        d           d S )NTr  r(   rF  rA   z8error: the following arguments are required: {foo,bar}
$	r   rr  rt  r   r   r;   r>   r  r   r   r2   rw  excinfos       r   -test_required_subparsers_no_destination_errorz?TestAddSubparsers.test_required_subparsers_no_destination_error  s    +--**D*99
e$$$e$$$233 	"wb!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"$G	
 	
 	
 	
 	
   )BBBc                 p   t                      }|                    d          }|                    d           |                    d           |                     t                    5 }|                    d           d d d            n# 1 swxY w Y   |                     |j        j        d           d S )NTr  r(   rF  r  zPerror: argument {foo,bar}: invalid choice: 'baz' \(choose from 'foo', 'bar'\)\n$r  r  s       r   3test_wrong_argument_subparsers_no_destination_errorzETestAddSubparsers.test_wrong_argument_subparsers_no_destination_error  s    +--**D*99
e$$$e$$$233 	(wh'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	($_	
 	
 	
 	
 	
r  c                     t                      }|                    dd          }|                    d           |                    d          }|                     |j                   d S )Nr  Fr  r  rA   r  r  s       r   test_optional_subparsersz*TestAddSubparsers.test_optional_subparsers  sh    +--**	E*JJ
e$$$###+&&&&&r   c                     |                      | j                                        d           |                      | j                                        t	          j        d                     d S )N)usage: PROG [-h] [--foo] bar {1,2,3} ...
a?              usage: PROG [-h] [--foo] bar {1,2,3} ...

            main description

            positional arguments:
              bar         bar help
              {1,2,3}     command help

            options:
              -h, --help  show this help message and exit
              --foo       foo help
            )r   r2   format_usageformat_helptextwrapdedentr   s    r   	test_helpzTestAddSubparsers.test_help  sv    1133E	G 	G 	G0022HO E 5 5 	 	 	 	 	r   c                     |                      d          }|                     |                                d           |                     |                                t	          j        d                     d S )Nz+:-rZ  z)usage: PROG [-h] [++foo] bar {1,2,3} ...
a?              usage: PROG [-h] [++foo] bar {1,2,3} ...

            main description

            positional arguments:
              bar         bar help
              {1,2,3}     command help

            options:
              -h, --help  show this help message and exit
              ++foo       foo help
            r   r   r  r  r  r  r1   s     r   test_help_extra_prefix_charsz.TestAddSubparsers.test_help_extra_prefix_chars  s    !!u!55,,..E	G 	G 	G++--x @ 0 0 	 	 	 	 	r   c                     t          dd          }|                    ddd           |                     |                                t	          j        d                     d S )	NrW  rX  r^  z--non-breakingr  uR   help message containing non-breaking spaces shall not wrap at non-breaking spacesr\  u7              usage: PROG [-h] [--non-breaking]

            main description

            options:
              -h, --help      show this help message and exit
              --non-breaking  help message containing non-breaking spaces shall not
                              wrap at non-breaking spaces
        r   r   r   r  r  r  r1   s     r   test_help_non_breaking_spacesz/TestAddSubparsers.test_help_non_breaking_spaces  s    +%79 9 9]; 	 	< 	< 	< 	++--x 	@ 	0 	0 		 		 		 		 		r   c                    t          dd          }|                    dd           |                     |                                t	          j        d                     t          dd          }|                    dg d	           |                     |                                t	          j        d
                     d S )NrW  rX  r^  r(   z    r]  z            usage: PROG [-h] foo

            main description

            positional arguments:
              foo         

            options:
              -h, --help  show this help message and exit
        z%(choices)srk  z            usage: PROG [-h] {}

            main description

            positional arguments:
              {}          

            options:
              -h, --help  show this help message and exit
        r  r1   s     r   test_help_blankz!TestAddSubparsers.test_help_blank  s   +%79 9 9 	 	 	 	 	++--x 	@ 	0 	0 		 		 		 ,%79 9 92 	 	  	  	  	++--x 	@ 	0 	0 		 		 		 		 		r   c                     |                      d          }|                     |                                d           |                     |                                t	          j        d                     d S )NrJ  rZ  z)usage: PROG [+h] [++foo] bar {1,2,3} ...
a?              usage: PROG [+h] [++foo] bar {1,2,3} ...

            main description

            positional arguments:
              bar         bar help
              {1,2,3}     command help

            options:
              +h, ++help  show this help message and exit
              ++foo       foo help
            r  r1   s     r    test_help_alternate_prefix_charsz2TestAddSubparsers.test_help_alternate_prefix_chars	  s    !!u!55,,..E	G 	G 	G++--x @ 0 0 	 	 	 	 	r   c                     |                      | j                                        d           |                      | j                                        t	          j        d                     d S )Nr  a              usage: PROG [-h] [--foo] bar {1,2,3} ...

            main description

            positional arguments:
              bar         bar help
              {1,2,3}     command help
                1         1 help
                2         2 help
                3         3 help

            options:
              -h, --help  show this help message and exit
              --foo       foo help
            )r   r  r  r  r  r  r   s    r   test_parser_command_helpz*TestAddSubparsers.test_parser_command_help	  sx    1>>@@E	G 	G 	G1==??! *  	 	 	 	 	r   c                    t          dd          }|                    ddd           |                    dd	
           |                    ddd          }|                    d          }|                    d          }|                     |                                d           |                     |                                t          j        d                     d S )NrW  rX  r^  r   r  r[  r\  rF  r_  r  subcommandsre  zadditional text)rd  rZ  r]  r  r  z'usage: PROG [-h] [--foo] bar {1,2} ...
av              usage: PROG [-h] [--foo] bar {1,2} ...

            main description

            positional arguments:
              bar         bar help

            options:
              -h, --help  show this help message and exit
              --foo       foo help

            subcommands:
              command help

              {1,2}       additional text
            )	r   r   rr  rt  r   r  r  r  r  )r   r2   rw  ry  r{  s        r   test_subparser_title_helpz+TestAddSubparsers.test_subparser_title_help4	  s   +8JL L LGLzJJJE
333**7E0A + C C
 '',,'',,,,..C	E 	E 	E++--x @ 0 0 	 	 	 	 	r   c                    |                      t                    5 }| j                            |                                           d d d            n# 1 swxY w Y   |                     ||j        j                   d S rO   )r   r   r2   r;   r   r   r  r   )r   r   expected_helpr  s       r   _test_subparser_helpz&TestAddSubparsers._test_subparser_helpR	  s    233 	5rK""8>>#3#3444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5(;<<<<<s   -AAAc                 V    |                      dt          j        d                     d S )Nz5.0 1 -ha              usage: PROG bar 1 [-h] [-w W] {a,b,c}

            1 description

            positional arguments:
              {a,b,c}     x help

            options:
              -h, --help  show this help message and exit
              -w W        w help
            r  r  r  r   s    r   test_subparser1_helpz&TestAddSubparsers.test_subparser1_helpW	  9    !!*ho ? / / 	 	 	 	 	r   c                 V    |                      dt          j        d                     d S )Nz5.0 2 -ha              usage: PROG bar 2 [-h] [-y {1,2,3}] [z ...]

            2 description

            positional arguments:
              z           z help

            options:
              -h, --help  show this help message and exit
              -y {1,2,3}  y help
            r  r   s    r   test_subparser2_helpz&TestAddSubparsers.test_subparser2_helpe	  r  r   c           	      j   |                      d          }|                     |                    d                                          t	          ddd d          g f           |                     |                    d                                          t	          ddd d          g f           d S )	NTri  z0.5 1alias1 bFrj  r  r  z0.5 1alias2 b)r   r   r  r   r{   r1   s     r   test_alias_invocationz'TestAddSubparsers.test_alias_invocations	  s    !!$!//##O$9$9$;$;<<Esdc222B7	
 	
 	
 	##O$9$9$;$;<<Esdc222B7	
 	
 	
 	
 	
r   c                     |                      d          }|                     |j        d                                           d S )NTr  z0.5 1alias3 b)r   rT  r;   r   r1   s     r   test_error_alias_invocationz-TestAddSubparsers.test_error_alias_invocation~	  sS    !!$!//&&v'8'6'<'<'>'>	@ 	@ 	@ 	@ 	@r   c                     |                      dd          }d | _        |                     |                                t	          j        d                     d S )NT)ri  ru  a	              usage: PROG [-h] [--foo] bar COMMAND ...

            main description

            positional arguments:
              bar                   bar help

            options:
              -h, --help            show this help message and exit
              --foo                 foo help

            commands:
              COMMAND
                1 (1alias1, 1alias2)
                                    1 help
                2                   2 help
                3                   3 help
            )r   maxDiffr   r  r  r  r1   s     r   test_alias_helpz!TestAddSubparsers.test_alias_help	  se    !!$t!DD++--x @ 0 0 	 	 	 	 	r   )FNF) r   r   r    r!   rT  r   rK   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#   s   @r   rQ  rQ    s       ((@ @ @ >B!5 5 5 5nI I I I I
I I I
 
 
&
 
 
,; ; ;> > >/ / // / /' ' '

 

 



 

 

' ' '  "  &  $     D  $  *  <= = =
    	
 	
 	
@ @ @
      r   rQ  c                   $    e Zd ZdZd Zd Zd ZdS )TestPositionalsGroupsz@Tests that order of group positionals matches construction orderc                 h   t                      }|                    d           |                    d          }|                    d           |                    d           t          ddd          }|                    d	                                          }|                     ||           d S )
Nr(   rh  rF  rG  r  r  r  r5  1 2 3)r   r   r   r{   r;   r   r   r   r2   r   expectedr   s        r   test_nongroup_firstz)TestPositionalsGroups.test_nongroup_first	  s    +--E"""))#..5!!!E"""#3C000""7==??336*****r   c                 h   t                      }|                    d          }|                    d           |                    d           |                    d           t          ddd          }|                    d	                                          }|                     ||           d S )
Nxxxr(   rF  rG  r  r  r  r5  r  r   r   r   r{   r;   r   r   r  s        r   test_group_firstz&TestPositionalsGroups.test_group_first	  s    +--))%005!!!E"""E"""#3C000""7==??336*****r   c                    t                      }|                    d          }|                    d           |                    d           |                    d           |                    d          }|                    d           t          ddd	d
          }|                    d                                          }|                     ||           d S )Nr  r(   rF  rG  r	  frellr  r  r  rL  )r(   rF  rG  r  z1 2 3 4r  r  s        r   test_interleaved_groupsz-TestPositionalsGroups.test_interleaved_groups	  s    +--))%00E"""5!!!E"""))%007####3Cs;;;""9??#4#4556*****r   N)r   r   r    r!   r  r  r  rA   r   r   r  r  	  sG        JJ+ + ++ + +
+ 
+ 
+ 
+ 
+r   r  c                   v     e Zd ZdZd Z f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 xZS )TestParentParsersz5Tests that parsers can be created with parent parsersc                 2     | j         t          g|R i | d S rO   rS  rx   s      r   rT  z+TestParentParsers.assertArgumentParserError	  rU  r   c                    t                                                       t          d          | _        | j                            d           | j                            d          }|                    d           | j                            d           t          d          | _        | j                            d           | j                            d           | j                            d	          }|                    d
           t          d          | _        | j                            d           t          d          | _        | j                            d           t          d          | _	        | j	        
                                }|                    dd           |                    dd           t          j                            t          j        d                   | _        d S )NFrM  z--wr   r  r
  r   r  r  z--dr  r  r  r   )r   rK   r   wxyz_parentr   r   abcd_parentw_parentz_parentab_mutex_parentadd_mutually_exclusive_grouprS   r[   basenamer   r   main_program)r   x_groupc_groupr   r   s       r   rK   zTestParentParsers.setUp	  s   5uEEE%%e,,,"55c::T"""%%c***5uEEE%%c***%%d+++"55c::U###2EBBB""5)))2EBBB""3'''  :5III$AACC45554555G,,SXa[99r   c                     t          | j        g          }|                     |                    d                                          t          ddd                     d S )Nparentsz-y 1 2 --w 3r  r  r  rg   r^  r
  )r   r  r   r;   r   r{   r1   s     r   test_single_parentz$TestParentParsers.test_single_parent	  sh    +T5E4FGGG**>+?+?+A+ABBcSC000	2 	2 	2 	2 	2r   c                     |                      | j        j                   t          | j        g          }|                      |j                   d S Nr  )_test_mutex_abr  r;   r   r1   s     r   test_single_parent_mutexz*TestParentParsers.test_single_parent_mutex	  sO    D0;<<<+T5I4JKKKF-.....r   c                     | j         g}t          d|          }t          |g          }|                     |j                   d S )NF)rM  r  r  )r  r   r  r;   r   r  r2   s      r   test_single_granparent_mutexz.TestParentParsers.test_single_granparent_mutex	  sN    '(+UGLLL+VH===F-.....r   c                    |                       |g           t          dd                     |                       |dg          t          dd                     |                       |dg          t          dd                     |                     |ddg           |                     |ddg           |                     |dg           |                     |ddg           |                     |ddg           d S )NFr   r  r  Tr  r  )r   r{   rT  )r   r;   s     r   r  z TestParentParsers._test_mutex_ab	  s   Beu)=)=)=>>>TF++R$%-@-@-@AAATF++R%4-@-@-@AAA&&zD$<@@@&&zD$<@@@&&zD6:::&&zD$<@@@&&zD$<@@@@@r   c                     | j         | j        g}t          |          }|                     |                    d                                          t          dd ddd d                     d S )Nr  z--d 1 --w 2 3 4r  r  r  rL  )r   r  r8  rg   r^  r
  )r  r  r   r   r;   r   r{   r  s      r   test_multiple_parentsz'TestParentParsers.test_multiple_parents
  s~    #T%56+G<<<**+<+B+B+D+DEEcTSC43GGG	I 	I 	I 	I 	Ir   c           
         | j         | j        g}t          |          }|                     |                    d                                          t          dddd d                     |                     |j        d                                           |                     |j        d	                                           d S )
Nr  z
-a --w 2 3TFr  r  )r   r  rg   r^  r
  z-a --w 2 3 -bz-a -b --w 2 3)r  r  r   r   r;   r   r{   rT  r  s      r   test_multiple_parents_mutexz-TestParentParsers.test_multiple_parents_mutex
  s    ')9:+G<<<**<+=+=+?+?@@desdcBBB	D 	D 	D&&4466	8 	8 	8&&4466	8 	8 	8 	8 	8r   c                 v    |                      t          j        t          j        | j        | j        g           d S r  )r   r+   ArgumentErrorr,   r  r  r   s    r   test_conflicting_parentsz*TestParentParsers.test_conflicting_parents
  sB    "#]D$45 	 	7 	7 	7 	7 	7r   c                 v    |                      t          j        t          j        | j        | j        g           d S r  )r   r+   r  r,   r  r  r   s    r   test_conflicting_parents_mutexz0TestParentParsers.test_conflicting_parents_mutex
  sC    "#%t';< 	 	> 	> 	> 	> 	>r   c                     | j         | j        g}t          |          }|                     |                    d                                          t          d d d                     d S )Nr  r  r  r  )r  r  r   r   r;   r   r{   r  s      r   test_same_argument_name_parentsz1TestParentParsers.test_same_argument_name_parents
  sm    #T]3+G<<<**5;;==99ddc222	4 	4 	4 	4 	4r   c           	      F   t                      }|                                }|                    d| j        g          }|                    d           |                     |                    d                                          t          dddd	                     d S )
NrF  r  r   zbar -b 1 --d 2 3 4r  r  r  rL  )r   r  r8  r   )	r   rr  rt  r  r   r   r;   r   r{   )r   r2   rw  abcde_parsers       r   test_subparser_parentsz(TestParentParsers.test_subparser_parents#
  s    +--**,,
!,,UT=M<N,OO!!#&&&**+?+E+E+G+GHHcSC3777	9 	9 	9 	9 	9r   c                 6   t                      }|                                }| j        g}|                    d|          }|                    d          }|                    d           | j        | j        g}|                    d|          }|                    d           |                     |                    d	                                          t          dd	d
                     |                     |                    d	                                          t          d	ddd dd
                     |                     |j        d	                                           |                     |j        d	                                           d S )Nr(   r  r  r  rF  r   zfoo -a 4TFrL  r~  zbar -b  --w 2 3 4r  r  )r   r  rg   r^  r
  r   zfoo -a -b 4zbar -b -a 4)r   rr  r  rt  r   r   r  r   r;   r   r{   rT  )r   r2   rw  r  
abc_parserr  wxyzabe_parsers          r   test_subparser_parents_mutexz.TestParentParsers.test_subparser_parents_mutex+
  s   +--**,,
'(**5'*BB
//	::S!!!#T%9:#..ug.FF##C(((**:+;+;+=+=>>des333	5 	5 	5**+>+D+D+F+FGGetsdcSIII	K 	K 	K&&}2244	6 	6 	6&&}2244	6 	6 	6 	6 	6r   c           	          | j         | j        g}t          |          }|                                }| j        }|                     |t          j        d                    ||rdnd                               d S )Nr  aG              usage: {}{}[-h] [-b B] [--d D] [--w W] [-y Y] a z

            positional arguments:
              a
              z

            options:
              -h, --help  show this help message and exit
              -b B
              --w W

            c:
              --d D

            x:
              -y Y
         r   )	r  r  r   r  r  r   r  r  format)r   r  r2   parser_helpprognames        r   test_parent_helpz"TestParentParsers.test_parent_help>
  s    #T%56+G<<<((**$ho 7" F8H4SS"66#'8 '8 	9 	9 	9 	9 	9r   c           	      B   t          d          }|                    dd          }|                    d           |                    d           |                                }|                    d           |                    d	           t          |g
          }|                     t
          |j        g d           |                                }| j        }| 	                    |t          j        d                    ||rdnd                               d S )NFr  rh  gdrd  rZ  r\  r   r  r  r  )r  re  r  rb  z            usage: {}{}[-h] [-w W] [-x X] [-y Y | -z Z]

            options:
              -h, --help  show this help message and exit
              -y Y
              -z Z

            g:
              gd

              -w W
              -x X
        r  r   )r   r   r   r  r   r   r;   r  r  r   r  r  r  )r   parentrh  r  r2   r  r  s          r   test_groups_parentsz%TestParentParsers.test_groups_parentsV
  s*   +U;;;%%CT%BB	t	t//11	t	t+VH===-v/@"""	$ 	$ 	$ ((**$ho 7 F8H4SS"66'8 '8 	9 	9 	9 	9 	9r   )r   r   r    r!   rT  rK   r  r  r  r  r  r   r  r  r  r
  r  r  r  r"   r#   s   @r   r  r  	  s       ??@ @ @: : : : :82 2 2
/ / /
/ / /A A AI I I8 8 87 7 7> > >4 4 49 9 96 6 6&9 9 909 9 9 9 9 9 9r   r  c                   &    e Zd Zd Zd Zd Zd ZdS ) TestMutuallyExclusiveGroupErrorsc                 `    t                      }| j        } |t          |j        d           d S )Nr(   )rd  )r   r   r   r  )r   r2   raisess      r   test_invalid_add_argument_groupz@TestMutuallyExclusiveGroupErrors.test_invalid_add_argument_groupz
  s5    +--"y&=UKKKKKKr   c                 >   t                      }|                                }|j        }| j        } |t          |dd            |t          |d            |t          |dd            |t          |dd            |t          |dt
          j                   d S )Nr   Tr  rF  r  rv  ru  )r   r  r   r   r  r+   PARSER)r   r2   r   r   r  s        r   test_invalid_add_argumentz:TestMutuallyExclusiveGroupErrors.test_invalid_add_argument
  s    +--3355)"z<4@@@@z<///z<c::::z<a8888z<hoFFFFFFr   c                    t          d          }|                                }|                    dd           |                    dd           |                                }|                    dd           |                    d	d           d
}|                     |                                t          j        |                     d S )NrW  rY  r   r  r  r1  r  z--soupz--nutsz            usage: PROG [-h] [--foo | --bar] [--soup | --nuts]

            options:
              -h, --help  show this help message and exit
              --foo
              --bar
              --soup
              --nuts
              )r   r  r   r   r  r  r  )r   r2   group1group2r  s        r   r  z*TestMutuallyExclusiveGroupErrors.test_help
  s    +8884466GL999GM:::4466H\:::H];;;	 	++--xx/H/HIIIIIr   c                     t          j                    }|                                }|                     t                    5  |                    dg           d d d            d S # 1 swxY w Y   d S )Nr5   )r+   r,   r  r   r  r;   r   r2   r   s      r   test_empty_groupz1TestMutuallyExclusiveGroupErrors.test_empty_group
  s    (**3355z** 	& 	&tf%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s   A&&A*-A*N)r   r   r    r  r!  r  r(  rA   r   r   r  r  x
  sY        L L L
	G 	G 	GJ J J(& & & & &r   r  c                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
MEMixinc                     |                      d          j        }t          }| j        D ]+}|                     |||                                           ,d S NFr  
get_parserr;   r   r   r   r   r   r;   r   args_strings       r   test_failures_when_not_requiredz'MEMixin.test_failures_when_not_required
  sc    __e_44?
#= 	F 	FKeZ1B1B1D1DEEEE	F 	Fr   c                     |                      d          j        }t          }| j        dgz   D ]+}|                     |||                                           ,d S )NTr  r   r-  r/  s       r   test_failures_when_requiredz#MEMixin.test_failures_when_required
  sj    __d_33>
#=B4/ 	F 	FKeZ1B1B1D1DEEEE	F 	Fr   c                     |                      d          j        }| j        | j        z   }|D ]8\  }} ||                                          }|                     ||           9d S r,  )r.  r;   r   successes_when_not_requiredr   r   )r   r;   r   r0  r   	actual_nss         r    test_successes_when_not_requiredz(MEMixin.test_successes_when_not_required
  sy    __e_44?
NT%EE	(1 	5 	5$K"
;#4#4#6#677IY4444	5 	5r   c                     |                      d          j        }| j        D ]8\  }} ||                                          }|                     ||           9d S NTr  )r.  r;   r   r   r   )r   r;   r0  r   r6  s        r   test_successes_when_requiredz$MEMixin.test_successes_when_required
  sl    __d_33>
(, 	5 	5$K"
;#4#4#6#677IY4444	5 	5r   c                     |                      d          j        }| j        }|                      |            t	          j        |                     d S r,  )r.  r  usage_when_not_requiredr   r  r  r   r  expected_usages      r   test_usage_when_not_requiredz$MEMixin.test_usage_when_not_required
  sL    66C5)H)HIIIIIr   c                     |                      d          j        }| j        }|                      |            t	          j        |                     d S r9  )r.  r  usage_when_requiredr   r  r  r=  s      r   test_usage_when_requiredz MEMixin.test_usage_when_required
  sL    55B1)H)HIIIIIr   c                     |                      d          j        }| j        | j        z   }|                      |            t          j        |                     d S r,  )r.  r  r<  r]  r   r  r  r   r  r]  s      r   test_help_when_not_requiredz#MEMixin.test_help_when_not_required
  sS    oouo55A+di7(=(=>>>>>r   c                     |                      d          j        }| j        | j        z   }|                      |            t          j        |                     d S r9  )r.  r  rA  r]  r   r  r  rD  s      r   test_help_when_requiredzMEMixin.test_help_when_required
  sS    ooto44@'$)3(=(=>>>>>r   N)r   r   r    r1  r3  r7  r:  r?  rB  rE  rG  rA   r   r   r*  r*  
  s        F F FF F F5 5 55 5 5J J J
J J J
? ? ?
? ? ? ? ?r   r*  c                       e Zd ZddZddgZd edd          fd ed	d          fd
 edd          fd edd	          fgZd edd          fgZdZdZ	dZ
dS )TestMutuallyExclusiveSimpleNc                     t          d          }|                    |          }|                    dd           |                    ddd	d
           |S )NrW  r#  r  r1  r_  r  re  r  rb  baz help)rw  r  r]  r   r  r   r   r  r2   r   s       r   r.  z&TestMutuallyExclusiveSimple.get_parser
  sc    +88833X3FF74447#SzJJJr   --bar X --baz Yz--bar X --baz--bar Xr8  rF  rG  z--bar X --bar Zrb  --baz Yre  re  r   z;        usage: PROG [-h] [--bar BAR | --baz [BAZ]]
        z;        usage: PROG [-h] (--bar BAR | --baz [BAZ])
        z
        options:
          -h, --help   show this help message and exit
          --bar BAR    bar help
          --baz [BAZ]  baz help
        rO   r   r   r    r.  r   r{   r   r5  r<  rA  r]  rA   r   r   rI  rI  
  s            "?3H	BB3D)))*	BB3D1112	BB4S)))*	""3'''(	I 
RRDd###$#DDDr   rI  c            
           e Zd ZddZdgZd edddd          fd edddd          fd	 edddd          fd
 edddd          fgZd edddd          fgZdZdZ	dZ
dS )TestMutuallyExclusiveLongNc                 
   t          d          }|                    dd           |                    dd           |                    |          }|                    d	d
           |                    dd           |S )NrW  r#  z--abcdez
abcde helpr  z--fghijz
fghij helpr  z--klmnoz
klmno helpz--pqrstz
pqrst helpr   r   r  rM  s       r   r.  z$TestMutuallyExclusiveLong.get_parser
  s    +888IL999IL99933X3FF9<8889<888r   z--klmno X --pqrst Yz	--klmno Xr8  )abcdefghijklmnopqrstz--abcde Y --klmno Xre  z	--pqrst Xz--pqrst X --fghij Yr   zi    usage: PROG [-h] [--abcde ABCDE] [--fghij FGHIJ]
                [--klmno KLMNO | --pqrst PQRST]
    zi    usage: PROG [-h] [--abcde ABCDE] [--fghij FGHIJ]
                (--klmno KLMNO | --pqrst PQRST)
    z
    options:
      -h, --help     show this help message and exit
      --abcde ABCDE  abcde help
      --fghij FGHIJ  fghij help
      --klmno KLMNO  klmno help
      --pqrst PQRST  pqrst help
    rO   rR  rA   r   r   rT  rT  
  s            &&H	bbt4s$GGGH	BSCt<<<	>	bbt4t3GGGH	BTD<<<	>I 
RRd$d$???@#DDDr   rT  c                       e Zd Zd ZdgZd edd          fd edd          fd	 ed
d          fgZd ed
d          fgZdZdZ	dZ
d
S )$TestMutuallyExclusiveFirstSuppressedc                     t          d          }|                    |          }|                    dt          j                   |                    ddd	           |S )
NrW  r#  r  r   r  r  r  rm  r\  r   r  r   r+   ro  rM  s       r   r.  z/TestMutuallyExclusiveFirstSuppressed.get_parser%  sd    +88833X3FF4h&78884HEEEr   z-x X -yz-x Xr8  Trp  z	-x X -x Yre  r  NFr   z&        usage: PROG [-h] [-y]
        z$        usage: PROG [-h] -y
        zm
        options:
          -h, --help  show this help message and exit
          -y          y help
        rR  rA   r   r   r\  r\  #  s           {H	cT"""#	bb3$'''(	rrDE"""#I 
RR$$ #DDDr   r\  c            	           e Zd Zd Zg dZd eddd          fd eddd          fd	 eddd
          fd eddd          fgZd eddd          fgZdxZZ	dZ
dS )#TestMutuallyExclusiveManySuppressedc                     t          d          }|                    |          }|j        } |ddt          j                    |ddt          j                    |d	t          j        
           |S )NrW  r#  r  --spamr  r\  r0  r  z	--bladderr  r^  )r   r  r2   r   r  s        r   r.  z.TestMutuallyExclusiveManySuppressed.get_parserF  s    +88833X3FF H\0ABBBBJ}83DEEEEKh/0000r   )z--spam --badgerz--badger --bladder Bz--bladder B --spamrb  TN)r  r6  bladderr0  Fz--bladder BrD  z--spam --spamr   z!        usage: PROG [-h]
        P
        options:
          -h, --help  show this help message and exit
        r   r   r    r.  r   r{   r   r5  rA  r<  r]  rA   r   r   r`  r`  D  s            H 
224d;;;<	RRU5$???@	dC@@@A	""$tTBBBC	I 
RRU46667#5 1DDDr   r`  c            
           e Zd Zd Zg dZd eddd          fd ed	d
d          fd ed	ddg          fd ed	dg d          fgZd ed	dd          fgZdZdZ	dZ
dS )*TestMutuallyExclusiveOptionalAndPositionalc                     t          d          }|                    |          }|                    ddd           |                    dd	
           |                    dddd           |S )NrW  r#  r  r   r  FOOr\  rb  SPAMr  r6  r  r8  BADGERrw  ro  r]  rL  rM  s       r   r.  z5TestMutuallyExclusiveOptionalAndPositional.get_parserj  s~    +88833X3FF7<eDDD8&11183(KKKr   )z--foo --spam Sz
--spam S XzX --foozX Y Z --spam Sz	--foo X Yr   TNr8  )r(   r  r6  z--spam SFSzX Y Z)r8  re  rb  r   zD        usage: PROG [-h] [--foo | --spam SPAM | badger ...]
        zD        usage: PROG [-h] (--foo | --spam SPAM | badger ...)
        z
        positional arguments:
          badger       BADGER

        options:
          -h, --help   show this help message and exit
          --foo        FOO
          --spam SPAM  SPAM
        rR  rA   r   r   rg  rg  h  s            H 
""D5556	RREC8889	bbUse4445	""T///BBBC	I 
RRES1112#	DDDr   rg  c                   b   e Zd Zd Zg dZd eddddd          fd eddddd          fd eddddd          fd	 eddddd          fd
 eddddd          fd eddddd          fgZd eddddd          fd eddddd          fd eddddd          fgZdxZZ	dZ
dS )#TestMutuallyExclusiveOptionalsMixedc                 B   t          d          }|                    ddd           |                    |          }|                    ddd	           |                    d
dd           |                    ddd           |                    ddd           |S )NrW  r#  r   r  rj  r\  r  r  a helpr  b helpr  rm  r  c helprV  rM  s       r   r.  z.TestMutuallyExclusiveOptionalsMixed.get_parser  s    +888DHEEE33X3FF48DDD48DDDDHEEE48DDDr   )z-a -b-b -cz-a -cz-a -b -cr  TFr   r  r  r   r^  r  r  z-a -xz-y -bz-x -y -cr   r   r  z:        usage: PROG [-h] [-x] [-a] [-b] [-y] [-c]
        z
        options:
          -h, --help  show this help message and exit
          -x          x help
          -a          a help
          -b          b help
          -y          y help
          -c          c help
        Nre  rA   r   r   ro  ro    sW          766H	rrDEUeu===>	rrETUeu===>	rrEUdeu===>	""tu???@	""u$???@	RR%5DDDAAABI 
RR%5EUe<<<=	rrEUetu===>	rrEUeu===>#5 1	DDDr   ro  c                       e Zd ZddZddgZd edd          fd edd	          fgZd
 edd          fgZdZdZ	dZ
dS )TestMutuallyExclusiveInGroupNc                     t          d          }|                    dd          }|                    |          }|                    dd	           |                    d
d	           |S )NrW  r#  zTitled groupzGroup descriptionr  r  r1  r_  r  re  rK  )r   r   r  r   )r   r  r2   titled_groupmutex_groups        r   r.  z'TestMutuallyExclusiveInGroup.get_parser  s    +88800 .A 1 C C 55x5HH 	  z :::  z :::r   rN  z--baz X --bar YrO  r8  rP  rQ  re  r   z9        usage: PROG [-h] [--bar BAR | --baz BAZ]
        z9        usage: PROG [-h] (--bar BAR | --baz BAZ)
        z
        options:
          -h, --help  show this help message and exit

        Titled group:
          Group description

          --bar BAR   bar help
          --baz BAZ   baz help
        rO   rR  rA   r   r   rw  rw    s            "#45H	BB3D)))*	BB4S)))*I
 
RRDd###$#
DDDr   rw  c                      e Zd Zd Zg dZd eddddd          fd ed	d
ddd          fd ed	dd
dd          fd eddddd
          fd ed	d
ddd
          fgZd ed	dddd          fd ed	dddd
          fgZdxZZ	dZ
d	S )1TestMutuallyExclusiveOptionalsAndPositionalsMixedc                 @   t          d          }|                    dd           |                    ddd	           |                    |
          }|                    ddd           |                    ddd	           |                    ddd	           |S )NrW  r#  r   rj  r  r  r  rm  r\  r  r   r  rq  rp  r  rr  r  rs  rV  rM  s       r   r.  z<TestMutuallyExclusiveOptionalsAndPositionalsMixed.get_parser  s    +888Ch///DHEEE33X3FF3c99948DDD48DDDr   )zX A -brt  z-c X AzX Ard  Fr8  ru  zX -bNTzX -czX A -yzX -y -bzX -yz6        usage: PROG [-h] [-y] [-b] [-c] x [a]
        a   
        positional arguments:
          x           x help
          a           a help

        options:
          -h, --help  show this help message and exit
          -y          y help
          -b          b help
          -c          c help
        re  rA   r   r   r|  r|    s          -,,H	SEUcU;;;<	ddese<<<=	detse<<<=	22u===>	BB#>>>?I 
bb45ESE:::;	deut<<<=#
5 1DDDr   r|  c                   0    e Zd Zd ZdZdZdZdZdZdZ	dZ
dS )TestMutuallyExclusiveNestedc                    t          d          }|                    |          }|                    d           |                    d           t          j                    5  t          j        dt                     |                    |          }d d d            n# 1 swxY w Y   |                    d           |                    d           t          j                    5  t          j        dt                     |                    |          }d d d            n# 1 swxY w Y   |                    d	           |                    d
           |S )NrW  r#  r  r  r  r  r  z-dz-er  )r   r  r   warningscatch_warningssimplefilterDeprecationWarning)r   r  r2   r   r%  group3s         r   r.  z&TestMutuallyExclusiveNested.get_parser  s   +88833X3FF4   4   $&& 	K 	K!(,>???777JJF	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	D!!!D!!!$&& 	L 	L!(,>???88(8KKF	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	L 	D!!!D!!!s$   $1B!!B%(B%)1D&&D*-D*zO        usage: PROG [-h] [-a A | -b B | [-c C | -d D | [-e E | -f F]]]
        zO        usage: PROG [-h] (-a A | -b B | (-c C | -d D | (-e E | -f F)))
        z
        options:
          -h, --help  show this help message and exit
          -a A
          -b B
          -c C
          -d D
          -e E
          -f F
        N)r   r   r    r.  r<  rA  r]  r1  r3  r7  r:  rA   r   r   r  r    sP          "
D '+#"&'+$#'   r   r  c                         e Zd Zd fd	Z xZS )MEPBaseNc                     t          t          |                               |          }t          |j        d|g          }|S )Nr  F)rY  rM  r  )r   r  r.  r   rY  )r   r  r  r2   r   s       r   r.  zMEPBase.get_parserG  sJ    w%%00(0CC+uvh@ @ @r   rO   )r   r   r    r.  r"   r#   s   @r   r  r  E  s=                 r   r  c                       e Zd ZdS )&TestMutuallyExclusiveGroupErrorsParentNr   r   r    rA   r   r   r  r  N          Dr   r  c                       e Zd ZdS )!TestMutuallyExclusiveSimpleParentNr  rA   r   r   r  r  S  r  r   r  c                       e Zd ZdS )TestMutuallyExclusiveLongParentNr  rA   r   r   r  r  X  r  r   r  c                       e Zd ZdS )*TestMutuallyExclusiveFirstSuppressedParentNr  rA   r   r   r  r  ]  r  r   r  c                       e Zd ZdS ))TestMutuallyExclusiveManySuppressedParentNr  rA   r   r   r  r  b  r  r   r  c                       e Zd ZdS )0TestMutuallyExclusiveOptionalAndPositionalParentNr  rA   r   r   r  r  g  r  r   r  c                       e Zd ZdS ))TestMutuallyExclusiveOptionalsMixedParentNr  rA   r   r   r  r  l  r  r   r  c                       e Zd ZdS )7TestMutuallyExclusiveOptionalsAndPositionalsMixedParentNr  rA   r   r   r  r  q  r  r   r  c                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	TestSetDefaultsc           
         t                      }|                    d           |                    dd           |                     t          ddd          |                    g                      |                     t          ddd          |                    g t                                           |                     t          ddd          |                    g t          d                               |                     t          ddd          |                    g t          dd	                               d S )
Nr(   r   rF  ru  )r^  r
  r]  rG  r  )r   r
  r   set_defaultsr   r{   r;   r1   s     r   test_set_defaults_no_argsz)TestSetDefaults.test_set_defaults_no_args{  sS   +--e$$$eq)))eu222**2..	0 	0 	0eu222**2rtt44	6 	6 	6eu222**2rE{{{;;	= 	= 	=eu222**2rEQ/?/?/?@@	B 	B 	B 	B 	Br   c           	         t                      }|                    dd           |                    dd           |                     t	          dd          |                    g                      |                     t	          dd          |                    g t	                                           |                     t	          dd          |                    g t	          d                               |                     t	          d	d          |                    d
                                                     |                     t	          d	d          |                    d
                                t	                                           |                     t	          d	d          |                    d
                                t	          d                               d S )Nr(   rF  rp  r   xfooxrn  rG  r   r  r  )r   r  r   r   r{   r;   r   r1   s     r   test_set_defaults_with_argsz+TestSetDefaults.test_set_defaults_with_args  s   +--eu---D'222g///**2..	0 	0 	0g///**2rtt44	6 	6 	6eu---**2rE{{{;;	= 	= 	=cU+++**6<<>>::	< 	< 	<cU+++**6<<>>244@@	B 	B 	BcU+++**6<<>>2;;;GG	I 	I 	I 	I 	Ir   c                 `   t                      }|                    d           |                                }|                    d          }|                    d           |                     t          dd          |                    d                                                     d S )Nr(   r   r   rF  r  rp  )r   r  rr  rt  r   r{   r;   r   )r   r2   rw  parser_as       r   test_set_defaults_subparsersz,TestSetDefaults.test_set_defaults_subparsers  s    +--e$$$**,,
((--&&&eu---**399;;77	9 	9 	9 	9 	9r   c                     t          d          }|                    d           t          |g          }|                     t          d          |                    g                      d S )NFr  r(   r   r  r  )r   r  r2   s      r   test_set_defaults_parentsz)TestSetDefaults.test_set_defaults_parents  sm    +U;;;e$$$+VH===ef&7&7&;&;<<<<<r   c                 B   t          j                    }|                                                    d          }|                    d           |                    d           |                     t          d          |                    dg                     d S )Nr8  ru  r  r  )r+   r,   rr  rt  r  r   r{   r;   )r   r2   xparsers      r   )test_set_defaults_on_parent_and_subparserz9TestSetDefaults.test_set_defaults_on_parent_and_subparser  s    (**''))44S99"""###F$5$5se$<$<=====r   c                 $   t                      }|                    dddd           |                    d           |                    dd	           |                    d
d           |                    ddd           |                     t	          dddd          |                    g                      |                    dddd           |                     t	          dddd          |                    g                      d S )NWr8  re  rb  r  r\  r   XXrn  r^  r  rv  r
  ZZr  WWYY)r   r  r   r   r{   r;   r1   s     r   &test_set_defaults_same_as_add_argumentz6TestSetDefaults.test_set_defaults_same_as_add_argument  s.   +--cSC3777D!!!D$///Cs+++CsD999 	cTSD999**2..	0 	0 	0 	dcTS999dcTS999**2..	0 	0 	0 	0 	0r   c                 N   t                      }|                    dddd           |                    d          }|                    d           |                    dd	
           |                    dd           |                    ddd           |                     t          dd	dd          |                    g                      |                    dddd           |                     t          dddd          |                    g                      d S )Nr  r8  re  rb  r  r(   r\  r   r  rn  r^  r  rv  r
  r  r  r  r  )r   r  r   r   r   r{   r;   r'  s      r   ,test_set_defaults_same_as_add_argument_groupz<TestSetDefaults.test_set_defaults_same_as_add_argument_group  sA   +--cSC3777))%004   4...3c***3c4888 	cTSD999**2..	0 	0 	0 	dcTS999dcTS999**2..	0 	0 	0 	0 	0r   N)
r   r   r    r  r  r  r  r  r  r  rA   r   r   r  r  y  s        B B BI I I"9 9 9= = => > >0 0 0"0 0 0 0 0r   r  c                       e Zd Zd ZdS )TestGetDefaultc                 8   t                      }|                     |                    d                     |                     |                    d                     |                    d           |                     |                    d                     |                     |                    d                     |                    dt          d           |                     |                    d                     |                     d|                    d                     |                    d           |                     d|                    d                     |                     d|                    d                     d S )	Nr(   rF  r   r1  r  r  r6  r  )r   r  get_defaultr   r  r   r  r1   s     r   test_get_defaultzTestGetDefault.test_get_default  so   +--&,,U33444&,,U33444G$$$&,,U33444&,,U33444G#r:::&,,U33444V//66777)))6#5#5e#<#<===V//6677777r   N)r   r   r    r  rA   r   r   r  r    s#        8 8 8 8 8r   r  c                       e Zd Zd Zd ZdS )TestNamespaceContainsSimplec                     t          j                    }|                     d|           |                     d|           d S )Nr   r   )r+   	NamespaceassertNotInr   nss     r   
test_emptyz&TestNamespaceContainsSimple.test_empty  sB    !!R   b!!!!!r   c                    t          j        dd          }|                     d|           |                     d|           |                     d|           |                     d|           |                     d|           d S )	Nru  r  rp  r   r   r^  xxr
  )r+   r  r  r  r  s     r   test_non_emptyz*TestNamespaceContainsSimple.test_non_empty  s    !q)))R   c2c2r"""b!!!!!r   N)r   r   r    r  r  rA   r   r   r  r    s2        " " "
" " " " "r   r  c                       e Zd Zd ZdS )TestHelpFormattingMetaclassc                 f    |dk    rd S  G d dt                     }dD ]\  }} || ||           d S )NHelpTestCasec                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )6TestHelpFormattingMetaclass.__init__.<locals>.AddTestsc                     || _         || _        | j        | j        | j        fD ]=}|j        d|}|fd}	 ||_        n# t          $ r Y nw xY wt          |||           >d S )Nr   c                      ||            d S rO   rA   r   s     r   test_wrapperzUTestHelpFormattingMetaclass.__init__.<locals>.AddTests.__init__.<locals>.test_wrapper  r   r   )func_suffixstd_nametest_format
test_printtest_print_filer   r   r   )r   
test_classr  r  r   r   r  s          r   r   z?TestHelpFormattingMetaclass.__init__.<locals>.AddTests.__init__	  s    #.  ("&"2"&/"&"6"8 A AI ,5+=+=+={{ KI5> ( ( ( (09--$   J	<@@@@A As   ?
AAc                    t          j        |j        j        i |j        j        }t          |dg           D ]} |j        |j        i |j         t          |dg           }|D ]8\  }} |j        |j        i |j        }|D ]} |j        |j        i |j         9t          |dg           }|r0|                                }	|D ]}
 |	j	        |
j        i |
j         |S )Nr   argument_group_signaturessubparsers_signatures)
r+   r,   r   rv   rw   r   r   r   rr  rt  )r   r   r2   argument_sig
group_sigs	group_sigargument_sigsr   subparsers_sigsrw  subparser_sigs              r   r   zBTestHelpFormattingMetaclass.__init__.<locals>.AddTests._get_parser  s   !0,16-46 6 %,F4I2$N$N ? ?L'F'): ?*6*=? ? ? ?$V-H"MM
0: B B,I}5F5y~ J8A8HJ JE(5 B B**L,= B-9-@B B B BB #*&2I2"N"N" G!'!6!6!8!8J)8 G G-
-}/A G1>1EG G G Gr   c                     t          || j                  }t          j        |          }d |_        |                    ||           d S rO   )r   r  r  r  r  r   )r   r   parser_textexpected_texts       r   _testz<TestHelpFormattingMetaclass.__init__.<locals>.AddTests._test0  sF     '0@ A A ( > >!%""=+>>>>>r   c                     |                      |          }t          |d| j        z            }|                     | |                       d S )Nz	format_%s)r   r   r  r  )r   r   r2   r  s       r   r  zBTestHelpFormattingMetaclass.__init__.<locals>.AddTests.test_format6  sL    ))&11 t7G)GHH

66688,,,,,r   c                    |                      |          }t          |d| j        z            }t          t          | j                  }t          t          | j        t                                 	  |             t          t          | j                                                  }t          t          | j        |           n # t          t          | j        |           w xY w|                     ||           d S Nzprint_%s)	r   r   r  r   r  r   r   r   r  )r   r   r2   print_
old_streamr  s         r   r  zATestHelpFormattingMetaclass.__init__.<locals>.AddTests.test_print;  s    ))&11 d6F)FGG$S$-88
T]KMM:::<FHHH")#t}"="="F"F"H"HKC
;;;;GC
;;;;

6;/////s   06C Cc                     |                      |          }t          |d| j        z            }t                      } ||           |                                }|                     ||           d S r  )r   r   r  r   r   r  )r   r   r2   r  sfiler  s         r   r  zFTestHelpFormattingMetaclass.__init__.<locals>.AddTests.test_print_fileG  sk    ))&11 d6F)FGG#u#nn..

6;/////r   N)	r   r   r    r   r   r  r  r  r  rA   r   r   r   r    sq        A A A"  ,? ? ?- - -

0 
0 
00 0 0 0 0r   r   ))usager   )r]  r   )r   )r   rd   r   r   r   r  r  s          r   r   z$TestHelpFormattingMetaclass.__init__  s|    >!!FF	0 F	0 F	0 F	0 F	0v F	0 F	0 F	0R&: 	1 	1!KHS+x0000	1 	1r   Nry   rA   r   r   r  r    s(        O1 O1 O1 O1 O1r   r  r  c                       e Zd ZdZ eddd          Z edddd	
           eddd           edd           edd           edd          gZg ZdZedz   Z	dZ
dS )TestHelpBiggerOptionals;Make sure that argument help aligns when options are longerrW  DESCRIPTIONEPILOGrY  rZ  epilogra  rv  rw  0.1ry  r   r  X HELPr\  --yY HELPr  r(   FOO HELPrF  BAR HELPz;        usage: PROG [-h] [-v] [-x] [--y Y] foo bar
        aW  
        DESCRIPTION

        positional arguments:
          foo            FOO HELP
          bar            BAR HELP

        options:
          -h, --help     show this help message and exit
          -v, --version  show program's version number and exit
          -x             X HELP
          --y Y          Y HELP

        EPILOG
            0.1
        Nr   r   r    r!   rt   r   r   r  r  r]  rw  rA   r   r   r  r  X  s        EEsM"*, , , 	D+i???DH555E!!!E
###E
### !#E   D GGGr   r  c                   ^    e Zd ZdZd Zej        Zej        Zej        ZdZ	e	dz   Z
ej        ZdS )TestShortColumnszTest extremely small number of columns.

    TestCase prevents "COLUMNS" from being too small in the tests themselves,
    but we don't want any exceptions thrown in such cases. Only ugly representation.
    c                 ~    |                      t          j                              }|                    dd           d S )NrF   rM  )rG   r   rH   rH  rI   s     r   rK   zTestShortColumns.setUp  s8    	 = ? ?@@	4     r   z        usage: PROG
               [-h]
               [-v]
               [-x]
               [--y Y]
               foo
               bar
        a  
        DESCRIPTION

        positional arguments:
          foo
            FOO HELP
          bar
            BAR HELP

        options:
          -h, --help
            show this
            help
            message and
            exit
          -v, --version
            show
            program's
            version
            number and
            exit
          -x
            X HELP
          --y Y
            Y HELP

        EPILOG
    N)r   r   r    r!   rK   r  r   r   r  r  r]  rw  rA   r   r   r  r  |  sf         
! ! ! #:"J"9"M"9"SE   D: #:"AGGGr   r  c                      e Zd ZdZ eddd          Z edddd	
           eddd           edd           edd           edd          gZ edd           edd           eddd          gfgZdZed z   Z	d!Z
d"S )#TestHelpBiggerOptionalGroupsr  rW  r  r  r  ra  rv  rw  r  ry  r   r  r  r\  r  r  r  r(   r  rF  r  zGROUP TITLEzGROUP DESCRIPTIONrf  rG  zBAZ HELPr  r  zZ HELPrp  zN        usage: PROG [-h] [-v] [-x] [--y Y] [-z Z [Z ...]] foo bar baz
        a  
        DESCRIPTION

        positional arguments:
          foo            FOO HELP
          bar            BAR HELP

        options:
          -h, --help     show this help message and exit
          -v, --version  show program's version number and exit
          -x             X HELP
          --y Y          Y HELP

        GROUP TITLE:
          GROUP DESCRIPTION

          baz            BAZ HELP
          -z Z [Z ...]   Z HELP

        EPILOG
    r  Nr  rA   r   r   r  r    s       EEsM"*, , , 	D+i???DH555E!!!E
###E
### 
](;	<	<	<CJ'''CCh///?1 	2!
E   D,GGGr   r  c                       e Zd ZdZ edd          Z eddd           ed	d
           edd           edd          gZg ZdZedz   Z	dZ
dS )TestHelpBiggerPositionalsz4Make sure that help aligns when arguments are longerUSAGEr  r  rZ  r   r  r  r\  r  r  r  ekiekiekifekangzEKI HELPrF  r          usage: USAGE
        a  
        DESCRIPTION

        positional arguments:
          ekiekiekifekang  EKI HELP
          bar              BAR HELP

        options:
          -h, --help       show this help message and exit
          -x               X HELP
          --y Y            Y HELP
        r   Nr  rA   r   r   r  r    s        >>smDDDDH555E!!!J///E
###	 !#E   D GGGr   r  c                       e Zd ZdZ edd          Z eddd           ed	d
d          gZ edd           eddd          gfgZdZedz   Z	dZ
dS )TestHelpReformatting>Make sure that text after short names starts on the first linerW  ze   oddly    formatted
description

that is so long that it should go onto multiple lines when wrappedr^  r   r  zoddly
    formatted -x helprb  r]  r^  r	  znormal y helprd  z'
    oddly formatted group

descriptionrf  r  r  z` oddly 
formatted    -a  help  
    again, so long that it should be wrapped over multiple linesr\  2        usage: PROG [-h] [-x XX] [-a] yyy
        a  
        oddly formatted description that is so long that it should go onto multiple
        lines when wrapped

        positional arguments:
          yyy         normal y help

        options:
          -h, --help  show this help message and exit
          -x XX       oddly formatted -x help

        title:
          oddly formatted group description

          -a          oddly formatted -a help again, so long that it should be wrapped
                      over multiple lines
        r   Nr  rA   r   r   r  r     s        HHs)* * * 	D$ &= 	> 	> 	>C_555 
W #0 
1 
1 
1 #d<$% % % 
&		'
!E   D( GGGr   r  c                       e Zd ZdZ edd          Z eddd           ed	d
d          gZ ed           eddd          gfgZdZedz   Z	dZ
dS )TestHelpWrappingShortNamesr  rW  zZD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
DD
Dr^  r   r  zxXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXr  r^  r	  dYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHALPHASr  r  zPAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAr\  r  a  
        D DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD
        DD DD DD DD D

        positional arguments:
          yyy         YH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH
                      YHYH YHYH YHYH YHYH YHYH YHYH YHYH YH

        options:
          -h, --help  show this help message and exit
          -x XX       XHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH
                      HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HXXHH HX

        ALPHAS:
          -a          AHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH HHAAHHH
                      HHAAHHH HHAAHHH HHA
        r   Nr  rA   r   r   r	  r	  4  s        HHs[AAAD$]333C\222
 
XC\@@@B 	C!E   D, GGGr   r	  c                       e Zd ZdZ edd          Z edddd	           ed
dd           eddd          gZ ed           eddd           eddd          gfgZdZedz   Z	dZ
dS )TestHelpWrappingLongNamesz<Make sure that text after long names starts on the next liner  zZD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD Dr   ra  rv  rw  zZV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV Vry  r   XXXXXXXXXXXXXXXXXXXXXXXXXzdXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHr  r^  yyyyyyyyyyyyyyyyyyyyyyyyyr
  r  r  AAAAAAAAAAAAAAAAAAAAAAAAAzdAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHr
  zzzzzzzzzzzzzzzzzzzzzzzzzzdZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHr  ag  
        D DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD
        DD DD DD DD D

        positional arguments:
          yyyyyyyyyyyyyyyyyyyyyyyyy
                                YH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH
                                YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YHYH YH

        options:
          -h, --help            show this help message and exit
          -v, --version         show program's version number and exit
          -x XXXXXXXXXXXXXXXXXXXXXXXXX
                                XH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH
                                XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XHXH XH

        ALPHAS:
          -a AAAAAAAAAAAAAAAAAAAAAAAAA
                                AH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH
                                AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AHAH AH
          zzzzzzzzzzzzzzzzzzzzzzzzz
                                ZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH
                                ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZHZH ZH
        zs        V VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV VV
        VV VV VV VV V
        Nr  rA   r   r   r  r  \  s        FFszBBBD+iDDDD(666C555 
XCh\:::CXL999; 	<!
E   D<GGGr   r  c                      e Zd ZdZ ed          Z eddd           edd	d
           edd           eddd           eddd           eddej                   edddej                   edddej                   edej        ej        d          g	Z	 ed            ed!dd"           ed#d$d%           ed&d&d	           ed'd'd          gfgZ
d(Zed)z   Zd*Zd+S ),TestHelpUsageTest basic usage messagesrW  r#  r\  r  rg   rp  r   r  r   r   r  r  r  )r]  rw  r  r  r   zWhether to foo)r]  r  r1  zWhether to barT)r]  ro  r  r  z--foobarz--barfoor  z--bazzzBazz!)r  ro  r]  r   r  r^  r  rz  r
  r8  r   a/          usage: PROG [-h] [-w W [W ...]] [-x [X ...]] [--foo | --no-foo]
                    [--bar | --no-bar]
                    [-f | --foobar | --no-foobar | --barfoo | --no-barfoo]
                    [--bazz | --no-bazz] [-y [Y]] [-z Z Z Z]
                    a b b [c] [d ...] e [e ...]
        az  
        positional arguments:
          a                     a
          b                     b
          c                     c

        options:
          -h, --help            show this help message and exit
          -w W [W ...]          w
          -x [X ...]            x
          --foo, --no-foo       Whether to foo
          --bar, --no-bar       Whether to bar
          -f, --foobar, --no-foobar, --barfoo, --no-barfoo
          --bazz, --no-bazz     Bazz!

        group:
          -y [Y]                y
          -z Z Z Z              z
          d                     d
          e                     e
        r   N)r   r   r    r!   rt   r   r+   r  ro  r   r  r  r]  rw  rA   r   r   r  r    s       ##s'''D#&&&D#&&&CcCc###Cc%%%G*83QRRRG*D$:	< 	< 	<D*j1OPPPHX;&/g	? 	? 	? 
WCCc***CAC(((C#S)))C#S)))	
 	!E   D, GGGr   r  c                   n    e Zd Z ed          Z edd           eddd          gZd	Zed
z   ZdZdS )TestHelpUsageWithParenthesesrW  r#  
positionalz(example) positionalrb  r  z
--optionalz{1 (option A), 2 (option B)}zX        usage: PROG [-h] [-p {1 (option A), 2 (option B)}] (example) positional
        z
        positional arguments:
          (example) positional

        options:
          -h, --help            show this help message and exit
          -p {1 (option A), 2 (option B)}, --optional {1 (option A), 2 (option B)}
        r   N)	r   r   r    rt   r   r   r  r]  rw  rA   r   r   r  r    sp        s'''L"8999D,(FGGG
E   D GGGr   r  c                       e Zd ZdZ edd          Zg Z ed           edd           ed	d	          gf ed
           edd           edd          gfgZdZedz   Z	dZ
dS )TestHelpOnlyUserGroupsr  rW  FrY  rM  xxxxr   r   r  r   yyyyr  r  r^  z.        usage: PROG [-x X] [-y Y] a b
        zn
        xxxx:
          -x X  x
          a     a

        yyyy:
          b     b
          -y Y  y
        r   Nr  rA   r   r   r  r    s        ##s777	VC3C#
 	 
VC#C3
 		!E  	 	D GGGr   r  c                       e Zd ZdZ ed          Z edd           edd           ed	           ed
          gZg ZdZedz   Z	dZ
dS )TestHelpUsageLongProgz*Test usage messages where the prog is long<PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPr#  r\  r  r  r   r8  r   r  zz        usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
               [-h] [-w W] [-x X] a b
        z
        positional arguments:
          a
          b

        options:
          -h, --help  show this help message and exit
          -w W
          -x X
        r   Nr  rA   r   r   r  r     s        44s)))D#D#CC	 !#E  
 
D GGGr   r  c                       e Zd ZdZ ed          Z edd           edd           ed	d
           edd           ed           ed          gZg ZdZedz   Z	dZ
dS ) TestHelpUsageLongProgOptionsWrapzATest usage messages where the prog is long and the optionals wrapr   r#  r\  WWWWWWWWWWWWWWWWWWWWWWWWWr  r   r  r  YYYYYYYYYYYYYYYYYYYYYYYYYr  ZZZZZZZZZZZZZZZZZZZZZZZZZr   r  a          usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
               [-h] [-w WWWWWWWWWWWWWWWWWWWWWWWWW] [-x XXXXXXXXXXXXXXXXXXXXXXXXX]
               [-y YYYYYYYYYYYYYYYYYYYYYYYYY] [-z ZZZZZZZZZZZZZZZZZZZZZZZZZ]
               a b
        a-  
        positional arguments:
          a
          b

        options:
          -h, --help            show this help message and exit
          -w WWWWWWWWWWWWWWWWWWWWWWWWW
          -x XXXXXXXXXXXXXXXXXXXXXXXXX
          -y YYYYYYYYYYYYYYYYYYYYYYYYY
          -z ZZZZZZZZZZZZZZZZZZZZZZZZZ
        r   Nr  rA   r   r   r"  r"    s        KKs)))D(###D(###D(###D(###CC !#E   D GGGr   r"  c                       e Zd ZdZ edd          Z ed           ed           ed          gZg ZdZed	z   Z	d
Z
dS )$TestHelpUsageLongProgPositionalsWrapzCTest usage messages where the prog is long and the positionals wrapr   Fr  aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccz        usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
               aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb
               ccccccccccccccccccccccccc
        
        positional arguments:
          aaaaaaaaaaaaaaaaaaaaaaaaa
          bbbbbbbbbbbbbbbbbbbbbbbbb
          ccccccccccccccccccccccccc
        r   Nr  rA   r   r   r'  r'  A  sy        MMs5999HHH
 !#E
   D GGGr   r'  c            	           e Zd ZdZ ed          Z edd           edd           ed	d
           edd           ed           ed           ed          gZg ZdZedz   Z	dZ
dS )TestHelpUsageOptionalsWrapz,Test usage messages where the optionals wraprW  r#  r\  r#  r  r   r  r  r$  r  r%  r   r  r  z        usage: PROG [-h] [-w WWWWWWWWWWWWWWWWWWWWWWWWW] [-x XXXXXXXXXXXXXXXXXXXXXXXXX]
                    [-y YYYYYYYYYYYYYYYYYYYYYYYYY] [-z ZZZZZZZZZZZZZZZZZZZZZZZZZ]
                    a b c
        a9  
        positional arguments:
          a
          b
          c

        options:
          -h, --help            show this help message and exit
          -w WWWWWWWWWWWWWWWWWWWWWWWWW
          -x XXXXXXXXXXXXXXXXXXXXXXXXX
          -y YYYYYYYYYYYYYYYYYYYYYYYYY
          -z ZZZZZZZZZZZZZZZZZZZZZZZZZ
        r   Nr  rA   r   r   r-  r-  Z  s        66s'''D(###D(###D(###D(###CCC !#E   D GGGr   r-  c                       e Zd ZdZ ed          Z ed           ed           ed           ed           ed           ed	          gZg Zd
Zedz   Z	dZ
dS )TestHelpUsagePositionalsWrapz.Test usage messages where the positionals wraprW  r#  r   r  r  r(  r)  r*  z        usage: PROG [-h] [-x X] [-y Y] [-z Z]
                    aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb
                    ccccccccccccccccccccccccc
        a  
        positional arguments:
          aaaaaaaaaaaaaaaaaaaaaaaaa
          bbbbbbbbbbbbbbbbbbbbbbbbb
          ccccccccccccccccccccccccc

        options:
          -h, --help            show this help message and exit
          -x X
          -y Y
          -z Z
        r   Nr  rA   r   r   r/  r/    s        88s'''D		D		D		HHH !#E
   D GGGr   r/  c                       e Zd ZdZ ed          Z edd           edd           ed	d
           ed           ed           ed          gZg ZdZedz   Z	dZ
dS )%TestHelpUsageOptionalsPositionalsWrapz<Test usage messages where the optionals and positionals wraprW  r#  r   r  r  r  r$  r  r%  r(  r)  r*  a          usage: PROG [-h] [-x XXXXXXXXXXXXXXXXXXXXXXXXX] [-y YYYYYYYYYYYYYYYYYYYYYYYYY]
                    [-z ZZZZZZZZZZZZZZZZZZZZZZZZZ]
                    aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb
                    ccccccccccccccccccccccccc
        aZ  
        positional arguments:
          aaaaaaaaaaaaaaaaaaaaaaaaa
          bbbbbbbbbbbbbbbbbbbbbbbbb
          ccccccccccccccccccccccccc

        options:
          -h, --help            show this help message and exit
          -x XXXXXXXXXXXXXXXXXXXXXXXXX
          -y YYYYYYYYYYYYYYYYYYYYYYYYY
          -z ZZZZZZZZZZZZZZZZZZZZZZZZZ
        r   Nr  rA   r   r   r1  r1    s        FFs'''D(###D(###D(###HHH !#E   D GGGr   r1  c                       e Zd ZdZ ed          Z edd           edd           ed	d
          gZg ZdZedz   Z	dZ
dS )TestHelpUsageOptionalsOnlyWrapz@Test usage messages where there are only optionals and they wraprW  r#  r   r  r  r  r$  r  r%  z        usage: PROG [-h] [-x XXXXXXXXXXXXXXXXXXXXXXXXX] [-y YYYYYYYYYYYYYYYYYYYYYYYYY]
                    [-z ZZZZZZZZZZZZZZZZZZZZZZZZZ]
        z
        options:
          -h, --help            show this help message and exit
          -x XXXXXXXXXXXXXXXXXXXXXXXXX
          -y YYYYYYYYYYYYYYYYYYYYYYYYY
          -z ZZZZZZZZZZZZZZZZZZZZZZZZZ
        r   Nr  rA   r   r   r3  r3    s        JJs'''D(###D(###D(###
 !#E
   D GGGr   r3  c                       e Zd ZdZ edd          Z ed           ed           ed          gZg ZdZed	z   Z	d
Z
dS ) TestHelpUsagePositionalsOnlyWrapzBTest usage messages where there are only positionals and they wraprW  Fr  r(  r)  r*  z~        usage: PROG aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb
                    ccccccccccccccccccccccccc
        r+  r   Nr  rA   r   r   r5  r5    sy        LLs777HHH
 !#E   D GGGr   r5  c            
       4   e Zd ZdZ ed          Z eded           eddd	d
d           eddd           eddddgdd           edd           eddd          gZ ed           ed d!           ed"d#d$          gfgZd%Z	e	d&z   Z
d'Zd(S ))TestHelpVariableExpansionz:Test that variables are expanded properly in help messagesrW  r#  r   z"x %(prog)s %(default)s %(type)s %%r`  r  r  r  XXXz y %(prog)s %(default)s %(const)s)r  ro  r  r]  r   r  z$foo %(prog)s %(default)s %(choices)srk  r1  rG  ru  r  BBBz!bar %(prog)s %(default)s %(dest)s)ro  r  rb  r]  r  zspam %(prog)s %(default)sr  r6  rj  zbadger %(prog)s %(default)s)ro  r]  r   r  za %(prog)s %(default)sr  r  zb %(prog)s %(default)szw        usage: PROG [-h] [-x X] [-y] [--foo {a,b,c}] [--bar BBB] [-a A] [-b B]
                    spam badger
        a  
        positional arguments:
          spam           spam PROG None
          badger         badger PROG 0.5

        options:
          -h, --help     show this help message and exit
          -x X           x PROG None int %
          -y             y PROG 42 XXX
          --foo {a,b,c}  foo PROG None a, b, c
          --bar BBB      bar PROG baz bar

        group:
          -a A           a PROG None
          -b B           b PROG -1
        r   N)r   r   r    r!   rt   r   r  r   r  r  r]  rw  rA   r   r   r7  r7    s5       DDs'''Ds5	7 	7 	7D%3	5 	5 	5GU7	9 	9 	9GUQFE4	6 	6 	6F4555Hc(EFFF 
WC3444Cb'?@@@
 	!E   D" GGGr   r7  c                   F    e Zd ZdZ edd          Zg Zg ZdZedz   Z	dZ
dS )	&TestHelpVariableExpansionUsageSuppliedz@Test that variables are expanded properly when usage= is presentrW  z%(prog)s FOOrY  r  z         usage: PROG FOO
        rd  r   Nr  rA   r   r   r;  r;  &  sT        JJsn=== "E   D
 GGGr   r;  c                   @    e Zd ZdZ edd          Zg Zg ZdZeZ	dZ
dS )$TestHelpVariableExpansionNoArgumentsz;Test that variables are expanded properly with no argumentsrW  Fr  z        usage: PROG
        r   Nr  rA   r   r   r>  r>  7  sH        EEs777 "E DGGGr   r>  c                   z    e Zd ZdZ edej                  Z edd           edd          gZg Z	d	Z
d
Zd
ZdS )TestHelpSuppressUsagez3Test that items can be suppressed in usage messagesrW  r<  r   r[  r  r  	spam helpz        positional arguments:
          spam        spam help

        options:
          -h, --help  show this help message and exit
          --foo FOO   foo help
        r   N)r   r   r    r!   rt   r+   ro  r   r   r  r]  r  rw  rA   r   r   r@  r@  D  ss        ==sh.?@@@G*%%%F%%% !#D EGGGr   r@  c                       e Zd ZdZ edd          Z edej                   edd          gZg Z	d	Z
e
d
z   ZdZdS )TestHelpSuppressOptionalz?Test that optional arguments can be suppressed in help messagesrW  Fr  r   r  r  rA  z!        usage: PROG spam
        zA
        positional arguments:
          spam  spam help
        r   Nr   r   r    r!   rt   r   r+   ro  r   r  r  r]  rw  rA   r   r   rC  rC  Y  s        IIs777G(+,,,F%%% !#E   D
 GGGr   rC  c                       e Zd ZdZ ed          Z edd           edd          gZ ed	           ed
ej                  gfgZ	dZ
e
dz   ZdZdS )TestHelpSuppressOptionalGroupz<Test that optional groups can be suppressed in help messagesrW  r#  r   r[  r  r  rA  r   r1  2        usage: PROG [-h] [--foo FOO] spam
        
        positional arguments:
          spam        spam help

        options:
          -h, --help  show this help message and exit
          --foo FOO   foo help
        r   N)r   r   r    r!   rt   r   r   r+   ro  r  r  r]  rw  rA   r   r   rF  rF  m  s        FFs'''G*%%%F%%%
 
WG(*;<<<=>!E   D GGGr   rF  c                   ~    e Zd ZdZ ed          Z edd           edej                  gZg Z	dZ
e
d	z   Zd
ZdS )TestHelpSuppressPositionalzATest that positional arguments can be suppressed in help messagesrW  r#  r   r[  r  r  z-        usage: PROG [-h] [--foo FOO]
        o
        options:
          -h, --help  show this help message and exit
          --foo FOO   foo help
        r   NrD  rA   r   r   rJ  rJ    s}        KKs'''G*%%%F*+++ !#E   D GGGr   rJ  c                   ^    e Zd ZdZ ed          Z eddd          gZg ZdZed	z   Z	d
Z
dS )TestHelpRequiredOptionalz.Test that required options don't look optionalrW  r#  r   Tr[  )r  r]  z+        usage: PROG [-h] --foo FOO
        rK  r   Nr  rA   r   r   rM  rM    sj        88s'''Gd444 !#E   D GGGr   rM  c                   |    e Zd ZdZ eddd          Z eddd	           ed
dd          gZg ZdZedz   Z	dZ
dS )TestHelpAlternatePrefixCharsz:Test that options display with different prefix charactersrW  z^;F)rY  rL  rM  z^^foor  r[  r\  z;bz;;barr_  r  z-        usage: PROG [^^foo] [;b BAR]
        zf
        options:
          ^^foo              foo help
          ;b BAR, ;;bar BAR  bar help
        r   Nr  rA   r   r   rO  rO    s        DDsTEJJJGLz:::D'
+++ !#E   D GGGr   rO  c                   v    e Zd ZdZ edd          Z edd           edd	          gZg Zd
Zedz   Z	dZ
dS )TestHelpNoHelpOptionalz=Test that the --help argument can be suppressed help messagesrW  Fr  r   r[  r  r  rA  z-        usage: PROG [--foo FOO] spam
        zv
        positional arguments:
          spam       spam help

        options:
          --foo FOO  foo help
        r   Nr  rA   r   r   rQ  rQ    s|        GGs777G*%%%F%%% !#E   D GGGr   rQ  c                   l    e Zd ZdZ ed          Z ed           ed          gZg ZdZedz   Z	dZ
d	S )
TestHelpNonez1Test that no errors occur if no help is specifiedrW  r#  r   r  rG  z
        positional arguments:
          spam

        options:
          -h, --help  show this help message and exit
          --foo FOO
        r   Nr  rA   r   r   rS  rS    sl        ;;s'''GF !#E   D GGGr   rS  c            	           e Zd ZdZ ed          Z edddd           ed	d
dd           edddd           edddd          gZg ZdZedz   Z	dZ
dS )TestHelpTupleMetavarz"Test specifying metavar as a tuplerW  r#  r\  rg   r  )W1W2)r]  rw  rb  r   r   r  )X1X2r  r^  rz  )Y1Y2Y3r  r
  r  )Z1z]        usage: PROG [-h] [-w W1 [W2 ...]] [-x [X1 [X2 ...]]] [-y Y1 Y2 Y3] [-z [Z1]]
        z
        options:
          -h, --help        show this help message and exit
          -w W1 [W2 ...]    w
          -x [X1 [X2 ...]]  x
          -y Y1 Y2 Y3       y
          -z [Z1]           z
        r   Nr  rA   r   r   rU  rU    s        ,,s'''Ds#|<<<Ds#|<<<Ds!-?@@@Ds#x888	 !#E   D GGGr   rU  c                       e Zd ZdZ edej        d          Z edd           edd	          gZ ed
d           edd          gfgZ	dZ
e
dz   ZdZdS )TestHelpRawTextTest the RawTextHelpFormatterrW  7Keep the formatting
    exactly as it is written

here
rY  formatter_classrZ  r   z-    foo help should also
appear as given herer  r  rA  rd  ?    This text
  should be indented
    exactly like it is here
rf  r1  r_  >        usage: PROG [-h] [--foo FOO] [--bar BAR] spam
        a  
        Keep the formatting
            exactly as it is written

        here

        positional arguments:
          spam        spam help

        options:
          -h, --help  show this help message and exit
          --foo FOO       foo help should also
                      appear as given here

        title:
              This text
            should be indented
              exactly like it is here

          --bar BAR   bar help
        r   N)r   r   r    r!   rt   r+   RawTextHelpFormatterr   r   r  r  r]  rw  rA   r   r   r_  r_    s        ''sX%B   	G 1 	2 	2 	2F%%% 
W #B 
C 
C 
C #gJ
'
'
'	(	*!E   D, GGGr   r_  c                       e Zd ZdZ edej        d          Z edd           edd	          gZ ed
d           edd          gfgZ	dZ
e
dz   ZdZdS )TestHelpRawDescriptionr`  rW  ra  rb  r   z4  foo help should not
    retain this odd formattingr  r  rA  rd  rd  rf  r1  r_  re  a  
        Keep the formatting
            exactly as it is written

        here

        positional arguments:
          spam        spam help

        options:
          -h, --help  show this help message and exit
          --foo FOO   foo help should not retain this odd formatting

        title:
              This text
            should be indented
              exactly like it is here

          --bar BAR   bar help
        r   N)r   r   r    r!   rt   r+   RawDescriptionHelpFormatterr   r   r  r  r]  rw  rA   r   r   rh  rh  @  s        ''sX%I   	G ; 	< 	< 	<F%%% 
W #B 
C 
C 
C #gJ
'
'
'	(	*!E   D* GGGr   rh  c                   `   e Zd ZdZ edej        d          Z edd           edd	d
           edej        dd           edej        dej	                   eddd           edd           edddd          gZ
 edd           ededd !          gfgZd"Zed#z   Zd$Zd%S )&TestHelpArgumentDefaultsz&Test the ArgumentDefaultsHelpFormatterrW  rZ  rb  r   z)foo help - oh and by the way, %(default)sr  r1  r  r_  r\  z--tazzWhether to taz itT)r  r]  ro  z--corgezWhether to corge itz--quuxzSet the quuxr  )r]  ro  r  rA  r6  r  woodenzbadger helprl  rd  rf  re  rK  )r   ro  r]  z        usage: PROG [-h] [--foo FOO] [--bar] [--taz | --no-taz] [--corge | --no-corge]
                    [--quux QUUX] [--baz BAZ]
                    spam [badger]
        ay  
        description

        positional arguments:
          spam                 spam help
          badger               badger help (default: wooden)

        options:
          -h, --help           show this help message and exit
          --foo FOO            foo help - oh and by the way, None
          --bar                bar help (default: False)
          --taz, --no-taz      Whether to taz it (default: True)
          --corge, --no-corge  Whether to corge it
          --quux QUUX          Set the quux (default: 42)

        title:
          description

          --baz BAZ            baz help (default: 42)
        r   N)r   r   r    r!   rt   r+   ArgumentDefaultsHelpFormatterr   r  ro  r   r  r  r  r]  rw  rA   r   r   rk  rk  p  sC       00sX%K!# # #
 	GEFFFGLz:::GH:$d	4 	4 	4Ih<&0A	C 	C 	CH>2666F%%%HCFFF
 
W-	0	0	0
#gC*
=
=
=	>	@!E
   D* GGGr   rk  c                   b    e Zd ZdZ edd          Z edddd	          gZg Zd
Zedz   Z	dZ
dS )TestHelpVersionActionz,Test the default help for the version actionrW  rZ  r^  -Vrv  rw  z3.6ry  z&        usage: PROG [-h] [-V]
        z
        description

        options:
          -h, --help     show this help message and exit
          -V, --version  show program's version number and exit
        r   Nr  rA   r   r   ro  ro    sj        66sMBBB3t[ERRRS "E   D GGGr   ro  c                       e Zd ZdZ ed          Z eddddej                   ed	d
           edd          gZg Z	dZ
e
dz   ZdS )TestHelpVersionActionSuppresszCTest that the --version argument can be suppressed in help messagesrW  r#  ra  rv  rw  rx  )r  rw  r]  r   r[  r  r  rA  rG  rH  N)r   r   r    r!   rt   r   r+   ro  r   r  r  r]  rA   r   r   rr  rr    s        MMs'''D+i"	$ 	$ 	$G*%%%F%%%	 !#E   DDDr   rr  c                   v    e Zd ZdZ edd          Z edddd	          gZd
 dD             ZdZedz   Z	dZ
dS )TestHelpSubparsersOrdering5Test ordering of subcommands in help matches the coderW  display some subcommandsr^  ra  rv  rw  r  ry  c                 .    g | ]}t          |           S )r  rt   )r   rd   s     r   r   z%TestHelpSubparsersOrdering.<listcomp>  s6     D D D!% !d^^^ D D Dr   )r   r  r  r8  r   6        usage: PROG [-h] [-v] {a,b,c,d,e} ...
        z
        display some subcommands

        positional arguments:
          {a,b,c,d,e}

        options:
          -h, --help     show this help message and exit
          -v, --version  show program's version number and exit
        r  N)r   r   r    r!   rt   r   r   r  r  r]  rw  rA   r   r   rt  rt    s        ??s'AC C C3t[ERRRSD D)BD D DE  
 
DGGGr   rt  c                   z    e Zd ZdZ edd          Z edddd	          gZd
Zd eD             ZdZ	e	dz   Z
dZdS )"TestHelpSubparsersWithHelpOrderingru  rW  rv  r^  ra  rv  rw  r  ry  ))r   za subcommand help)r  zb subcommand help)r  zc subcommand help)r8  zd subcommand help)r   ze subcommand helpc                 6    g | ]\  }}t          ||           S ))rd   r]  rx  )r   rd   r]  s      r   r   z-TestHelpSubparsersWithHelpOrdering.<listcomp>  s?     @ @ @!+t !d666 @ @ @r   ry  a  
        display some subcommands

        positional arguments:
          {a,b,c,d,e}
            a            a subcommand help
            b            b subcommand help
            c            c subcommand help
            d            d subcommand help
            e            e subcommand help

        options:
          -h, --help     show this help message and exit
          -v, --version  show program's version number and exit
        r  N)r   r   r    r!   rt   r   r   subcommand_datar  r  r]  rw  rA   r   r   r{  r{    s        ??s'AC C C3t[ERRRSO@ @/>@ @ @E   D"GGGr   r{  c                       e Zd Zd Z eddej                  Z ede           ede           ede	d	
          gZ
g ZdZedz   ZdZdS )TestHelpMetavarTypeFormatterc                     | S rO   rA   r%  s    r   custom_typez(TestHelpMetavarTypeFormatter.custom_type  s    r   rW  rZ  )rY  rZ  rc  r   rh  r  r  z
SOME FLOAT)r   rb  zF        usage: PROG [-h] [-b custom_type] [-c SOME FLOAT] int
        z
        description

        positional arguments:
          int

        options:
          -h, --help      show this help message and exit
          -b custom_type
          -c SOME FLOAT
        r   N)r   r   r    r  rt   r+   MetavarTypeHelpFormatterr   r  rk  r   r  r  r]  rw  rA   r   r   r  r    s           sM+3+LN N N3s---3t+6663t%FFFH !#E   D GGGr   r  c                   l    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S )TestInvalidArgumentConstructorsz-Test a bunch of invalid Argument constructorsc                 d    t          j                    } | j        t          |j        g|R i | d S rO   )r+   r,   r   r   r   r   rv   rw   r2   s       r   assertTypeErrorz/TestInvalidArgumentConstructors.assertTypeError;  sR    (**)V%8 	+	+ 	+ 	+#)	+ 	+ 	+ 	+ 	+r   c                 d    t          j                    } | j        t          |j        g|R i | d S rO   )r+   r,   r   r  r   r  s       r   assertValueErrorz0TestInvalidArgumentConstructors.assertValueError@  sR    (***f&9 	+	+ 	+ 	+#)	+ 	+ 	+ 	+ 	+r   c                     |                      dd            |                      dd           |                      dd           |                      di            d S )	Nr   )rF  r  r(   )callbackrA   )callback_args)callback_kwargsr  r   s    r   test_invalid_keyword_argumentsz>TestInvalidArgumentConstructors.test_invalid_keyword_argumentsE  sl    Tt,,,TE222T444T266666r   c                 d    |                                   dD ]}|                      |           d S )N)r  r  r  r  r   r  s     r   test_missing_destinationz8TestInvalidArgumentConstructors.test_missing_destinationK  sG    ) 	0 	0F   ////	0 	0r   c                 Z    |                      d           |                      d           d S )Nr  z---r  r   s    r   test_invalid_option_stringsz;TestInvalidArgumentConstructors.test_invalid_option_stringsP  s0    d###e$$$$$r   c                 z    |                      dd           |                      dt          t          f           d S )Nr   r  rh  )r  r  rk  r   s    r   test_invalid_typez1TestInvalidArgumentConstructors.test_invalid_typeT  s>    gE222gS%L99999r   c                    |                      dd           |                      dd           |                      dd           t          j                    }|                     t                    5 }|                    dd           d d d            n# 1 swxY w Y   |                     dt          |j                             d S )	Nr   r(   r  rG  r   r  r  z
store-truezunknown action)	r  r+   r,   r   r  r   r  r   r  r  s      r   test_invalid_actionz3TestInvalidArgumentConstructors.test_invalid_actionX  s    d5111eE222g.ABBB(**z** 	>b===	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>&BL(9(9:::::s   3BBBc                 :   t          j                    }|                    d           |                     t                    5 }|                    dd           d d d            n# 1 swxY w Y   |                     dt          |j                             d S )Nr(   r)  rF  rG  z+dest supplied twice for positional argument)r+   r,   r   r   r  r  r   r  r  s      r   test_multiple_destz2TestInvalidArgumentConstructors.test_multiple_desta  s    (**'''z** 	3bE222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3C",''	) 	) 	) 	) 	)s   A((A,/A,c                     dD ]H}t          t                    t          d          t          d          fD ]} | j        d	d|i| Id S )
N)r  r  r  r  r  rh  r  rv  abr  r   r  )r   )rs  r  r  )r   r  attrss      r   test_no_argument_actionsz8TestInvalidArgumentConstructors.test_no_argument_actionsi  s~    0 	C 	CFC...$S///t,,,. C C$$BB&BEBBBBC	C 	Cr   c                 p    dD ]2}|                      dd|           |                      dd|           3d S )N)r  r  r  r   r(   r  r  rw  r  r  r  s     r   !test_no_argument_no_const_actionszATestInvalidArgumentConstructors.test_no_argument_no_const_actionsp  s\    < 	A 	AF   U6 BBB   S @@@@	A 	Ar   c                     dD ]i}|                      dd|           |                      dd|           dD ]4}|                      dd||           |                      dd||           5jd S )	Nr  r   r   r  r  )ru  r  r  r(   )r  rw  r  r  )r   r  rw  s      r   #test_more_than_one_argument_actionszCTestInvalidArgumentConstructors.test_more_than_one_argument_actionsz  s    ) 	B 	BF !!$a!???!!&&!AAA ' B B%%d%,1& & B B B%%fE,1& & B B B BB	B 	Br   c                 @    dD ]}|                      dd|           d S )N)r  r  r   r  r  r  r  s     r   test_required_const_actionsz;TestInvalidArgumentConstructors.test_required_const_actions  s?    5 	A 	AF   S @@@@	A 	Ar   c                     |                      dd           |                      ddd           |                      ddt          j                   d S )Nr  parsersr  rW  )r  rY  )r  r   )r  r+   r,   r   s    r   "test_parsers_action_missing_paramszBTestInvalidArgumentConstructors.test_parsers_action_missing_params  sl    Yy999YyvFFFYy*2*A 	 	C 	C 	C 	C 	Cr   c                 4    |                      dd           d S )Nr(   Tr  r  r   s    r   test_required_positionalz8TestInvalidArgumentConstructors.test_required_positional  s!    UT22222r   c                      G d dt                      G fddt                    }t          j                    }|                     |j        d|           |                     |j        d|           d S )Nc                       e Zd ZdS )ITestInvalidArgumentConstructors.test_user_defined_action.<locals>.SuccessNr  rA   r   r   Successr    s        Dr   r  c                   $    e Zd Z	 d fd	Zd ZdS )HTestInvalidArgumentConstructors.test_user_defined_action.<locals>.ActionFc                 @    |dk    r|u r|u r             d S d S d S )Nr  rA   )r   option_stringsr*  r  ro  r  r  s         r   r   zQTestInvalidArgumentConstructors.test_user_defined_action.<locals>.Action.__init__  sB     6>>''"g--")'))O ">''--r   c                     d S rO   rA   rx   s      r   r7  zQTestInvalidArgumentConstructors.test_user_defined_action.<locals>.Action.__call__  s    r   N)F)r   r   r    r   r7  )r  s   r   r?  r    sG         #(	, 	, 	, 	, 	, 	,    r   r?  rb  )r  ro  r  r  )r   r   r+   r,   r   r   )r   r?  r2   r  s      @r   test_user_defined_actionz8TestInvalidArgumentConstructors.test_user_defined_action  s    	 	 	 	 	i 	 	 		 	 	 	 	 	 	V 	 	 	  (**'6#6!' 	 	I 	I 	I'6#6!' 	 	I 	I 	I 	I 	Ir   N)r   r   r    r!   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rA   r   r   r  r  8  s       77+ + +
+ + +
7 7 70 0 0
% % %: : :; ; ;) ) )C C CA A AB B BA A AC C C3 3 3I I I I Ir   r  c                       e Zd Zd Zd ZdS )TestActionsReturnedc                 P   t          j                    }|                    d          }|                     |j        d           |                    dd          }|                     |j        d           |                    dd          }|                     |j        d           d S )	Nr   r(   r  r1  rF  r   r  r   )r+   r,   r   r   r*  r   r2   r  s      r   r  zTestActionsReturned.test_dest  s    (**$$W--e,,,$$T733e,,,$$T400c*****r   c                 4   t          j                    }|                    ddddt          ddgddd	
	  	        }|                     |j        d           |                     |j        d           |                     |j        d           |                     |j        t                     |                     |j	        ddg           |                     |j
        d           |                     |j        d           |                     |j        d	           d S )Nr   r  r  r  ru  r  ri  BARrG  )rw  r  ro  r   r  r]  rb  r*  )r+   r,   r   r  r   rw  r  ro  r   r  r]  rb  r*  r  s      r   	test_misczTestActionsReturned.test_misc  s   (**$$WCr-/cAq6*/U % L L 	s+++r***,,,c***!Q000e,,,///e,,,,,r   N)r   r   r    r  r  rA   r   r   r  r    s2        + + +- - - - -r   r  c                   &    e Zd Zd Zd Zd Zd ZdS )TestConflictHandlingc                 T    |                      t          t          j        d           d S )Nr(   )conflict_handler)r   r  r+   r,   r   s    r   test_bad_typez"TestConflictHandling.test_bad_type  s3    *h&=+0 	 	2 	2 	2 	2 	2r   c                    t          j                    }|                    d           |                     t           j        |j        d           |                    d           |                     t           j        |j        d           d S )Nr   rb  )r+   r,   r   r   r  r1   s     r   test_conflict_errorz(TestConflictHandling.test_conflict_error  s    (**D!!!(0 -t	5 	5 	5H%%%(0 -x	9 	9 	9 	9 	9r   c                    t           j        } |dd          }|                    dd           |                    dd           |                     |                                t          j        d                     |                    d	d
           |                    d	d           |                     |                                t          j        d                     d S )NrW  resolve)rY  r  r   zOLD Xr  zNEW Xz            usage: PROG [-h] [-x X]

            options:
              -h, --help  show this help message and exit
              -x X        NEW X
            rb  OLD_SPAMr  NEW_SPAMz            usage: PROG [-h] [-x X] [--spam NEW_SPAM]

            options:
              -h, --help       show this help message and exit
              -x X             NEW X
              --spam NEW_SPAM
            )r+   r,   r   r   r  r  r  )r   r.  r2   s      r   test_resolve_errorz'TestConflictHandling.test_resolve_error  s   ,
)DDDDw///Dw///++--x @ 0 0 	 	 	 	Hj999Hj999++--x @ 0 0 	 	 	 	 	r   c                    t          j                    }|                                }|                    ddg           |                     t           j        |j        d           |                     t           j        |j        d           |                     t           j        |j        ddg           |                     t           j        |j        ddg           d S )Nfullnamealiasr  r   )r+   r,   rr  rt  r   r  )r   r2   sps      r   test_subparser_conflictz,TestConflictHandling.test_subparser_conflict  s    (**""$$
j7)444(0-	5 	5 	5(0-	2 	2 	2(0-:, 	 	H 	H 	H(0-7) 	 	E 	E 	E 	E 	Er   N)r   r   r    r  r  r  r  rA   r   r   r  r    sU        2 2 29 9 9  2E E E E Er   r  c                   H    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S )TestOptionalsHelpVersionActionsz!Test the help and version actionsc                    |                      t                    5 }|                    |                                           d d d            n# 1 swxY w Y   |                     |                                |j        j                   d S rO   )r   r   r;   r   r   r  r  r   )r   r2   r   r  s       r   assertPrintHelpExitz3TestOptionalsHelpVersionActions.assertPrintHelpExit  s    233 	0rhnn..///	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0++--r|/BCCCCCs   (AAAc                 H    |                      t          |j        |           d S rO   )r   r   r;   r   r2   rv   s      r   rT  z9TestOptionalsHelpVersionActions.assertArgumentParserError  s$    -v/@$GGGGGr   c                     t                      }|                    dddd           |                     |d           |                     |d           |                     t          t
          |d           d S )	Nra  rv  rw  rx  ry  r5   rR  format_versionr   r   r  r   r  r   r1   s     r   test_versionz,TestOptionalsHelpVersionActions.test_version  sw    +--D+iOOO  ...  222.'6;KLLLLLr   c                 (   t          d          }|                    dddd           |                     t                    5 }|                    dg           d d d            n# 1 swxY w Y   |                     d|j        j                   d S )	NPPPr#  ra  rv  rw  z%(prog)s 3.5ry  zPPP 3.5
r   r   r   r   r;   r   r  r   r  s      r   test_version_formatz3TestOptionalsHelpVersionActions.test_version_format   s    +777D+iXXX233 	&rtf%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&bl&9:::::s   A''A+.A+c                     t          d          }|                    dddd           |                     |d           |                     |d	           |                     t          t
          |d
           d S )NFr  ra  rv  rw  rx  ry  r5   rR  r  )r   r   rT  r   r  r   r1   s     r   test_version_no_helpz4TestOptionalsHelpVersionActions.test_version_no_help'  s|    +U;;;D+iOOO&&vt444&&vx888.'6;KLLLLLr   c                 &   t          d          }|                    ddd           |                     t                    5 }|                    dg           d d d            n# 1 swxY w Y   |                     d|j        j                   d S )Nr8  r#  rp  rw  z%(prog)s 3.7ry  zXXX 3.7
r  r  s      r   test_version_actionz3TestOptionalsHelpVersionActions.test_version_action.  s    +777DNKKK233 	&rtf%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&bl&9:::::s   A&&A*-A*c                     t          d          }|                     |d           |                     |d           |                     |d           |                     |d           d S )NFr  r5   rR  ra  rv  )r   rT  r1   s     r   test_no_helpz,TestOptionalsHelpVersionActions.test_no_help5  sp    +U;;;&&vt444&&vx888&&vt444&&v{;;;;;r   c                 F   t                      }|                    dd           |                    dd           |                     |d           |                     |d           |                     |d           |                     t
          t          |d           d S )	Nr   r]  r  r  rw  ra  rv  r  )r   r   r  rT  r   r  r   r1   s     r   test_alternate_help_versionz;TestOptionalsHelpVersionActions.test_alternate_help_version<  s    +--D000D333  ...&&vt444&&v{;;;.'6;KLLLLLr   c                    t                      }|                    ddd           |                    dd           |                    d           g d	}|d
dgz   }|D ]b}|D ]	}|d|}
|                     ||dz             |                     ||dz             |                     t          t
          |d           cd S )Nrv  rw  rx  ry  r   r  r  r^  )r   r   r(   z-x barzbaz -xz--bad-optionzfoo bar bazz %s r5   rR  r  r  )r   r2   valid_prefixesvalid_suffixesprefixsuffixr  s          r   !test_help_version_extra_argumentszATestOptionalsHelpVersionActions.test_help_version_extra_argumentsE  s   +--K	5IIID666C    ?>>'>=*II$ 	Q 	QF( 8 8(.7$$VVd];;;$$VVh->???ngv?OPPPP	Q 	Qr   N)r   r   r    r!   r  rT  r  r  r  r  r  r  r  rA   r   r   r  r    s        ++D D D
H H HM M M; ; ;M M M; ; ;< < <M M MQ Q Q Q Qr   r  c                   B    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )TestStringsz3Test str()  and repr() on Optionals and Positionalsc                 f    t           t          fD ]!}|                      ||          |           "d S rO   )r   r  r   )r   objresult_stringr6   s       r   assertStringEqualzTestStrings.assertStringEqual]  s@    $K 	7 	7DTT#YY6666	7 	7r   c                 x    t          j        g dddddg dddd	
	  	        }d}|                     ||           d S )N)r   r  r  r  r  r  r  ru  r  rz  FHELPMETAVAR	r  r*  r   rw  ro  r  r  r]  rb  zAction(option_strings=['--foo', '-a', '-b'], dest='b', nargs='+', const=None, default=42, type='int', choices=[1, 2, 3], required=False, help='HELP', metavar='METAVAR'))r+   r?  r  )r   optionr&  s      r   test_optionalzTestStrings.test_optionala  sf    000II	 	 	Q 	 	vv.....r   c                     t          j        g dt          ddg dddd	  	        }d	t          z  }|                     ||           d S )
Nr   r  ri  )rj  g      ?ri  TzH HH HzMV MV MVr  zAction(option_strings=[], dest='x', nargs='?', const=None, default=2.5, type=%r, choices=[0.5, 1.5, 2.5], required=True, help='H HH H', metavar='MV MV MV'))r+   r?  rk  r  )r   argumentr&  s      r   test_argumentzTestStrings.test_argumentr  si    ?#OO	  	  	 @BGH 	 	x00000r   c                 b    t          j        dd          }d}|                     ||           d S )Nr  r  r  zNamespace(foo=42, bar='spam')r+   r  r  r   r  r&  s      r   test_namespacezTestStrings.test_namespace  s8    BF3330r6*****r   c                 \    t          j        di ddi}d}|                     ||           d S )N"quotezNamespace(**{'"': 'quote'})rA   r  r  s      r   'test_namespace_starkwargs_notidentifierz3TestStrings.test_namespace_starkwargs_notidentifier  s=    113.112r6*****r   c                 `    t          j        dddiddi}d}|                     ||           d S )Nr   ru  r   r  z Namespace(a=1, **{'"': 'quote'})rA   r  r  s      r   2test_namespace_kwargs_and_starkwargs_notidentifierz>TestStrings.test_namespace_kwargs_and_starkwargs_notidentifier  sB    66!6W~667r6*****r   c                 \    t          j        di ddi}d}|                     ||           d S )NvalidTzNamespace(valid=True)rA   r  r  s      r   $test_namespace_starkwargs_identifierz0TestStrings.test_namespace_starkwargs_identifier  s=    227D/22(r6*****r   c                 z    t          j        d          }dt           j        z  }|                     ||           d S )NrW  r#  zvArgumentParser(prog='PROG', usage=None, description=None, formatter_class=%r, conflict_handler='error', add_help=True))r+   r,   HelpFormatterr  )r   r2   r&  s      r   test_parserzTestStrings.test_parser  sH    (f555'56 	 	vv.....r   N)r   r   r    r!   r  r  r  r  r  r  r  r
  rA   r   r   r  r  Z  s        ==7 7 7/ / /"1 1 1"+ + +
+ + +
+ + +
+ + +
/ / / / /r   r  c                        e Zd Zd Zd Zd ZdS )TestNamespacec                    t          j                    }|                     t          t          |d           t          j        dd          }|                     |j        d           |                     |j        d           d S )Nr   r  r  r  )r+   r  r   r  r   r   r   r  r  s     r   test_constructorzTestNamespace.test_constructor  su    !!.'2s;;;"///r"""v&&&&&r   c                 V   t          j        dd          }t          j        dd          }t          j        d          }t          j        d          }|                     ||           |                     ||           |                     ||           |                     ||           |                     ||           |                     ||k               |                     ||k               |                     ||k               |                     ||k               d S )Nru  r  r  )r  r   )r   r  )r+   r  r   assertNotEqual
assertTrue)r   ns1ns2ns3ns4s        r   test_equalityzTestNamespace.test_equality  s    1*** 1*** 1%%% 1%%%c"""C%%%C%%%C%%%C%%%s
###s
###s
###s
#####r   c                     t          j        dd          }|                     |                    d           t                     |                     |                    d           t                     d S )Nru  r  r  )r+   r  assertIsr   NotImplemented__ne__r  s     r   $test_equality_returns_notimplementedz2TestNamespace.test_equality_returns_notimplemented  sY    !q)))biioo~666biioo~66666r   N)r   r   r    r  r  r  rA   r   r   r  r    sA        ' ' '$ $ $ 7 7 7 7 7r   r  c                        e Zd Zd Zd Zd ZdS )TestEncodingc                     t           j                            |          \  }}|dz  }t          |dd          5 }|                                 d d d            d S # 1 swxY w Y   d S )Nz.pyr  r
   rh   )rS   r[   splitextrj   r  )r   r[   r   r  s       r   _test_module_encodingz"TestEncoding._test_module_encoding  s    '""4((a$g... 	!FFHHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AA #A c                 D    |                      t          j                   d S rO   )r   r+   __file__r   s    r   test_argparse_module_encodingz*TestEncoding.test_argparse_module_encoding  s    ""8#455555r   c                 :    |                      t                     d S rO   )r   r"  r   s    r   "test_test_argparse_module_encodingz/TestEncoding.test_test_argparse_module_encoding  s    ""8,,,,,r   N)r   r   r    r   r#  r%  rA   r   r   r  r    sA          6 6 6- - - - -r   r  c                       e Zd Zd ZdS )TestArgumentErrorc                 z    d}t          j        d |          }|                     t          |          |           d S )Nzmy error here)r+   r  r   r   )r   r   r   s      r   test_argument_errorz%TestArgumentError.test_argument_error  s;    &tS11US)))))r   N)r   r   r    r)  rA   r   r   r'  r'    s#        * * * * *r   r'  c                       e Zd Zd ZdS )TestArgumentTypeErrorc                 ,   d }t          dd          }|                    d|           |                     t                    5 }|                    dg           d d d            n# 1 swxY w Y   |                     d|j        j                   d S )	Nc                 *    t          j        d          )Nspam!)r+   ArgumentTypeErrorr%  s    r   r  z<TestArgumentTypeError.test_argument_type_error.<locals>.spam  s    ,W555r   rW  Fr  r   rh  r8  z-usage: PROG x
PROG: error: argument x: spam!
)r   r   r   r   r;   r   r  r   )r   r  r2   r  s       r   test_argument_type_errorz.TestArgumentTypeError.test_argument_type_error  s    	6 	6 	6 ,%HHHCd+++233 	'rug&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'J,	. 	. 	. 	. 	.s   A))A-0A-N)r   r   r    r0  rA   r   r   r+  r+    s#        
. 
. 
. 
. 
.r   r+  c                        e Zd Zd Zd Zd ZdS )TestMessageContentErrorc                    t          dd          }|                    dt                     |                    dt          d           |                    d	t          d
           |                     t
                    5 }|                    g            d d d            n# 1 swxY w Y   t          |j                  }|                     |d           |                     |d           |                     |d	           |                     t
                    5 }|                    dg           d d d            n# 1 swxY w Y   t          |j                  }| 	                    |d           |                     |d           |                     |d	           |                     t
                    5 }|                    ddg           d d d            n# 1 swxY w Y   t          |j                  }| 	                    |d           | 	                    |d           |                     |d	           d S )NrW  r   r<  req_posrh  -req_optTr  need_oner  )r   rw  req_optmyXargumentz
-req_opt=1)
r   r   r   r  r   r   r;   r  r>   r  r   r2   r  r   s       r   %test_missing_argument_name_in_messagez=TestMessageContentError.test_missing_argument_name_in_message  s   +rBBBIC000JS4@@@JS<<<233 	"rb!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"",i(((i(((j)))233 	/r}o...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/",i(((i(((j)))233 	=r}l;<<<	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	= 	=",i(((i(((j)))))s6   B$$B(+B(EE	E=G!!G%(G%c                 L   t          dd          }|                    dt                     |                    dt          d           |                    d	t          d
d           |                     t                    5 }|                    g            d d d            n# 1 swxY w Y   t          |j                  }| 	                    |d           | 	                    |d           | 
                    |d           |                     t                    5 }|                    dg           d d d            n# 1 swxY w Y   t          |j                  }| 	                    |d           | 
                    |d           | 
                    |d           d S )NrW  r   r<  r4  rh  z	--req_optTr  z	--opt_optr  )r   rw  ro  r7  opt_optz--req_opt=1)r   r   r   r  boolr   r   r;   r  r>   r  r9  s       r   %test_optional_optional_not_in_messagez=TestMessageContentError.test_optional_optional_not_in_message  s   +rBBBIC000KcDAAAKd#$( 	 	* 	* 	*233 	"rb!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"",i(((i(((i(((233 	/r}o...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/",i(((i(((i(((((s$   B%%B),B) EE
Ec                    t          dd          }|                    d           |                    ddd           |                     t                    5 }|                    g            d d d            n# 1 swxY w Y   t          |j                  }|                     |d           |                     |d           d S )	NrW  r   r<  r4  optional_positionalr  r  r  )	r   r   r   r   r;   r   r  r>   r  r9  s       r   'test_optional_positional_not_in_messagez?TestMessageContentError.test_optional_positional_not_in_message%  s   +rBBBI&&&1fMMM233 	"rb!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"",i(((344444s   A;;A?A?N)r   r   r    r:  r>  rA  rA   r   r   r2  r2    sA        * * *2) ) )&5 5 5 5 5r   r2  c                       e Zd Zd ZdS )TestTypeFunctionCallOnlyOncec                       fd}t          j                    }|                    d|d           |                    d                                          }                     t          d          |           d S )Nc                 4                         | d           dS )Nr.  foo_convertedr   )string_to_convertr   s    r   r  zLTestTypeFunctionCallOnlyOnce.test_type_function_call_only_once.<locals>.spam7  s    .888"?r   r   rF  r  z--foo spam!rF  r  )r+   r,   r   r;   r   r   r{   r   r  r2   rv   s   `   r   !test_type_function_call_only_oncez>TestTypeFunctionCallOnlyOnce.test_type_function_call_only_once6  s    	# 	# 	# 	# 	# (**G$>>>  !4!4!6!677000$77777r   N)r   r   r    rJ  rA   r   r   rC  rC  4  s#        8 8 8 8 8r   rC  c                   &    e Zd Zd Zd Zd Zd ZdS )TestTypeFunctionCalledOnDefaultc                       fd}t          j                    }|                    d|d           |                    g           }                     t          d          |           d S )Nc                 4                         | d           dS )Nr   rF  rG  )int_to_convertr   s    r   r  z]TestTypeFunctionCalledOnDefault.test_type_function_call_with_non_string_default.<locals>.spamG  s    ^Q///"?r   r   r   r  r  r+   r,   r   r;   r   r{   rI  s   `   r   /test_type_function_call_with_non_string_defaultzOTestTypeFunctionCalledOnDefault.test_type_function_call_with_non_string_defaultF  s~    	# 	# 	# 	# 	# (**G$:::  $$D)))))r   c                     d }t          j                    }|                    d|d           |                    g           }|                     t          d          |           d S )Nc                     dS )NrF  rA   )rO  s    r   r  zYTestTypeFunctionCalledOnDefault.test_type_function_call_with_string_default.<locals>.spamR  s    "?r   r   0r  rF  r  rP  rI  s       r   +test_type_function_call_with_string_defaultzKTestTypeFunctionCalledOnDefault.test_type_function_call_with_string_defaultQ  sv    	# 	# 	# (**G$<<<  $$000$77777r   c                     d }t          j                    }|                    d|d           |                    g           }|                     t          d          |           d S )Nc                     | dz   S )Nr  rA   )str_to_converts    r   rK  zYTestTypeFunctionCalledOnDefault.test_no_double_type_conversion_of_default.<locals>.extend\  s    !C''r   --testr  r  z**)r  rP  )r   rK  r2   rv   s       r   )test_no_double_type_conversion_of_defaultzITestTypeFunctionCalledOnDefault.test_no_double_type_conversion_of_default[  su    	( 	( 	( (**H63???  $$ 	-----r   c                     t          j                    }|                    ddt          g d           |                    g           }|                     |j        g            d S )NrY  r  r  )r*  r   ro  r  )r+   r,   r   r   r;   r   r  r  s      r   test_issue_15906z0TestTypeFunctionCalledOnDefault.test_issue_15906g  sk     (**H6$&x 	 	9 	9 	9  $$B'''''r   N)r   r   r    rQ  rU  rZ  r\  rA   r   r   rL  rL  D  sP        	* 	* 	*8 8 8
. 
. 
.( ( ( ( (r   rL  c                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )TestParseKnownArgsc                 V    t          j                    }|                    d           d S )NrA   r+   r,   r;   r1   s     r   test_arguments_tuplez'TestParseKnownArgs.test_arguments_tuplew  *    (**"r   c                 V    t          j                    }|                    g            d S rO   r`  r1   s     r   test_arguments_listz&TestParseKnownArgs.test_arguments_list{  rb  r   c                     t          j                    }|                    d           |                    d           d S )Nr   r   r+   r,   r   r;   r1   s     r   test_arguments_tuple_positionalz2TestParseKnownArgs.test_arguments_tuple_positional  s>    (**C   &!!!!!r   c                     t          j                    }|                    d           |                    dg           d S )Nr   rf  r1   s     r   test_arguments_list_positionalz1TestParseKnownArgs.test_arguments_list_positional  s@    (**C   3%     r   c                 "   t          j                    }|                    d           |                    d                                          \  }}|                     t          d          |           |                     ddg|           d S )Nr   z--foo F --bar --bazFr  r1  re  )r+   r,   r   r  r   r   r{   )r   r2   rv   extrass       r   test_optionalsz!TestParseKnownArgs.test_optionals  s    (**G$$$../D/J/J/L/LMMfd+++'7+V44444r   c                 t   t          j                    }|                    dddt                     |                    dd           |                    d           g d	}|                    |          \  }}|                     t          d
dd          |           |                     g d|           d S )Nra  r  ru  )rw  r  r   rb  r  r  r6  )rD  r   r   ra  r  rL  rz  TrD  )vr  r6  )r   r   rL  )r+   r,   r   r  r  r   r{   )r   r2   r   rv   rl  s        r   
test_mixedzTestParseKnownArgs.test_mixed  s    (**D13???H];;;H%%%222..t44fad3777>>>,,,f55555r   N)	r   r   r    ra  rd  rg  ri  rm  rp  rA   r   r   r^  r^  u  sn            " " "
! ! !
5 5 5	6 	6 	6 	6 	6r   r^  c                   &    e Zd Zd Zd Zd Zd ZdS )TestIntermixedArgsc           	         t          j        d          }|                    dd           |                    ddd	          }|                    d
           |                    ddt                     d                                }|                    |          }|                     t          dd
dg d          |           |                    |          \  }}|                     t          dd
dg           |           |                     g d|           d                                }|	                    |          \  }}|                     t          dd
ddg          |           |                     g d|           | 
                    |j                   |                     |j        d           d S )NrW  r#  r   r(   r)  r1  rF  Tr  cmdrestr  )rw  r   zcmd --foo x 1 --bar y 2 3r^  r   r  )rF  rt  r(   ru  r  r  r  z!cmd --foo x 1 --error 2 --bar y 3ru  )z--errorr  r  )r+   r,   r   r  r   parse_intermixed_argsr   r{   r  parse_known_intermixed_argsr  r  r  )r   r2   rF  r   rv   rl  s         r   
test_basiczTestIntermixedArgs.test_basic  s   (f555G%000!!'!EEE"""F#C888*0022++D11CiiiHHH$OOO..t44fCbAAA4HHH&111288::99$??fCqcBBBDIII...777 	&,'''t,,,,,r   c                    t          d          }|                    d           |                    d           |                    dd           d                                }|                     t                    5 }|                    |           d d d            n# 1 swxY w Y   |                     t          |j                  d	           d S )
NrW  r#  r  r   r^  ra  rv  rc  z\.\.\.)	r   r   r   r   r   rw  r>   r   r  )r   r2   r   r  s       r   test_remainderz!TestIntermixedArgs.test_remainder  s   +888D!!!C   Cu---!!## y)) 	/R((...	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/ 	/R\**I66666s    B""B&)B&c                    t          d          }|                    d          }|                    ddd           |                    d	d
           |                    dddd           |                    d                                          }|                     t          ddgdd           |           |                     t          |j        d                                           |                     |j	        d           d S )NrW  r#  Tr  r   r  ri  r\  rb  rj  r  r6  r  r8  rk  rl  z	1 --foo 2r  r  )r6  r(   r  r  )
r   r  r   rw  r   r   r{   r   r   r  )r   r2   r   rv   s       r   test_exclusivez!TestIntermixedArgs.test_exclusive  s   +88833T3BB7<eDDD8&111HC8LLL++K,=,=,?,?@@C:4dCCCTJJJ-v/KU[[]][[[.....r   c                 Z   t          d          }|                    d          }|                    ddd           |                    d	d
           |                    dddd           |                     t          |j        g            |                     |j        d           d S )NrW  r#  Tr  r   r  ri  r\  rb  rj  r  r6  r  r8  rk  rl  )r   r  r   r   r   rw  r   r  r'  s      r   test_exclusive_incompatiblez.TestIntermixedArgs.test_exclusive_incompatible  s    +88833T3BB7<eDDD8&11183(KKK)V%A2FFF.....r   N)r   r   r    ry  r{  r}  r  rA   r   r   rr  rr    sP        - - -67 7 7
/ 
/ 
// / / / /r   rr  c                       e Zd Zd ZdS )!TestIntermixedMessageContentErrorc                    t          dd          }|                    dt                     |                    dt          d           |                     t
                    5 }|                    g            d d d            n# 1 swxY w Y   t          |j                  }|                     |d           |                     |d	           |                     t
                    5 }|	                    g            d d d            n# 1 swxY w Y   t          |j                  }| 
                    |d           |                     |d	           d S )
NrW  r   r<  r4  rh  r5  Tr  r7  )r   r   r   r  r   r   r;   r  r>   rw  assertNotRegexr9  s       r   r:  zGTestIntermixedMessageContentError.test_missing_argument_name_in_message  s   +rBBBIC000JS4@@@233 	"rb!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"",i(((i(((233 	-r((,,,	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	-",C+++i(((((s$   %BBB,DDDN)r   r   r    r:  rA   r   r   r  r    s#        ) ) ) ) )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 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. Z0d/ Z1d0 Z2d1S )2TestAddArgumentMetavarz,length of metavar tuple does not match nargsc                 \    t          j                    }|                    d||           d S )Nr   rw  rb  )r+   r,   r   )r   rw  rb  r2   s       r   do_test_no_exceptionz+TestAddArgumentMetavar.do_test_no_exception  s1    (**G5'BBBBBr   c                    t          j                    }|                     t                    5 }|                    d||           d d d            n# 1 swxY w Y   |                     |j        j        d         | j                   d S )Nr   r  r   )	r+   r,   r   r  r   r   r  rv   EXPECTED_MESSAGE)r   rw  rb  r2   r  s        r   do_test_exceptionz(TestAddArgumentMetavar.do_test_exception  s    (**z** 	GbugFFF	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G 	G*1-t/DEEEEEs   AAAc                 4    |                      d d           d S )Nr  r  r  r   s    r   test_nargs_None_metavar_stringz5TestAddArgumentMetavar.test_nargs_None_metavar_string  s!    !!c!:::::r   c                 L    |                      d t                                 d S )Nr  r  tupler   s    r   test_nargs_None_metavar_length0z6TestAddArgumentMetavar.test_nargs_None_metavar_length0	  s%    T577;;;;;r   c                 4    |                      d d           d S )Nrq  r  r  r   s    r   test_nargs_None_metavar_length1z6TestAddArgumentMetavar.test_nargs_None_metavar_length1  s!    !!f!=====r   c                 4    |                      d d           d S )Nr  r  r  r  r   s    r   test_nargs_None_metavar_length2z6TestAddArgumentMetavar.test_nargs_None_metavar_length2  s!    T:>>>>>r   c                 4    |                      d d           d S )Nrv  r  r  r   s    r   test_nargs_None_metavar_length3z6TestAddArgumentMetavar.test_nargs_None_metavar_length3  s!    T?CCCCCr   c                 4    |                      dd           d S )Nr  r  r  r  r   s    r   "test_nargs_optional_metavar_stringz9TestAddArgumentMetavar.test_nargs_optional_metavar_string  !    !!S!99999r   c                 L    |                      dt                                 d S )Nr  r  r  r   s    r   #test_nargs_optional_metavar_length0z:TestAddArgumentMetavar.test_nargs_optional_metavar_length0  %    S%'':::::r   c                 4    |                      dd           d S )Nr  rq  r  r  r   s    r   #test_nargs_optional_metavar_length1z:TestAddArgumentMetavar.test_nargs_optional_metavar_length1  !    !!V!<<<<<r   c                 4    |                      dd           d S )Nr  r  r  r  r   s    r   #test_nargs_optional_metavar_length2z:TestAddArgumentMetavar.test_nargs_optional_metavar_length2   s!    S*=====r   c                 4    |                      dd           d S )Nr  rv  r  r  r   s    r   #test_nargs_optional_metavar_length3z:TestAddArgumentMetavar.test_nargs_optional_metavar_length3#  !    S/BBBBBr   c                 4    |                      dd           d S )Nr  r  r  r  r   s    r   $test_nargs_zeroormore_metavar_stringz;TestAddArgumentMetavar.test_nargs_zeroormore_metavar_string(  r  r   c                 L    |                      dt                                 d S )Nr  r  r  r   s    r   %test_nargs_zeroormore_metavar_length0z<TestAddArgumentMetavar.test_nargs_zeroormore_metavar_length0+  r  r   c                 4    |                      dd           d S )Nr  rq  r  r  r   s    r   %test_nargs_zeroormore_metavar_length1z<TestAddArgumentMetavar.test_nargs_zeroormore_metavar_length1.  r  r   c                 4    |                      dd           d S )Nr  r  r  r  r   s    r   %test_nargs_zeroormore_metavar_length2z<TestAddArgumentMetavar.test_nargs_zeroormore_metavar_length21  !    !!Z!@@@@@r   c                 4    |                      dd           d S )Nr  rv  r  r  r   s    r   %test_nargs_zeroormore_metavar_length3z<TestAddArgumentMetavar.test_nargs_zeroormore_metavar_length34  r  r   c                 4    |                      dd           d S )Nr  r  r  r  r   s    r   #test_nargs_oneormore_metavar_stringz:TestAddArgumentMetavar.test_nargs_oneormore_metavar_string9  r  r   c                 L    |                      dt                                 d S )Nr  r  r  r   s    r   $test_nargs_oneormore_metavar_length0z;TestAddArgumentMetavar.test_nargs_oneormore_metavar_length0<  r  r   c                 4    |                      dd           d S )Nr  rq  r  r  r   s    r   $test_nargs_oneormore_metavar_length1z;TestAddArgumentMetavar.test_nargs_oneormore_metavar_length1?  s!    S&99999r   c                 4    |                      dd           d S )Nr  r  r  r  r   s    r   $test_nargs_oneormore_metavar_length2z;TestAddArgumentMetavar.test_nargs_oneormore_metavar_length2B  r  r   c                 4    |                      dd           d S )Nr  rv  r  r  r   s    r   $test_nargs_oneormore_metavar_length3z;TestAddArgumentMetavar.test_nargs_oneormore_metavar_length3E  r  r   c                 4    |                      dd           d S )Nra  r  r  r  r   s    r   #test_nargs_remainder_metavar_stringz:TestAddArgumentMetavar.test_nargs_remainder_metavar_stringJ  s!    !!s!;;;;;r   c                 L    |                      dt                                 d S )Nra  r  )r  r  r   s    r   $test_nargs_remainder_metavar_length0z;TestAddArgumentMetavar.test_nargs_remainder_metavar_length0M  s%    !!uww!?????r   c                 4    |                      dd           d S )Nra  rq  r  r  r   s    r   $test_nargs_remainder_metavar_length1z;TestAddArgumentMetavar.test_nargs_remainder_metavar_length1P  s!    !!v!>>>>>r   c                 4    |                      dd           d S )Nra  r  r  r  r   s    r   $test_nargs_remainder_metavar_length2z;TestAddArgumentMetavar.test_nargs_remainder_metavar_length2S  s!    !!z!BBBBBr   c                 4    |                      dd           d S )Nra  rv  r  r  r   s    r   $test_nargs_remainder_metavar_length3z;TestAddArgumentMetavar.test_nargs_remainder_metavar_length3V  s!    !!!GGGGGr   c                 4    |                      dd           d S )NA...r  r  r  r   s    r    test_nargs_parser_metavar_stringz7TestAddArgumentMetavar.test_nargs_parser_metavar_string[  s!    !!!<<<<<r   c                 L    |                      dt                                 d S )Nr  r  r  r   s    r   !test_nargs_parser_metavar_length0z8TestAddArgumentMetavar.test_nargs_parser_metavar_length0^  s%    VUWW=====r   c                 4    |                      dd           d S )Nr  rq  r  r  r   s    r   !test_nargs_parser_metavar_length1z8TestAddArgumentMetavar.test_nargs_parser_metavar_length1a  s!    !!!?????r   c                 4    |                      dd           d S )Nr  r  r  r  r   s    r   !test_nargs_parser_metavar_length2z8TestAddArgumentMetavar.test_nargs_parser_metavar_length2d  s!    VZ@@@@@r   c                 4    |                      dd           d S )Nr  rv  r  r  r   s    r   !test_nargs_parser_metavar_length3z8TestAddArgumentMetavar.test_nargs_parser_metavar_length3g  s!    V_EEEEEr   c                 4    |                      dd           d S )Nru  r  r  r  r   s    r   test_nargs_1_metavar_stringz2TestAddArgumentMetavar.test_nargs_1_metavar_stringl  !    !!3!77777r   c                 L    |                      dt                                 d S )Nru  r  r  r   s    r   test_nargs_1_metavar_length0z3TestAddArgumentMetavar.test_nargs_1_metavar_length0o  %    Q88888r   c                 4    |                      dd           d S )Nru  rq  r  r  r   s    r   test_nargs_1_metavar_length1z3TestAddArgumentMetavar.test_nargs_1_metavar_length1r  s!    !!6!:::::r   c                 4    |                      dd           d S )Nru  r  r  r  r   s    r   test_nargs_1_metavar_length2z3TestAddArgumentMetavar.test_nargs_1_metavar_length2u  !    Q
;;;;;r   c                 4    |                      dd           d S )Nru  rv  r  r  r   s    r   test_nargs_1_metavar_length3z3TestAddArgumentMetavar.test_nargs_1_metavar_length3x  !    Q@@@@@r   c                 4    |                      dd           d S )Nr  r  r  r  r   s    r   test_nargs_2_metavar_stringz2TestAddArgumentMetavar.test_nargs_2_metavar_string}  r  r   c                 L    |                      dt                                 d S )Nr  r  r  r   s    r   test_nargs_2_metavar_length0z3TestAddArgumentMetavar.test_nargs_2_metavar_length0  r  r   c                 4    |                      dd           d S )Nr  rq  r  r  r   s    r   test_nargs_2_metavar_length1z3TestAddArgumentMetavar.test_nargs_2_metavar_length1  !    Q77777r   c                 4    |                      dd           d S )Nr  r  r  r  r   s    r   test_nargs_2_metavar_length2z3TestAddArgumentMetavar.test_nargs_2_metavar_length2  s!    !!:!>>>>>r   c                 4    |                      dd           d S )Nr  rv  r  r  r   s    r   test_nargs_2_metavar_length3z3TestAddArgumentMetavar.test_nargs_2_metavar_length3  r  r   c                 4    |                      dd           d S )Nrz  r  r  r  r   s    r   test_nargs_3_metavar_stringz2TestAddArgumentMetavar.test_nargs_3_metavar_string  r  r   c                 L    |                      dt                                 d S )Nrz  r  r  r   s    r   test_nargs_3_metavar_length0z3TestAddArgumentMetavar.test_nargs_3_metavar_length0  r  r   c                 4    |                      dd           d S )Nrz  rq  r  r  r   s    r   test_nargs_3_metavar_length1z3TestAddArgumentMetavar.test_nargs_3_metavar_length1  r  r   c                 4    |                      dd           d S )Nrz  r  r  r  r   s    r   test_nargs_3_metavar_length2z3TestAddArgumentMetavar.test_nargs_3_metavar_length2  r  r   c                 4    |                      dd           d S )Nrz  rv  r  r  r   s    r   test_nargs_3_metavar_length3z3TestAddArgumentMetavar.test_nargs_3_metavar_length3  s!    !!?!CCCCCr   N)3r   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  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rA   r   r   r  r    s       EC C CF F F; ; ;< < <> > >? ? ?D D D
: : :; ; ;= = => > >C C C
: : :; ; ;= = =A A AC C C
: : :; ; ;: : :A A AC C C
< < <@ @ @? ? ?C C CH H H
= = => > >@ @ @A A AF F F
8 8 89 9 9; ; ;< < <A A A
8 8 89 9 98 8 8? ? ?A A A
8 8 89 9 98 8 8< < <D D D D Dr   r  c                   .    e Zd ZdZdZd Zd Zd Zd ZdS )TestInvalidNargszinvalid nargs valueznargs for store actions must be != 0; if you have nothing to store, actions such as store true or store const may be more appropriatec                    t          j                    }|                     t                    5 }|                    d|           d d d            n# 1 swxY w Y   |                     |j        j        d         | j                   d S Nr   rv  r   )	r+   r,   r   r  r   r   r  rv   EXPECTED_RANGE_MESSAGEr   rw  r2   r  s       r   do_test_range_exceptionz(TestInvalidNargs.do_test_range_exception  s    (**z** 	6bu555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6*1-t/JKKKKK   AAAc                    t          j                    }|                     t                    5 }|                    d|           d d d            n# 1 swxY w Y   |                     |j        j        d         | j                   d S r  )	r+   r,   r   r  r   r   r  rv   EXPECTED_INVALID_MESSAGEr  s       r   do_test_invalid_exceptionz*TestInvalidNargs.do_test_invalid_exception  s    (**z** 	6bu555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6*1-t/LMMMMMr  c                 ^    |                      d           |                      d           d S )Nr   rv  abcd)r   r   s    r   test_nargs_alphabeticz&TestInvalidNargs.test_nargs_alphabetic  s6    &&S&111&&V&44444r   c                 2    |                      d           d S )Nr   rv  )r  r   s    r   test_nargs_zeroz TestInvalidNargs.test_nargs_zero  s    $$1$-----r   N)	r   r   r    r  r  r  r   r  r  rA   r   r   r  r    se        4LL L LN N N5 5 5. . . . .r   r  c                       e Zd Zd Zd ZdS )TestImportStarc                 t    t           j        D ]*}|                     t          t           |                     +d S rO   )r+   __all__r  r   r  s     r   r  zTestImportStar.test  s=    $ 	5 	5DOOGHd334444	5 	5r   c                     d t          t                                                    D             }|                     t	          |          t	          t          j                             d S )Nc                 v    g | ]6\  }}|                     d           s|dk     t          j        |          4|7S )r   ngettext)
startswithinspectismodule)r   rd   r  s      r   r   zJTestImportStar.test_all_exports_everything_but_modules.<locals>.<listcomp>  sZ     
 
 
eOOC((
 -1J,>,>#E** -? ,>,>,>r   )r   r+   r   r   r   r	  )r   r   s     r   'test_all_exports_everything_but_modulesz6TestImportStar.test_all_exports_everything_but_modules  sa    
 
#H~~3355
 
 
 	x/?(@(@AAAAAr   N)r   r   r    r  r  rA   r   r   r  r    s7        5 5 5B B B B Br   r  c                   $     e Zd Z fdZd Z xZS )TestWrappingMetavarc                     t                                                       t          d          | _        d}| j                            d|           d S )N9this_is_spammy_prog_with_a_long_name_sorry_about_the_namez<http[s]://example:1234>z--proxyr  )r   rK   r   r2   r   )r   rb  r   s     r   rK   zTestWrappingMetavar.setUp  sP    0G
 

 -  G <<<<<r   c                     | j                                         }|                     |t          j        d                     d S )Na              usage: this_is_spammy_prog_with_a_long_name_sorry_about_the_name
                   [-h] [--proxy <http[s]://example:1234>]

            options:
              -h, --help            show this help message and exit
              --proxy <http[s]://example:1234>
            )r2   r  r   r  r  )r   	help_texts     r   test_help_with_metavarz*TestWrappingMetavar.test_help_with_metavar  sL    K++--	HO 5 % % 	 	 	 	 	r   )r   r   r    rK   r  r"   r#   s   @r   r  r    sG        = = = = =	 	 	 	 	 	 	r   r  c                        e Zd Zd Zd Zd ZdS )TestExitOnErrorc                 ~    t          j        d          | _        | j                            ddt                     d S )NF)exit_on_errorz
--integersN)rb  r   )r+   r,   r2   r   r  r   s    r   rK   zTestExitOnError.setUp  s:    -EBBB  s EEEEEr   c                     | j                             d                                          }|                     |t	          j        d                     d S )Nz--integers 4r  )integers)r2   r;   r   r   r+   r  r  s     r   !test_exit_on_error_with_good_argsz1TestExitOnError.test_exit_on_error_with_good_args  sM    [##N$8$8$:$:;;X/;;;<<<<<r   c                     |                      t          j                  5  | j                            d                                           d d d            d S # 1 swxY w Y   d S )Nz--integers a)r   r+   r  r2   r;   r   r   s    r    test_exit_on_error_with_bad_argsz0TestExitOnError.test_exit_on_error_with_bad_args  s    x566 	; 	;K"">#7#7#9#9:::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;s   -AA!AN)r   r   r    rK   r  r!  rA   r   r   r  r    sD        F F F= = =; ; ; ; ;r   r  c                  N    i t           _        t                      t          _        d S rO   )r  r  rH  r  rA   r   r   tearDownModuler#    s    EJEJJJr   __main__)r-   r9   r  r   r  rS   r_   r]   r   r  rP   unittestr+   r  test.supportr   r   TextIOWrapperr   rC   r%   skip_unless_working_chmodr   rM   rt   r{   r   r   r   r,   r   r   r   r   r   r   r   r  r  r%  r'  r-  r/  r=  r@  rI  rY  r[  r`  rd  rm  rr  rt  ry  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  r  r  r  r  r  r  r  r"  r$  r&  r(  r*  r,  r.  r0  r2  r4  r7  r:  r=  r?  rA  rC  rJ  rP  rR  rU  rW  rY  r^  r`  rg  rm  rq  ru  r{  r  r  r   r   r  r  r  	eq_stderrr  r  
eq_bstderrr  r  r  r  r  skip_if_dac_overrider  r  r  r  r  r   r  r  r  r"  r+  rA  rJ  rQ  r  r  r  r*  rI  rT  r\  r`  rg  ro  rw  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-  r/  r1  r3  r5  r7  r;  r>  r@  rC  rF  rJ  rM  rO  rQ  rS  rU  r_  rh  rk  ro  rr  rt  r{  r  r  r  r  r  r  r  r  r'  r+  r2  rC  rL  r^  rr  r  r  r  r  r  r  r#  r   mainrA   r   r   <module>r-     s#            				  				   



      " " " " " "      : : : : :"" : : :$F F F F FH% F F F:    x     $D D D D D6 D D %$D.    &   ) ) ) ) ) ) ) )% % % % %) % % %#  #  # L> > > > >!8 > > >o9 o9 o9 o9 o9D o9 o9 o9b 		&&'7CC    n       n   4    .       ^        ~    
 
 
 
 
> 
 
 
    n       .   $       &    N   &       (       ,       .    ^    
 
 
 
 
 
 
 
	 	 	 	 	> 	 	 	           .       .          .    >   &    .   "    >   "
 
 
 
 
N 
 
 
    ~       N       N       >   W W W W W W W W*
 
 
 
 
 
 
 
	 	 	 	 	 	 	 		 	 	 	 	> 	 	 	       &    ^              ~          "    N   "    ~   "    n   &    N   .    ~       N       N   	 	 	 	 	^ 	 	 		 	 	 	 	N 	 	 	    N       >       .       >       >                 	 	 	 	 	 	 	 	           ~   	 	 	 	 	 	 	 	           ~       n       ^       N   	 	 	 	 	n 	 	 	    ^       N       .                     >   
 
 
 
 
^ 
 
 
	 	 	 	 	N 	 	 	    >          
 
 
 
 
. 
 
 
             ~   "    >   &    ~   &    .    
 
 
 
 
 
 
 
    ^   6    .   &       (    .   *    L.   D    \>   DK K K K Kx K K K0 fhh fhh , , , , , , , ,, W%%h''	h''	n--	//
//
/ / / / /F / / /"    L.   03 3 3 3 3< 3 3 3"    \>   .' ' ' ' 'F ' ' '"     L.    ,     L.    &     \>      
 
 
 
 
] 
 
  
3 3 3 3 38 3 3 3$
 
 
 
 
 
 
 
$    ~       .   ,    >   ,> > > > >8 > > >.> > > > >N > > >BJ J J J JX J J J$    ~   [ [ [ [ [ [ [ [B!+ !+ !+ !+ !+H !+ !+ !+Nm9 m9 m9 m9 m9 m9 m9 m9f+& +& +& +& +&x +& +& +&Z-? -? -? -? -?f -? -? -?`         '8      F( ( ( ( ( ( ( (V    7H   B! ! ! ! !'8 ! ! !H* * * * *( * * *Z' ' ' ' ''8 ' ' 'T% % % % %7H % % %P' ' ' ' ' ' ' 'R/( /( /( /( /('8 /( /( /(j    f   	 	 	 	 	-	 	 	
	 	 	 	 	(	 	 	
	 	 	 	 	&	 	 	
	 	 	 	 	1	 	 	
	 	 	 	 	0	 	 	
	 	 	 	 	7	 	 	
	 	 	 	 	0	 	 	
	 	 	 	 	>	 	 	X0 X0 X0 X0 X0h X0 X0 X0|8 8 8 8 8X 8 8 8." " " " "( " " "&Q1 Q1 Q1 Q1 Q1$ Q1 Q1 Q1f 		**>5"EE" " " " "l " " "H3B 3B 3B 3B 3B| 3B 3B 3Bl, , , , ,< , , ,^       >1 1 1 1 1< 1 1 1h% % % % % % % %P3 3 3 3 3 3 3 3l6 6 6 6 6L 6 6 6r    <   ,    \   >    L   :! ! ! ! !| ! ! !H    <   2# # # # # # # #L    <   D! ! ! ! !L ! ! !H    \   4    |   0+ + + + + + + +\    \   "
 
 
 
 
< 
 
 
    L   *    |   (    L   4       *    |   (    <   *    \   .    <   0    <   6. . . . .l . . .b- - - - -\ - - -`0 0 0 0 0| 0 0 0d    L   (    L   2       :' ' ' ' ' ' ' 'V    <   BxI xI xI xI xIh xI xI xI|- - - - -( - - -<3E 3E 3E 3E 3E8 3E 3E 3EtEQ EQ EQ EQ EQh EQ EQ EQXC/ C/ C/ C/ C/( C/ C/ C/R7 7 7 7 7H 7 7 7J- - - - -8 - - -$* * * * * * * *. . . . .H . . .$65 65 65 65 65h 65 65 65z
8 
8 
8 
8 
88 
8 
8 
8 +( +( +( +( +(h +( +( +(b$6 $6 $6 $6 $6 $6 $6 $6T=/ =/ =/ =/ =/ =/ =/ =/~) ) ) ) ) ) ) )0eD eD eD eD eDX eD eD eDP. . . . .x . . .@B B B B BX B B B     (   0; ; ; ; ;h ; ; ;   zHMOOOOO r   