
    ;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 fd	Zd Z xZS )StdIOBuffer 
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__r   r   __classcell__r   s   @r   r   r      sQ        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   r1   r5   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    r2   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    rJ   r@   r   r   rB   rB   E   s#            r   rB   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   rJ   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)rR   rU   rT   walkrQ   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)rR   rZ   r[   rQ   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 rN   )rR   rY   rn   r\   S_IREAD)r   rk   s     r   create_readonly_filez!TempDirMixin.create_readonly_filed   s*    
**844dlCCCCCr   N)r   r   r    rJ   rd   rn   rq   r@   r   r   rL   rL   O   sU             
+ + +  D D D D Dr   rL   c                       e Zd Zd ZdS )Sigc                 "    || _         || _        d S rN   )argskwargsr   ru   rv   s      r   r   zSig.__init__i   s    	r   Nr   r   r    r   r@   r   r   rs   rs   g   s#            r   rs   c                        e Zd Zd Zd Zd ZdS )NSc                 :    | j                             |           d S rN   )__dict__update)r   rv   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=%rr@   ).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 rN   )varsr   others     r   __eq__z	NS.__eq__x   s    DzzT%[[((r   N)r   r   r    r   r   r   r@   r   r   rz   rz   n   sA        % % %; ; ;
) ) ) ) )r   rz   c                       e Zd ZddZdS )ArgumentParserErrorNc                 x    t                               | |||           || _        || _        || _        || _        d S rN   )	Exceptionr   r)   stdoutstderr
error_code)r   r)   r   r   r   s        r   r   zArgumentParserError.__init__~   s<    4&&999$r   )NNNrx   r@   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:   ru   rv   
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 rN   )r   r   r:   r   )r   ru   rv   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 rN   )r   r   r/   r   )r   ru   rv   r/   r   s       r   r/   zErrorRaisingArgumentParser.exit   s4    /66;%d<T<<<V<<<r   c                 X    t          t          |           j        }t          |g|R i |S rN   )r   r   errorr   )r   ru   rv   r   r   s       r   r   z ErrorRaisingArgumentParser.error   s4    0$77=%e=d===f===r   )r   r   r    r:   r/   r   r!   r"   s   @r   r   r      so        C C C C C= = = = => > > > > > > > >r   r   c                       e Zd Z	 d ZdS )ParserTesterMetaclassc                    |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 rN   )add_argumentru   rv   )r1   argument_signaturessigs      r   	no_groupsz1ParserTesterMetaclass.__init__.<locals>.no_groups   s=    :* = =##SX<<<<<= =r   c                 j    	 |                      d          }|D ]} |j        |j        i |j         d S )Nr'   )add_argument_groupr   ru   rv   )r1   r   groupr   s       r   	one_groupz1ParserTesterMetaclass.__init__.<locals>.one_group   sP    F--e44E* < <""CH;
;;;;< <r   c                     	 t          |          D ]4\  }}|                     d|z            } |j        |j        i |j         5d S )Nzfoo:%i)	enumerater   r   ru   rv   )r1   r   ir   r   s        r   many_groupsz3ParserTesterMetaclass.__init__.<locals>.many_groups   sa    B#$788 < <311(Q,??""CH;
;;;;< <r   c                 .    	 |                      |          S rN   )r:   )r1   ru   s     r   listargsz0ParserTesterMetaclass.__init__.<locals>.listargs   s    5$$T***r   c                     	 t           j        }|d         g|z   t           _        	 |                                 |t           _        S # |t           _        w xY w)Nr   )r   argvr:   )r1   ru   old_sys_argvs      r   sysargsz/ParserTesterMetaclass.__init__.<locals>.sysargs   sO    :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 rN   r@   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 rN   )r   ru   rv   r   r   r   )r   testerru   rv   r1   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   r1   args_strru   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 rN   )r   	successesr   strr   r   assertEqual)r   r   r1   ru   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   r@   r   r   AddTestsr      sP        < < <&  0 0 0? ? ? ? ?r   r   )hasattrrs   r   r   r   object)clsrc   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   Nrx   r@   r   r   r   r      s-        _9 _9 _9 _9 _9r   r   r   c                       e 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 )TestOptionalsSingleDash-x)r   a--foo-x --fooz-x -yr   Nx-x ar   -xaz-x -1-1z-x-1r   r   r    rs   r   r   rz   r   r@   r   r   r   r   3  s        ;3t99+888H	RR$ZZZ	c	S				""t***	dIIIr   r   c                      e 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   
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   r@   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	  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 )TestOptionalsSingleDashLong-foo)r  r   r   z
-foo --fooz-foo -y-fooar   Nr'   z-foo ar   z-foo -1r   z-fo a-f ar   r@   r   r   r  r  [  s        K3v;;-GGGH	RRD\\\	22#;;;	BB4LLL!	""+++	IIIr   r  c                   .   e 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 )&TestOptionalsSingleDashSubsetAmbiguous-f-foobar-foorab)r  r  -fo-foo bz-foobz-foobaz-foorar   N)ffoobarfoorabr  r   -fa-foaoar  ooa	-foobar a	-foorab ar   r@   r   r   r  r  i  s        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	  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 ) TestOptionalsSingleDashAmbiguousr  r  )r  r  r  r  r  r  r  r   N)r  r  z-foob ar   z-foor az-fooba az-foora ar   r!  r   r@   r   r   r#  r#  y  s        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	  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 )TestOptionalsNumericr   onedest)r   r   z-1 --fooz-1 -yz-1 -1z-1 -2r   N)r&  z-1 ar   z-1az-1-2-2r   r@   r   r   r%  r%    s        23t%0001AAAH	RRD\\\		s		IIIr   r%  c                       e 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 )TestOptionalsDoubleDashr   )r   r  r  r   z--foo -xz--foo --barr   Nr  z--foo ar   z--foo=az
--foo -2.5z-2.5z
--foo=-2.5r   r@   r   r   r+  r+    s        ;3w<<.FFFH	RRD\\\	BB3KKK 	BB3KKK 	rrf~~~&	rrf~~~&IIIr   r+  c            
           e 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 )#TestOptionalsDoubleDashPartialMatch--badgerr   r   z--bat)--bar--b--ba--b=2z--ba=4	--badge 5r   FN)badgerbatz--bat XX--badT--badg--badger   r@   r   r   r-  r-    s        A 	J|,,,G HGGH	RRu$'''(	BBe---.	""Dd+++,	22Tt,,,-	BBd---.	RRt.../IIIr   r-  c                      e 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 )"TestOptionalsDoubleDashPrefixMatchr.  r   r   r1  )r/  r0  r1  r2  r3  r   FN)r4  baz--ba Xr6  z--ba=Xr7  Tr8  r9  r   r@   r   r   r;  r;    s        I 	J|,,,F >==H	RRu&&&'	22Us+++,	22Us+++,	""DT***+	22Td+++,	BBdt,,,-	RRt---.IIIr   r;  c                      e 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 )TestOptionalsSingleDoubleDashr  r   r   r/  -bazr  r  r  )r/  -fbarz-fbazz-bazf-b BBr   FNr  barbazTz--ba BrB  z
-f --bar Bz-f -bz-ba -fr   r@   r   r   r>  r>    s        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                   4   e 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 )!TestOptionalsAlternatePrefixChars+:/Fprefix_charsadd_help+fr   r   ::bar/bazr  r  r  )r/  r@  rA  rB  r  --bar Br?  r4   --helpz+hz::helpz/helpr   NrC  T::ba BrB  
+f ::bar B+f /b/ba +f	r   r   r    rs   r   r   r   rz   r   r@   r   r   rG  rG    s
       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   rG  c                   4   e 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 )*TestOptionalsAlternatePrefixCharsAddedHelprH  TrI  rL  r   r   rM  rN  r  r  r  )r/  r@  rA  rB  r  rO  r?  r   FNrC  rQ  rB  rR  rS  rT  rU  r@   r   r   rW  rW    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   rW  c            	           e 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+-FrI  r   r   r   z+yz+z)-wz-xyzz+xr  z+xyzr   r   yr  Tz+y -xz+yz -xNrU  r@   r   r   rY  rY    s        Jsu===D&&&D&&&D&&&
  H 
RR%5E***+	rrDEU+++,	""ttu---.	22---.	IIIr   rY  c                       e 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 )TestOptionalsShortLong-vz	--verbosez-nz--noisyr   r   )z--x --verbosez-Nr   z-v xr   F)verboseTNr   r@   r   r   r^  r^    s        F 	D+tY|DDD 433H	RR	rr$ 	bb&&&'	rr$ 	BBt$$$%IIIr   r^  c                       e 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	--foo-bar--bazzabbazr'  r   z--foo-bar fr  N)foo_barrd  z--baz ggz--foo-bar h --baz ihr   z--baz j --foo-bar kkjr   r@   r   r   rb  rb  -  s        43{++SSx-H-H-HIuH	3t4445	BBtC0001	3s ; ; ;<	3s ; ; ;<	IIIr   rb  c                       e 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 )TestOptionalsDefaultr   r  r  defaultr   r   Nr   r\  z-xxr   z-yyr\  r   r@   r   r   rk  rk  :  s        43t99cc$&;&;&;<uH	RR$"	SB 	TS!!!"IIIr   rk  c                   h    e Zd Z	  ed          gZddgZd ed          fd ed          fgZdS )TestOptionalsNargsDefaultr   r   r   Nr   r   r   r@   r   r   rp  rp  F  sU        A3t99+T{H	RR$ZZZ	cIIIr   rp  c                   n    e 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 )	TestOptionalsNargs1r      nargsr   r   Nr   r   r   r@   r   r   rr  rr  Q  s_        03t1---.T{H	RR$ZZZ	seIIIr   rr  c                   p    e Zd Z	  edd          gZg dZd ed          fd eg d	          fgZdS )
TestOptionalsNargs3r      rt  )r   r   r   -x a ba -xa -x br   Nr   z-x a b cr   bcr   r@   r   r   rw  rw  \  sf        13t1---.>>>H	RR$ZZZ	RR///***+IIIr   rw  c                      e 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 )TestOptionalsNargsOptionalrZ  ?rt  r   r  )ru  r  r  spamru  rm  r  4284)ru  r   r  rm  2r   NT   rf   r   r\  r  z-w 2z-x 2z-y 2z-z 2   	r   r   r    rs   intr   r   rz   r   r@   r   r   r  r  g  sp       : 	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	  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 )TestOptionalsNargsZeroOrMorer   *rt  r  r  r  r   r   Nrn  r   ry  r}  -y a-y a br   r@   r   r   r  r  ~  s        I 	DDV,,, uH	RR$&!!!"	rrB&!!!"	sev&&&'	22c
f---.	rrDB 	dse$$$%	22c
+++,IIIr   r  c            
           e 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 )TestOptionalsNargsOneOrMorer   +rt  r  r  r  )r   r   r  rz  za -y br   Nrn  r   r   ry  r}  r  r  r   r@   r   r   r  r    s        H 	DDV,,, 322H	RR$&!!!"	sev&&&'	22c
f---.	dse$$$%	22c
+++,IIIr   r  c            
          e 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 )TestOptionalsChoicesr  abcchoicesz-g   r   r  )r   z-f dz-fadz-gaz-g 6r   N)r  rf  r  r   z-f cr~  z-g 0r   z-g 03rx  z-fb -g4r}     
r   r   r    rs   r  ranger   r   rz   r   r@   r   r   r  r    s        6 	D%   DsEE!HH---/ 433H	RR$$ 	cT"""#	cT"""#	da!	""tq///"	BBNNN#IIIr   r  c                   n    e 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 )TestOptionalsRequiredr   Tr   requiredr   r   -x 1rs  r   z-x42r  Nr  r@   r   r   r  r    se        3 	DsT*** RyH	a	bIIIr   r  c                   l    e Zd Z	  edd          gZddgZd ed          fd	 ed
          fgZdS )TestOptionalsActionStorer   storer   r   rz  r   Nr   z-xfoor'   r   r@   r   r   r  r    s]        03tG4445V}H	RR$ZZZ	""u+++IIIr   r  c                   l    e Zd Z	  edde          gZdgZd ed          fd ee          fgZdS )TestOptionalsActionStoreConstr  r  r  r   r   Nr\  )	r   r   r    rs   r   r   r   rz   r   r@   r   r   r  r    s]        63tMHHHIuH	RR$ZZZ	rrF|||IIIr   r  c                   l    e Zd Z	  edd          gZg dZd ed          fd ed          fgZd	S )
TestOptionalsActionStoreFalser  store_falser   )r   r	  r
  r   T)r  FNr   r@   r   r   r  r    s_        63tM:::;###H	RR$ZZZ	rrE{{{IIIr   r  c                   l    e Zd Z	  edd          gZg dZd ed          fd ed          fgZd	S )
TestOptionalsActionStoreTruez--appler   r   )r   z	--apple=bz	--apple br   F)appleTNr   r@   r   r   r  r    s_        53y>>>?...H	RRe___	BBTNNN#IIIr   r  c                       e 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 )TestBooleanOptionalActionr   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   r1   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    rs   r*   r  r   r   rz   r   r  r@   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                   v    e 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 )	!TestBooleanOptionalActionRequiredr   T)r  r  r   r  r  FN)
r   r   r    rs   r*   r  r   r   rz   r   r@   r   r   r  r     sf        . 	Gd8+IJJJ tH	"",,,	RRE]]]#IIIr   r  c                       e 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 )TestOptionalsActionAppendrc  appendr   r   rc  a --baz	--baz a br   NrE  --baz ar   --baz a --baz br}  r   r@   r   r   r  r    sz        13wx8889555H	RRD\\\	BBC5MMM"	BBC:.../IIIr   r  c                       e 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 )$TestOptionalsActionAppendWithDefaultrc  r  r6  r  rm  r  r   r  r  r   r  )r6  r   r}  Nr   r@   r   r   r  r    s        13wx#GGGH555H	RRSE]]]	BBC:&&&'	BB???3334IIIr   r  c                   $   e 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 )!TestConstActionsMissingConstKwargr  append_constr   r   -br  r/  )z-f vr  r  r   N)r  r'   r}  rD  r   r@   r   r   r  r  $  s       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	  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 )TestOptionalsActionAppendConstr  r  r  -cr  r}  r  r(  r   r  za -cz-bxz-b xr   Nr}  -b -cx -b -cyzr   yz	r   r   r    rs   r   r   r   rz   r   r@   r   r   r  r  7  s        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	  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  r6  )r  r  rm  r  r  r}  r  r  r   r  r  r   r  Nr  r@   r   r   r  r  F  s        7 	Dy3%HHHD,,, 211H	RR3%[[[	rrS)$%%%&	22ii FGGGHIIIr   r  c                   l    e Zd Z	  edd          gZg dZd ed          fd ed          fgZdS )	TestOptionalsActionCountr   countr   )r   r   z-x bz	-x a -x br   Nr   rs  r   r@   r   r   r  r  U  s^        03tG4445111H	RR$ZZZ	rrAwwwIIIr   r  c            	           e 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 )"TestOptionalsAllowLongAbbreviationr   z--foobazz--foobler   r   z--foob 5z--foobr   NF)r'   foobazfooblez--foo 77z	--fooba ar   z--foobl --foo grf  Tr   r@   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	  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 )%TestOptionalsDisallowLongAbbreviationF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  rU  r@   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	  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 )0TestOptionalsDisallowLongAbbreviationPrefixCharsr  FrJ  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  rU  r@   r   r   r  r    s        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	  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 )/TestDisallowLongAbbreviationAllowsShortGroupingFr  z-rr  r  r   z-c -rr   Nrr~  z-rar   z-rccccz-ccr  z-cc -raz-ccrccrU  r@   r   r   r  r    s        ;s...D		D!!! gH	RR$$ 	SD!!!"	dd###$	TQ 	BBNNN#	22???#IIIr   r  c            
          e 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 )5TestDisallowLongAbbreviationAllowsShortGroupingPrefixr  Fr  z+rz+cr  r   z+c +rr   Nr  z+rar   z+rccr  z+ccr  z+cc +raz+ccrccrU  r@   r   r   r  r    s        Os%@@@D		D!!! gH	RR$$ 	SD!!!"	dd###$	TQ 	BBNNN#	22???#IIIr   r  c                   N    e Zd Z	  ed          gZg dZd ed          fgZdS )TestPositionalsNargsNoner'   r   r   a br   r  Nr   r@   r   r   r  r    sE        63u::,   H	bbSkkkIIIr   r  c                   T    e Zd Z	  edd          gZg dZd edg          fgZdS )TestPositionalsNargs1r'   rs  rt  r  r   r  Nr   r@   r   r   r  r    sO        83uA.../   H	bbcUmmmIIIr   r  c                   V    e Zd Z	  edd          gZg dZd eddg          fgZd	S )
TestPositionalsNargs2r'   r  rt  )r   r   r   a b cr  r   r}  r  Nr   r@   r   r   r  r    sT        83uA.../'''H	Sz"""#IIIr   r  c                       e 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 )TestPositionalsNargsZeroOrMorer'   r  rt  r   r   r  r   r  r}  Nr   r@   r   r   r  r    sv        :3uC0001vH	RRBZZZ	bbcUmmm	Sz"""#IIIr   r  c                       e 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 )%TestPositionalsNargsZeroOrMoreDefaultr'   r  rD  r  r   r   r  r   r  r}  Nr   r@   r   r   r  r    sx        H3uC???@vH	RRE]]]	bbcUmmm	Sz"""#IIIr   r  c                   r    e 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 )TestPositionalsNargsOneOrMorer'   r  rt  r   r   r   r  r  r}  Nr   r@   r   r   r  r    sf        <3uC0001DzH	bbcUmmm	Sz"""#IIIr   r  c                   l    e Zd Z	  edd          gZddgZd ed          fd	 ed	          fgZdS )
TestPositionalsNargsOptionalr'   r  rt  r   r  r   Nr  r   r   r@   r   r   r  r    s]        &3uC0001e}H	RRD\\\	bbSkkkIIIr   r  c                   n    e 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 )#TestPositionalsNargsOptionalDefaultr'   r  r  r  r   r  r   r  r   Nr   r@   r   r   r  r  	  s_        ;3uC<<<=e}H	RRBZZZ	bbSkkkIIIr   r  c                   p    e 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 ),TestPositionalsNargsOptionalConvertedDefaultr'   r  r  )ru  r   rm  )r   r  1 2r   r  r  1rs  Nr  r@   r   r   r  r    sk        
 	E3555 $##H	RRBZZZ	bbQiiiIIIr   r  c                   d    e Zd Z	  ed           ed          gZg dZd edd          fgZdS )	TestPositionalsNargsNoneNoner'   rD  )r   r   r   r  r  r   r}  r'   rD  Nr   r@   r   r   r  r  #  sU        73u::ss5zz2'''H	s$$$%IIIr   r  c                   j    e Zd Z	  ed           edd          gZg dZd eddg	          fgZd
S )TestPositionalsNargsNone1r'   rD  rs  rt  )r   r   r   r  r  r   r}  r  Nr   r@   r   r   r  r  -  s^        @3u::ss5':':':;***H	s&&&'IIIr   r  c                   l    e Zd Z	  edd           ed          gZg dZd eddgd	
          fgZdS )TestPositionalsNargs2Noner'   r  rt  rD  r   r   r   r  a b c dr  r   r}  r~  r  Nr   r@   r   r   r  r  7  s`        B3uA...E

;333H	""#s---.IIIr   r  c                       e 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 )"TestPositionalsNargsNoneZeroOrMorer'   rD  r  rt  r   r   r   r  r  r}  r  r~  Nr   r@   r   r   r  r  A  s        H3u::ss5'<'<'<=G}H	bbSb!!!"	s&&&'	""3*---.IIIr   r  c                       e 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 )!TestPositionalsNargsNoneOneOrMorer'   rD  r  rt  r   r   r   r  r   r}  r  r  r~  Nr   r@   r   r   r  r  M  sy        J3u::ss5'<'<'<=!!!H	s&&&'	""3*---.IIIr   r  c                       e 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 ) TestPositionalsNargsNoneOptionalr'   rD  r  rt  r   r   r  r   Nr  r  r}  r   r@   r   r   r  r  X  ss        J3u::ss5'<'<'<=%%%H	bbSd###$	s$$$%IIIr   r  c                       e 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 )"TestPositionalsNargsZeroOrMoreNoner'   r  rt  rD  r   r   r   r  r  r}  r  r~  Nr   r@   r   r   r  r  c  s        J3uC000##e**=G}H	bbRS!!!"	u#&&&'	""#s---.IIIr   r  c                       e 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 )!TestPositionalsNargsOneOrMoreNoner'   r  rt  rD  r  r  r   r}  r  r  r~  Nr   r@   r   r   r  r  o  sy        L3uC000##e**=!!!H	u#&&&'	""#s---.IIIr   r  c                       e 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 ) TestPositionalsNargsOptionalNoner'   r  r  r  rD  r  r   r  r  r}  Nr   r@   r   r   r   r   z  su        L3uC<<<cc%jjI%%%H	bbRS!!!"	s$$$%IIIr   r   c                       e 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 )TestPositionalsNargs2ZeroOrMorer'   r  rt  rD  r  r  r  r   r}  r  r  r~  Nr   r@   r   r   r"  r"    s        G3uA...E0E0E0EF!!!H	Szr***+	""#s#///0IIIr   r"  c                   r    e 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 )TestPositionalsNargs2OneOrMorer'   r  rt  rD  r  )r   r   r   r  r  r   r}  r~  r  Nr   r@   r   r   r$  r$    si        I3uA...E0E0E0EF(((H	""#s#///0IIIr   r$  c                       e 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 )TestPositionalsNargs2Optionalr'   r  rt  rD  r  )r   r   r   r  r  r   r}  Nr  r  r~  r   r@   r   r   r&  r&    s        A3uA...E0E0E0EF,,,H	Szt,,,-	""#s---.IIIr   r&  c                       e 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 )TestPositionalsNargsZeroOrMore1r'   r  rt  rD  rs  r   r   r   r  r  r}  r  r~  Nr   r@   r   r   r(  r(    s        G3uC000##e12E2E2EFGH	bbRcU###$	u3%((()	""#s#///0IIIr   r(  c                       e 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 )TestPositionalsNargsOneOrMore1r'   r  rt  rD  rs  r  r  r   r}  r  r  r~  Nr   r@   r   r   r*  r*    s        I3uC000##e12E2E2EF!!!H	u3%((()	""#s#///0IIIr   r*  c                       e 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 )TestPositionalsNargsOptional1r'   r  rt  rD  rs  r  r   Nr  r  r}  r   r@   r   r   r,  r,    s~        I3uC000##e12E2E2EF%%%H	bbTu%%%&	s&&&'IIIr   r,  c                       e 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 )#TestPositionalsNargsNoneZeroOrMore1r'   rD  r  rt  rE  rs  r  r  r   r}  r'   rD  rE  r  r~  Nr   r@   r   r   r.  r.    s        G 	E

EE
 "!!H	s.../	""3%cU3334IIIr   r.  c                       e 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 )"TestPositionalsNargsNoneOneOrMore1r'   rD  r  rt  rE  rs  )r   r   r   r}  r  r   r}  r~  r/  r  dNr   r@   r   r   r1  r1    s        I 	E

EE
 '&&H	""3%cU3334	BB3S#JSE:::;IIIr   r1  c                       e 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 )!TestPositionalsNargsNoneOptional1r'   rD  r        ?r  rE  rs  rt  r  r  r   r}  r/  r  r~  Nr   r@   r   r   r4  r4    s        E 	E

Ee,,,E
 "!!H	sC51112	""#C51112IIIr   r4  c                       e 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 )$TestPositionalsNargsOptionalOptionalr'   r  rt  rD  r  r  r   r  r   Nr  r   r  r}  r   r@   r   r   r7  r7    s        ! 	EEb))) !H	RRDb!!!"	bbSb!!!"	s$$$%IIIr   r7  c            	           e 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 )&TestPositionalsNargsOptionalZeroOrMorer'   r  rt  rD  r  r   r   Nr  r   r  r}  r  r~  r   r@   r   r   r9  r9    s        ;3uC000##e32G2G2GHyH	RRDb!!!"	bbSb!!!"	s&&&'	""3*---.	IIIr   r9  c                       e 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 )%TestPositionalsNargsOptionalOneOrMorer'   r  rt  rD  r  r   r   r   Nr  r  r}  r  r~  r   r@   r   r   r;  r;    s        =3uC000##e32G2G2GHG}H	bbTu%%%&	s&&&'	""3*---.IIIr   r;  c                   ~    e Zd Z	  ed ed                    gZg dZd ed          fd ed          fgZdS )	TestPositionalsChoicesStringr  abcdefgr  r   r   rg  r  efr   r  rf  N)	r   r   r    rs   setr   r   rz   r   r@   r   r   r=  r=    sg        03vss9~~>>>?---H	bbclll	bbclllIIIr   r=  c                       e 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 )TestPositionalsChoicesIntr     r  r?  4r  rA  15   Nr  r@   r   r   rD  rD  '  si        '3vCrCCCD---H	bbajjj	rrr{{{IIIr   rD  c                   t    e 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 )TestPositionalsActionAppendr  r  r   r  )r  ru  r  r  r   r}  r~  rA  Nr   r@   r   r   rJ  rJ  2  ss        " 	F8$$$F81--- 433H	""3c
+,,,-IIIr   rJ  c                       e 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 )"TestOptionalsNumericAndPositionalsr   r  rt  z-4r\  r   r(  r  r)  z-315r   NFrn  r   Tz-4 ar   r@   r   r   rL  rL  B  s        E 	CsDs<000 f~H	RR$%   !	bb3%   !	rrDD!!!"	cT"""#	IIIr   rL  c            	           e 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 )(TestOptionalsAlmostNumericAndPositionalsr   r  rt  z-k4r\  r   rM  z-k3r   NFrn  r)  r   Tz-k4 ar   r@   r   r   rO  rO  R  s        L 	CsEL111 wH	RR$%   !	rrDE"""#	bb3%   !	TT"""#	""sd###$IIIr   rO  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  rt  r  z--yyyr\  r'  r   Nrn  za badgerz	-a badgerz--yyy=a badgerz--yyy=-a badgerr   r@   r   r   rQ  rQ  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   rQ  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-+rJ  -r   r  r4  )r(  ru  r  r  r\  r  )r(  r   rm  z-+-r  r   rM  r  z+ -r   NFr[  z- Xr6  z+ -3Tz- ===z===)
r   r   r    rs   r   r  r   r   rz   r   r@   r   r   rS  rS  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   rS  c                      e 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  rt  r\  r   Nrn  r   r   z	-x a -- br}  rz  r{  r   r@   r   r   rX  rX    s        I3t3///S1D1D1DEH	RR$"	rrB"~~~	ser"""#	bbC5SE***+	bb4C5!!!"	bSE"""#	22#'''(IIIr   rX  c            	           e 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 )TestNargsRemainderr   r\  ...rt  r  )r   r  z-z Zr6  Nr[  z-z Z XZ
X A B -z Z)ArB  r  r\  z	X Y --fooYr   r   r@   r   r   rZ  rZ    s        <3s88SSE%:%:%:CCIIF!!!H	bb3"%%%&	22rS)))*	rrC#8#8#8DAAAB	bb33.D999:	IIIr   rZ  c                      e 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 )TestOptionLiker   r   z-3r\  )r   r(  r  r  rt  )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    rs   floatr   r   rz   r   r@   r   r   ra  ra    s       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   ra  c                   .   e 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 )TestDefaultSuppressr'   r  r  rD  r  rc  r   r  r   r   r   r  r  r}  r  Tr  r  r'   rE  r  r/  N)
r   r   r    rs   r*   SUPPRESSr   r   rz   r   r@   r   r   rg  rg    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   rg  c                   ,   e 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 )TestParserDefaultSuppressargument_defaultr'   r  rt  rD  r  rc  r   r   r   r   r   r  r  r}  r  Tr  r  rh  r  r/  N)r   r   r    rs   r*   ri  r   r   r   rz   r   r@   r   r   rk  rk    s        >sH,=>>>EEGL)))
 vH	RRTT
	bbSkkk	s&&&'	"",,,	BB3D)))*	bbSse6667IIIr   rk  c                   \   e 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 )TestParserDefault42r  rl  	--versionversion1.0r  rq  r'   r  rt  rD  r  rc  r   r   r   r   )r'   rD  rE  rq  r   r  r}  Tr  r  NrU  r@   r   r   ro  ro    s,       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   ro  c                   r    e 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 )TestArgumentsFromFilec                     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
rf   r
   rg   )r   ru  rJ   ri   rj   r   
file_textsrZ   textrm   r   s        r   rJ   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  rt  )r   r  r6  z@invalidz@missingzX YNr6  r_  )r   r   r\  z
X -a A Y Zr^  r\  @hello Xzhello world!zX @helloz-a B @recursive Y ZzX @recursive Z -a BrB  )r  r   r6  r_  r   )r   r   r    rJ   rs   r   r   r   rz   r   r!   r"   s   @r   ru  ru    sS       ,! ! ! ! ! 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   ru  c                        e 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 )TestArgumentsFromFileConverterc                     t          t          |                                            dg}|D ]D\  }}t          |dd          5 }|                    |           d d d            n# 1 swxY w Y   Ed S )Nrw  rf   r
   rg   )r   r  rJ   ri   rj   r{  s        r   rJ   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 rN   )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  r@   r   r   FromFileConverterArgumentParserr  +  s#        	 	 	 	 	r   r  r~  r  r\  r  rt  r  )rx  zworld!r6  r  )r   r   r    rJ   r   r  r   rs   r   r   r   rz   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wbrs  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_1rg   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 )Nrf   big5ignore)rh   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  rs  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  r@   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rN   )r   r   AttributeErrorr  r   s     r   r   zStdStreamComparer.__eq__l  sL    	,DLL---- 	, 	, 	,DO++++	,s     88Nr   r   r    r   r   r@   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 rN   rc   r   rc   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   rc   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   r@   r   r   r  r  {  s7        D  / / / / /r   r  c                       e 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 )TestFileTypeRc                 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  rf   r
   rg   readonly)
r   r  rJ   ri   rR   rZ   r[   rQ   rj   rq   r   	file_namerm   r   s      r   rJ   zTestFileTypeR.setUp  s    mT""((***' 	& 	&Ibgll4=)<<G- - - &04

9%%%& & & & & & & & & & & & & & & 	!!*-----   "BB	B	r   rb  r  r  )r   r   znon-existent-file.txtr'   Nr   r  
-x foo barrD  
bar -x foo-x - -r  )r   r   r    rJ   rs   r*   r  r   r   rz   r  eq_stdinr   r!   r"   s   @r   r  r    s0       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	  fdZ ed ej        d          d          gZdgZd e	 e
d          	          fgZ xZS )
TestFileTypeDefaultsc                    t          t          |                                            t          t          j                            | j        d          dd          }|                    d           |	                                 d S )Ngoodrf   r
   rg   )
r   r  rJ   ri   rR   rZ   r[   rQ   rj   r  )r   rm   r   s     r   rJ   zTestFileTypeDefaults.setUp  si    "D))//111BGLL77wOOO

6

r   r  r  zno-file.txtr   rm  r   z-c goodr  )r~  )r   r   r    rJ   rs   r*   r  r   r   rz   r  r   r!   r"   s   @r   r  r    s        F     	D(x(--}EEE tHRR%%--00012IIIIIr   r  c            	       b    e 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 )TestFileTypeRBc                 $   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  rf   r
   rg   )	r   r  rJ   ri   rR   rZ   r[   rQ   rj   r  s      r   rJ   zTestFileTypeRB.setUp  s    nd##))+++' 	& 	&Ibgll4=)<<G- - - &04

9%%%& & & & & & & & & & & & & & &	& 	&r  r   rbrb  r  r   r'   Nr  r  rD  r  r  )r   r   r    rJ   rs   r*   r  r   r   rz   r  	eq_bstdinr   r!   r"   s   @r   r  r    s       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 rN   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   rj   r  addrc   r  s      r   r   zWFile.__eq__  st    	!!1Dej  {{7++KKKKMMMIMM%   yEJ&&r   N)r   r   r    rB  r  r   r   r@   r   r   r  r    s=        355D  ' ' ' ' 'r   r  c            
           e 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 )TestFileTypeWc                     t                                                       |                     d           |                     d           d S Nr  writabler   rJ   rq   rn   r   r   s    r   rJ   zTestFileTypeW.setUp  B    !!*---!!*-----r   r   rf   rb  r  )r   r   r  r'   Nr  r  r  rD  r  r  r   r   r    rJ   rs   r*   r  r   r   rz   r  	eq_stdoutr   r!   r"   s   @r   r  r    s2       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	  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 )TestFileTypeXc                     t                                                       |                     d           |                     d           d S r  r  r  s    r   rJ   zTestFileTypeX.setUp  r  r   r   r   rb  r  )r   r   r  r  r  r'   rD  r  r  r  r"   s   @r   r  r    s        K. . . . . 	D(x(--...F**3//000 211H	rrEE%LLuuU||<<<=	22		2223IIIIIr   r  c            	       R   e 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 )TestFileTypeWBr   r  rb  r  r   r'   Nr  r  rD  r  r  )r   r   r    rs   r*   r  r   r   rz   r  
eq_bstdoutr   r@   r   r   r  r    s        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	  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 )TestFileTypeXBr   xbrb  r  r  r'   rD  r  r  N)r   r   r    rs   r*   r  r   rz   r  r  r   r@   r   r   r  r    s        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S )TestFileTypeOpenArgsc           
      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  NNrf   rs  )rf   rs  NNr  r  )rf   r  Nr  r  r  rg   )r  r  r  Nr   l1strict)rf   r   r  r  zbuiltins.openr'   )r*   r  r   r.   assert_called_with)r   FTcasesmr   ru   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@   r   r   r  r  '  s&        :3 3 3 3 3r   r  c                       e Zd Z	 d ZdS )!TestFileTypeMissingInitializationc                 <   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   rb  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@   r   r   r  r  9  s(        
	
 	
 	
 	
 	
r   r  c                       e 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--eggsrb  r  )r   42jz--eggs az	--eggs 2iz--eggs=42 42r  g      E@)eggsr  z--eggs 2j -- -1.5y               @      z1024.675Ng3333@)
r   r   r    rs   complexre  r   r   rz   r   r@   r   r   r  r  K  s        6 	H7###F 544H	$///0	bbbt4445	RRT1112IIIr   r  c                       e 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 )TestTypeUserDefinedc                       e Zd Zd Zd ZdS )TestTypeUserDefined.MyTypec                     || _         d S rN   valuer   r	  s     r   r   z#TestTypeUserDefined.MyType.__init___      DJJJr   c                 ^    t          |           | j        ft          |          |j        fk    S rN   r   r	  r   s     r   r   z!TestTypeUserDefined.MyType.__eq__b  '    JJ
+UU[/IIIr   Nr  r@   r   r   MyTyper  ]  7        	 	 		J 	J 	J 	J 	Jr   r  r   rb  r  r{  r}  r   r  -xf gr  rf  N)
r   r   r    rB   r  rs   r   r   rz   r   r@   r   r   r  r  Z  s        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	  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 )TestTypeClassicClassc                       e Zd Zd Zd ZdS )TestTypeClassicClass.Cc                     || _         d S rN   r  r
  s     r   r   zTestTypeClassicClass.C.__init__u  r  r   c                 ^    t          |           | j        ft          |          |j        fk    S rN   r  r   s     r   r   zTestTypeClassicClass.C.__eq__x  r  r   Nr  r@   r   r   Cr  s  r  r   r  r   rb  r  r{  r}  r   r  r  r  rf  N)	r   r   r    r  rs   r   r   rz   r   r@   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S )TestTypeRegistrationc                    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}r@   strings    r   get_my_typez.TestTypeRegistration.test.<locals>.get_my_type  s     6))r   r   my_typer   rb  r\  r	  z
my_type{1}rn  z-x 1 42zmy_type{42})r*   r+   registerr   r   r:   r   rz   )r   r  r1   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  r@   r   r   r  r    s&        4> > > > >r   r  c                      e 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 )TestActionUserDefinedc                       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      ?rA  )      ?r5  r  )       @r  	value: %szopt_action failed: %sr  )rz   r4  AssertionErrorr   r   r   r1   	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rN   r   r   r    r/  r@   r   r   OptionalActionr%    s(        	. 	. 	. 	. 	. 	.r   r1  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  r4  )r  r  r'  )rs  r5  )r  r(  r*  zarg_action failed: %sr4  )rz   r  r+  r   r   r,  s          r   r/  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*rN   r0  r@   r   r   PositionalActionr3    s(        	0 	0 	0 	0 	0 	0r   r6  z-sr  r'  )r(  r  r   rm  r4  r  r  )r  r   ru  rm  z-s0.125r(  )r  r4  r  r  z
-s 0.625 1r5  rs  z84 -s2r)  r  N)r   r   r    r*   Actionr1  r6  rs   re  r  r   r   rz   r   r@   r   r   r#  r#    s       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	  G d dej                  Zd ZdS )TestActionRegistrationc                       e Zd ZddZdS )TestActionRegistration.MyActionNc                 8    t          || j        d|z             d S )Nzfoo[%s])r   r(  )r   r1   r-  valuesr.  s        r   r/  z(TestActionRegistration.MyAction.__call__  s!    Ity)f*<=====r   rN   r0  r@   r   r   MyActionr;    s(        	> 	> 	> 	> 	> 	>r   r>  c                 r   t          j                    }|                    dd| j                   |                    dd           |                     |                    dg          t          d                     |                     |                    dg          t          d	                     d S )
Nr  	my_actionr4  r   r	  zfoo[1]r5  r  zfoo[42])r*   r+   r!  r>  r   r   r:   rz   r0   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*   r7  r>  r  r@   r   r   r9  r9    sW        ?> > > > >8? > > >
J J J J Jr   r9  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  ru  r   r@   z--foo f1 --foo f2 f3 f4)f1f2f3f4r  N)	r   r   r    rs   r   r   r   rz   r   r@   r   r   rB  rB    sV        GHCc::: H	"BB+C+C+C$D$D$DEIIIr   rB  c                        e 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 )TestAddSubparsersc                 2     | j         t          g|R i | d S rN   r   r   rw   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descriptionrJ  r   r  r'   r   foo helpr  helprQ  rR  r   rD  bar helpr   rU  r  FCOMMANDmetavarcommandstitlecommand helprU  z1 descriptionrR  z1 help1alias11alias2aliasesr	  rZ  zw helpr   r  x helpr  rU  z2 descriptionz2 helpr  r  123y helpr  r  zz help)r   ru  rU  z3 descriptionz3 helpr  tzt helpur[  zu helpru  rU  r@   r	  )r  )r  )	r   r   re  add_subparsersrL  dict
add_parserr  r  )r   subparser_helprJ  ra  r1   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)rm  )r   rJ   r   r1   command_help_parserr  s    r   rJ   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   rL  r1   r:   )r   r   ru   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 7Frd     r}  r'   rD  rf   r   z0.25 --foo 2 -y 2 3j -- -1jTr'  r  y              @y             )r'   rD  r\  r  z--foo 0.125 1 cr(  r~  z-1.5 3 11 -- a --foo 7 -- br     )r   r   r  --r}  )r'   rD  rf  rg  )r   r1   r:   r   rz   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{  Frd  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-Xr_  r\  )r   r1   parse_known_argsr   rz   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   rD  r'  r	  rE  Fr  r/  r  )r   r   rj  rl  r   rz   r:   r   )r   r1   ro  rq  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runr@   )r:   r   commandrL  )r   r1   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   rj  r  rl  r  r   r1   ro  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   rj  rl  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  r@   r   rj  rl  r:   assertIsNoner  r   r1   ro  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'   rD  r@   z8error: the following arguments are required: {foo,bar}
$	r   rj  rl  r   r   r:   r=   r  r   r   r1   ro  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'   rD  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  r@   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   r1   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+:-rT  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  r0   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 )	NrO  rP  rV  z--non-breakingr  uR   help message containing non-breaking spaces shall not wrap at non-breaking spacesrT  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  r0   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 )NrO  rP  rV  r'   z    rU  z            usage: PROG [-h] foo

            main description

            positional arguments:
              foo         

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

            main description

            positional arguments:
              {}          

            options:
              -h, --help  show this help message and exit
        r  r0   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 )NrH  rT  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  r0   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   rw  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 )NrO  rP  rV  r   r   rS  rT  rD  rW  r  subcommandsr]  zadditional text)r\  rR  rU  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   rj  rl  r   r  r  r  r  )r   r1   ro  rq  rs  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 rN   )r   r   r1   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ra  z0.5 1alias1 bFrd  r}  r}  z0.5 1alias2 b)r   r   r  r   rz   r0   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   rL  r:   r   r0   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)ra  rm  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  r0   s     r   test_alias_helpz!TestAddSubparsers.test_alias_help	  se    !!$t!DD++--x @ 0 0 	 	 	 	 	r   )FNF)r   r   r    rL  r   rJ   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"   s   @r   rI  rI    s       (@ @ @ >B!5 5 5 5nI I I I I
I I I
 
 
&
 
 
,; ; ;> > >/ / // / /' ' '

 

 



 

 

' ' '  "  &  $     D  $  *  <= = =
    	
 	
 	
@ @ @
      r   rI  c                   "    e Zd Z	 d Zd Zd ZdS )TestPositionalsGroupsc                 h   t                      }|                    d           |                    d          }|                    d           |                    d           t          ddd          }|                    d	                                          }|                     ||           d S )
Nr'   rf  rD  rE  r	  r  r  r/  1 2 3)r   r   r   rz   r:   r   r   r   r1   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'   rD  rE  r	  r  r  r/  r  r   r   r   rz   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'   rD  rE  r  frellr	  r  r  rF  )r'   rD  rE  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@   r   r   r  r  	  sD        J+ + ++ + +
+ 
+ 
+ 
+ 
+r   r  c                   t     e 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 )TestParentParsersc                 2     | j         t          g|R i | d S rN   rK  rw   s      r   rL  z+TestParentParsers.assertArgumentParserError	  rM  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rK  z--wr   r  r  r   r  r~  z--dr  r   r   r   )r   rJ   r   wxyz_parentr   r   abcd_parentw_parentz_parentab_mutex_parentadd_mutually_exclusive_grouprR   rZ   basenamer   r   main_program)r   x_groupc_groupr   r   s       r   rJ   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  rf   r\  r  )r   r  r   r:   r   rz   r0   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   r0   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)rK  r  r  )r  r   r  r:   r   r  r1   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   rz   rL  )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  rF  )r   r}  r2  rf   r\  r  )r  r  r   r   r:   r   rz   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}  rf   r\  r  z-a --w 2 3 -bz-a -b --w 2 3)r  r  r   r   r:   r   rz   rL  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   rz   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 )
NrD  r  r   zbar -b 1 --d 2 3 4r  r	  r  rF  )r   r}  r2  r   )	r   rj  rl  r  r   r   r:   r   rz   )r   r1   ro  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~  rD  r   zfoo -a 4TFrF  r|  zbar -b  --w 2 3 4r  r  )r   r}  rf   r\  r  r   zfoo -a -b 4zbar -b -a 4)r   rj  r  rl  r   r   r  r   r:   r   rz   rL  )r   r1   ro  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  r1   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  rf  gdr\  rR  rZ  r   r  r  r  )r  r_  r  r\  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   parentrf  r  r1   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    rL  rJ   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'   )r\  )r   r   r   r  )r   r1   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  rD  r  rt  rs  )r   r  r   r   r  r*   PARSER)r   r1   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 )NrO  rQ  r   r   r   r/  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   r1   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 )Nr4   )r*   r+   r  r   r  r:   r   r1   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   r@   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   r(  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:   r(  r   r.  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 r1  )r&  r  usage_when_requiredr   r  r  r5  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  r4  rU  r   r  r  r   r  rU  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 r1  )r&  r  r9  rU  r   r  r  r<  s      r   test_help_when_requiredzMEMixin.test_help_when_required
  sS    ooto44@'$)3(=(=>>>>>r   N)r   r   r    r)  r+  r/  r2  r7  r:  r=  r?  r@   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 )NrO  r  r  r/  rW  r  rc  r  r\  baz help)ru  r  rU  r   r  r   r   r  r1   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 Xr6  rD  rE  z--bar X --bar Zr\  --baz Yr_  rc  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
        rN   r   r   r    r&  r   rz   r   r-  r4  r9  rU  r@   r   r   rA  rA  
  s            "?3H	BB3D)))*	BB3D1112	BB4S)))*	""3'''(	I 
RRDd###$#DDDr   rA  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 )NrO  r  z--abcdez
abcde helpr  z--fghijz
fghij helpr  z--klmnoz
klmno helpz--pqrstz
pqrst helpr   r   r  rE  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 Xr6  )abcdefghijklmnopqrstz--abcde Y --klmno Xr_  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
    rN   rJ  r@   r   r   rL  rL  
  s            &&H	bbt4s$GGGH	BSCt<<<	>	bbt4t3GGGH	BTD<<<	>I 
RRd$d$???@#DDDr   rL  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 )
NrO  r  r  r   r  r  r  re  rT  r   r  r   r*   ri  rE  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 Xr6  Trn  z	-x X -x Yr_  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
        rJ  r@   r   r   rT  rT  #  s           {H	cT"""#	bb3$'''(	rrDE"""#I 
RR$$ #DDDr   rT  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 )NrO  r  r  --spamr   rT  r.  r  z	--bladderr  rV  )r   r  r1   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 --spamrZ  TN)r  r4  bladderr.  Fz--bladder BrB  z--spam --spamr   z!        usage: PROG [-h]
        P
        options:
          -h, --help  show this help message and exit
        r   r   r    r&  r   rz   r   r-  r9  r4  rU  r@   r   r   rX  rX  D  s            H 
224d;;;<	RRU5$???@	dC@@@A	""$tTBBBC	I 
RRU46667#5 1DDDr   rX  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 )NrO  r  r  r   r   FOOrT  rZ  SPAMr  r4  r  r6  BADGERru  rm  rU  rD  rE  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   TNr6  )r'   r  r4  z--spam SFSzX Y Z)r6  r_  r\  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
        rJ  r@   r   r   r_  r_  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   r_  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 )NrO  r  r   r   rb  rT  r  r  a helpr  b helpr  re  r  c helprN  rE  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
        Nr]  r@   r   r   rg  rg    sW          766H	rrDEUeu===>	rrETUeu===>	rrEUdeu===>	""tu???@	""u$???@	RR%5DDDAAABI 
RR%5EUe<<<=	rrEUetu===>	rrEUeu===>#5 1	DDDr   rg  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 )NrO  r  zTitled groupzGroup descriptionr  r  r/  rW  r  rc  rC  )r   r   r  r   )r   r  r1   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   rF  z--baz X --bar YrG  r6  rH  rI  r_  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
        rN   rJ  r@   r   r   ro  ro    s            "#45H	BB3D)))*	BB4S)))*I
 
RRDd###$#
DDDr   ro  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 )NrO  r  r   rb  r  r  r   re  rT  r  r   r  ri  rh  r  rj  r  rk  rN  rE  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 -brl  z-c X AzX Ar^  Fr6  rm  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
        r]  r@   r   r   rt  rt    s          -,,H	SEUcU;;;<	ddese<<<=	detse<<<=	22u===>	BB#>>>?I 
bb45ESE:::;	deut<<<=#
5 1DDDr   rt  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 )NrO  r  r  r  r  r  r  z-dz-er  )r   r  r   warningscatch_warningssimplefilterDeprecationWarning)r   r  r1   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&  r4  r9  rU  r)  r+  r/  r2  r@   r   r   rw  rw    sP          "
D '+#"&'+$#'   r   rw  c                         e Zd Zd fd	Z xZS )MEPBaseNc                     t          t          |                               |          }t          |j        d|g          }|S )Nr  F)rQ  rK  r  )r   r  r&  r   rQ  )r   r  r  r1   r   s       r   r&  zMEPBase.get_parserG  sJ    w%%00(0CC+uvh@ @ @r   rN   )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    r@   r   r   r  r  N          Dr   r  c                       e Zd ZdS )!TestMutuallyExclusiveSimpleParentNr  r@   r   r   r  r  S  r  r   r  c                       e Zd ZdS )TestMutuallyExclusiveLongParentNr  r@   r   r   r  r  X  r  r   r  c                       e Zd ZdS )*TestMutuallyExclusiveFirstSuppressedParentNr  r@   r   r   r  r  ]  r  r   r  c                       e Zd ZdS ))TestMutuallyExclusiveManySuppressedParentNr  r@   r   r   r  r  b  r  r   r  c                       e Zd ZdS )0TestMutuallyExclusiveOptionalAndPositionalParentNr  r@   r   r   r  r  g  r  r   r  c                       e Zd ZdS ))TestMutuallyExclusiveOptionalsMixedParentNr  r@   r   r   r  r  l  r  r   r  c                       e Zd ZdS )7TestMutuallyExclusiveOptionalsAndPositionalsMixedParentNr  r@   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   rD  rs  )r\  r  r[  rE  r  )r   r  r   set_defaultsr   rz   r:   r0   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'   rD  rn  r   xfooxrl  rE  r   r	  r  )r   r  r   r   rz   r:   r   r0   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   rD  r  rn  )r   r  rj  rl  r   rz   r:   r   )r   r1   ro  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  r1   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 )Nr6  rs  r  r  )r*   r+   rj  rl  r  r   rz   r:   )r   r1   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Wr6  r_  r\  r  rZ  r   XXrl  r\  r  rt  r  ZZr  WWYY)r   r  r   r   rz   r:   r0   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  r6  r_  r\  r  r'   rZ  r   r  rl  r\  r  rt  r  r  r  r  r  )r   r  r   r   r   rz   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  r@   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'   rD  r   r/  r  r  r4  r  )r   r  get_defaultr   r  r   r  r0   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  r@   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 )	Nrs  r  rn  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  r@   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 rN   r@   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   ru   rv   r   r   r   rj  rl  )r   r   r1   argument_sig
group_sigs	group_sigargument_sigsr   subparsers_sigsro  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 rN   )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   r1   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   r1   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   r1   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  r@   r   r   r   r    sq        A A A"  ,? ? ?- - -

0 
0 
00 0 0 0 0r   r   ))usager   )rU  r   )r   )r   rc   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   Nrx   r@   r   r   r  r    s(        O1 O1 O1 O1 O1r   r  r  c                       e 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 )TestHelpBiggerOptionalsrO  DESCRIPTIONEPILOGrQ  rR  epilogr_  rp  rq  0.1rs  r   r   X HELPrT  --yY HELPr  r'   FOO HELPrD  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    rs   r   r   r  r  rU  rq  r@   r   r   r  r  X  s        EsM"*, , , 	D+i???DH555E!!!E
###E
### !#E   D GGGr   r  c                   \    e 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 )TestShortColumnsc                 ~    |                      t          j                              }|                    dd           d S )NrE   rG  )rF   r   rG   rB  rH   s     r   rJ   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    rJ   r  r   r   r  r  rU  rq  r@   r   r   r  r  |  sa        
! ! ! #:"J"9"M"9"SE   D: #:"AGGGr   r  c                      e 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 )"TestHelpBiggerOptionalGroupsrO  r  r  r  r_  rp  rq  r  rs  r   r   r  rT  r  r  r  r'   r  rD  r  zGROUP TITLEzGROUP DESCRIPTIONr^  rE  zBAZ HELPr  r  zZ HELPrh  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  r@   r   r   r  r    s       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	  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 )TestHelpBiggerPositionalsUSAGEr  r  rR  r   r   r  rT  r  r  r  ekiekiekifekangzEKI HELPrD  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  r@   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	  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 )TestHelpReformattingrO  ze   oddly    formatted
description

that is so long that it should go onto multiple lines when wrappedrV  r   r  zoddly
    formatted -x helprZ  rU  r\  r  znormal y helpr\  z'
    oddly formatted group

descriptionr^  r  r   z` oddly 
formatted    -a  help  
    again, so long that it should be wrapped over multiple linesrT  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  r@   r   r   r  r     s        Hs)* * * 	D$ &= 	> 	> 	>C_555 
W #0 
1 
1 
1 #d<$% % % 
&		'
!E   D( GGGr   r  c                       e 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 )TestHelpWrappingShortNamesrO  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
DrV  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 HHArT  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  r@   r   r   r  r  4  s        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	  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 )TestHelpWrappingLongNamesr  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_  rp  rq  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 Vrs  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  r@   r   r   r  r  \  s        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	  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 )+TestHelpUsagerO  r  rZ  r  rf   rh  r   r  r   r   r  r}  r  )rU  ru  r~  r  r   zWhether to foo)rU  r  r/  zWhether to barT)rU  rm  r  r  z--foobarz--barfoor   z--bazzzBazz!)r  rm  rU  r   r  r\  r  rx  r  r2  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    rs   r   r*   r  ri  r   r  r  rU  rq  r@   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 )TestHelpUsageWithParenthesesrO  r  
positionalz(example) positionalrZ  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    rs   r   r   r  rU  rq  r@   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	  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 )TestHelpOnlyUserGroupsrO  FrQ  rK  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  r@   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	  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 )TestHelpUsageLongProg<PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPr  rZ  r  r  r   r6  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  r@   r   r   r  r     s        4s)))D#D#CC	 !#E  
 
D GGGr   r  c                       e 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 ) TestHelpUsageLongProgOptionsWrapr  r  rZ  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  r@   r   r   r  r    s        Ks)))D(###D(###D(###D(###CC !#E   D GGGr   r  c                       e 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 )$TestHelpUsageLongProgPositionalsWrapr  Fr  aaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccz        usage: PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP
               aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb
               ccccccccccccccccccccccccc
        
        positional arguments:
          aaaaaaaaaaaaaaaaaaaaaaaaa
          bbbbbbbbbbbbbbbbbbbbbbbbb
          ccccccccccccccccccccccccc
        r   Nr  r@   r   r   r  r  A  sv        Ms5999HHH
 !#E
   D GGGr   r  c            	           e 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 )TestHelpUsageOptionalsWraprO  r  rZ  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  r@   r   r   r"  r"  Z  s        6s'''D(###D(###D(###D(###CCC !#E   D GGGr   r"  c                       e 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 )TestHelpUsagePositionalsWraprO  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  r@   r   r   r$  r$    s        8s'''D		D		D		HHH !#E
   D GGGr   r$  c                       e 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 )%TestHelpUsageOptionalsPositionalsWraprO  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  r@   r   r   r&  r&    s        Fs'''D(###D(###D(###HHH !#E   D GGGr   r&  c                       e 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 )TestHelpUsageOptionalsOnlyWraprO  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  r@   r   r   r(  r(    s        Js'''D(###D(###D(###
 !#E
   D GGGr   r(  c                       e 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 ) TestHelpUsagePositionalsOnlyWraprO  Fr  r  r  r  z~        usage: PROG aaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbb
                    ccccccccccccccccccccccccc
        r   r   Nr  r@   r   r   r*  r*    sv        Ls777HHH
 !#E   D GGGr   r*  c            
       2   e 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 )(TestHelpVariableExpansionrO  r  r   z"x %(prog)s %(default)s %(type)s %%rX  r  r  r  XXXz y %(prog)s %(default)s %(const)s)r  rm  r  rU  r   r  z$foo %(prog)s %(default)s %(choices)src  r/  rE  rs  r  BBBz!bar %(prog)s %(default)s %(dest)s)rm  r  rZ  rU  r  zspam %(prog)s %(default)sr  r4  rd  zbadger %(prog)s %(default)s)rm  rU  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    rs   r   r  r   r  r  rU  rq  r@   r   r   r,  r,    s2       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   r,  c                   D    e Zd Z	  edd          Zg Zg ZdZedz   ZdZ	dS )&TestHelpVariableExpansionUsageSuppliedrO  z%(prog)s FOOrQ  r  z         usage: PROG FOO
        r\  r   Nr  r@   r   r   r0  r0  &  sQ        Jsn=== "E   D
 GGGr   r0  c                   >    e Zd Z	  edd          Zg Zg ZdZeZdZ	dS )$TestHelpVariableExpansionNoArgumentsrO  Fr  z        usage: PROG
        r   Nr  r@   r   r   r3  r3  7  sE        Es777 "E DGGGr   r3  c                   x    e 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 )TestHelpSuppressUsagerO  r1  r   rS  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    rs   r*   ri  r   r   r  rU  r  rq  r@   r   r   r5  r5  D  sp        =sh.?@@@G*%%%F%%% !#D EGGGr   r5  c                   ~    e 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 )TestHelpSuppressOptionalrO  Fr  r   r  r  r6  z!        usage: PROG spam
        zA
        positional arguments:
          spam  spam help
        r   Nr   r   r    rs   r   r*   ri  r   r  r  rU  rq  r@   r   r   r8  r8  Y  s|        Is777G(+,,,F%%% !#E   D
 GGGr   r8  c                       e 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 )TestHelpSuppressOptionalGrouprO  r  r   rS  r  r  r6  r   r/  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    rs   r   r   r*   ri  r  r  rU  rq  r@   r   r   r;  r;  m  s        Fs'''G*%%%F%%%
 
WG(*;<<<=>!E   D GGGr   r;  c                   |    e 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 )TestHelpSuppressPositionalrO  r  r   rS  r  r  z-        usage: PROG [-h] [--foo FOO]
        o
        options:
          -h, --help  show this help message and exit
          --foo FOO   foo help
        r   Nr9  r@   r   r   r?  r?    sz        Ks'''G*%%%F*+++ !#E   D GGGr   r?  c                   \    e Zd Z	  ed          Z eddd          gZg ZdZedz   Zd	Z	d
S )TestHelpRequiredOptionalrO  r  r   TrS  )r  rU  z+        usage: PROG [-h] --foo FOO
        r@  r   Nr  r@   r   r   rB  rB    sg        8s'''Gd444 !#E   D GGGr   rB  c                   z    e 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 )TestHelpAlternatePrefixCharsrO  z^;F)rQ  rJ  rK  z^^foor   rS  rT  z;bz;;barrW  r  z-        usage: PROG [^^foo] [;b BAR]
        zf
        options:
          ^^foo              foo help
          ;b BAR, ;;bar BAR  bar help
        r   Nr  r@   r   r   rD  rD    s        DsTEJJJGLz:::D'
+++ !#E   D GGGr   rD  c                   t    e 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 )TestHelpNoHelpOptionalrO  Fr  r   rS  r  r  r6  z-        usage: PROG [--foo FOO] spam
        zv
        positional arguments:
          spam       spam help

        options:
          --foo FOO  foo help
        r   Nr  r@   r   r   rF  rF    sy        Gs777G*%%%F%%% !#E   D GGGr   rF  c                   j    e Zd Z	  ed          Z ed           ed          gZg ZdZedz   ZdZ	dS )	TestHelpNonerO  r  r   r  r<  z
        positional arguments:
          spam

        options:
          -h, --help  show this help message and exit
          --foo FOO
        r   Nr  r@   r   r   rH  rH    si        ;s'''GF !#E   D GGGr   rH  c            	           e 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 )TestHelpTupleMetavarrO  r  rZ  rf   r  )W1W2)rU  ru  rZ  r   r   r  )X1X2r  r\  rx  )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  r@   r   r   rJ  rJ    s        ,s'''Ds#|<<<Ds#|<<<Ds!-?@@@Ds#x888	 !#E   D GGGr   rJ  c                       e 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 )TestHelpRawTextrO  7Keep the formatting
    exactly as it is written

here
rQ  formatter_classrR  r   z-    foo help should also
appear as given herer  r  r6  r\  ?    This text
  should be indented
    exactly like it is here
r^  r/  rW  >        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    rs   r*   RawTextHelpFormatterr   r   r  r  rU  rq  r@   r   r   rT  rT    s        'sX%B   	G 1 	2 	2 	2F%%% 
W #B 
C 
C 
C #gJ
'
'
'	(	*!E   D, GGGr   rT  c                       e 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 )TestHelpRawDescriptionrO  rU  rV  r   z4  foo help should not
    retain this odd formattingr  r  r6  r\  rX  r^  r/  rW  rY  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    rs   r*   RawDescriptionHelpFormatterr   r   r  r  rU  rq  r@   r   r   r\  r\  @  s        'sX%I   	G ; 	< 	< 	<F%%% 
W #B 
C 
C 
C #gJ
'
'
'	(	*!E   D* GGGr   r\  c                   ^   e 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 )%TestHelpArgumentDefaultsrO  rR  rV  r   z)foo help - oh and by the way, %(default)sr  r/  r   rW  rT  z--tazzWhether to taz itT)r  rU  rm  z--corgezWhether to corge itz--quuxzSet the quuxr  )rU  rm  r  r6  r4  r  woodenzbadger helprd  r\  r^  rc  rC  )r   rm  rU  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    rs   r*   ArgumentDefaultsHelpFormatterr   r  ri  r   r  r  r  rU  rq  r@   r   r   r_  r_  p  s@       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   r_  c                   `    e 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 )TestHelpVersionActionrO  rR  rV  -Vrp  rq  z3.6rs  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  r@   r   r   rc  rc    sg        6sMBBB3t[ERRRS "E   D GGGr   rc  c                       e 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 )TestHelpVersionActionSuppressrO  r  r_  rp  rq  rr  )r  rq  rU  r   rS  r  r  r6  r<  r=  N)r   r   r    rs   r   r*   ri  r   r  r  rU  r@   r   r   rf  rf    s        Ms'''D+i"	$ 	$ 	$G*%%%F%%%	 !#E   DDDr   rf  c                   t    e 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 )TestHelpSubparsersOrderingrO  display some subcommandsrV  r_  rp  rq  r  rs  c                 .    g | ]}t          |           S )r  rs   )r   rc   s     r   r   z%TestHelpSubparsersOrdering.<listcomp>  s6     D D D!% !d^^^ D D Dr   )r   r}  r~  r2  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    rs   r   r   r  r  rU  rq  r@   r   r   rh  rh    s        ?s'AC C C3t[ERRRSD D)BD D DE  
 
DGGGr   rh  c                   x    e 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 )"TestHelpSubparsersWithHelpOrderingrO  ri  rV  r_  rp  rq  r  rs  ))r   za subcommand help)r}  zb subcommand help)r~  zc subcommand help)r2  zd subcommand help)r   ze subcommand helpc                 6    g | ]\  }}t          ||           S ))rc   rU  rk  )r   rc   rU  s      r   r   z-TestHelpSubparsersWithHelpOrdering.<listcomp>  s?     @ @ @!+t !d666 @ @ @r   rl  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    rs   r   r   subcommand_datar  r  rU  rq  r@   r   r   rn  rn    s        ?s'AC C C3t[ERRRSO@ @/>@ @ @E   D"GGGr   rn  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 rN   r@   r  s    r   custom_typez(TestHelpMetavarTypeFormatter.custom_type  s    r   rO  rR  )rQ  rR  rW  r   rb  r  r  z
SOME FLOAT)r   rZ  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    rt  rs   r*   MetavarTypeHelpFormatterr   r  re  r   r  r  rU  rq  r@   r   r   rr  rr    s           sM+3+LN N N3s---3t+6663t%FFFH !#E   D GGGr   rr  c                   j    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S )TestInvalidArgumentConstructorsc                 d    t          j                    } | j        t          |j        g|R i | d S rN   )r*   r+   r   r   r   r   ru   rv   r1   s       r   assertTypeErrorz/TestInvalidArgumentConstructors.assertTypeError;  sR    (**)V%8 	+	+ 	+ 	+#)	+ 	+ 	+ 	+ 	+r   c                 d    t          j                    } | j        t          |j        g|R i | d S rN   )r*   r+   r   r  r   ry  s       r   assertValueErrorz0TestInvalidArgumentConstructors.assertValueError@  sR    (***f&9 	+	+ 	+ 	+#)	+ 	+ 	+ 	+ 	+r   c                     |                      dd            |                      dd           |                      dd           |                      di            d S )	Nr   )rD  r  r'   )callbackr@   )callback_args)callback_kwargsrz  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  rb  )r|  r  re  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   rE  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'  rD  rE  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  rb  r  rt  abr  r   r  )r   )rk  r  rz  )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  ru  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  )rs  r  r  r'   )r  ru  r  r  )r   r  ru  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   rO  )r  rQ  )r  r   )rz  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  r@   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  r@   )r   option_stringsr(  r  rm  r  r  s         r   r   zQTestInvalidArgumentConstructors.test_user_defined_action.<locals>.Action.__init__  sB     6>>''"g--")'))O ">''--r   c                     d S rN   r@   rw   s      r   r/  zQTestInvalidArgumentConstructors.test_user_defined_action.<locals>.Action.__call__  s    r   N)F)r   r   r    r   r/  )r  s   r   r7  r    sG         #(	, 	, 	, 	, 	, 	,    r   r7  rZ  )r  rm  r  r  )r   r   r*   r+   r   r   )r   r7  r1   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    rz  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r@   r   r   rw  rw  8  s       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   rw  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  r/  rD  r   r  r   )r*   r+   r   r   r(  r   r1   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  rs  r  ra  BARrE  )ru  r  rm  r   r  rU  rZ  r(  )r*   r+   r   r  r   ru  r  rm  r   r  rU  rZ  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  r@   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   rZ  )r*   r+   r   r   r  r0   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 )NrO  resolve)rQ  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
            rZ  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&  r1   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+   rj  rl  r   r  )r   r1   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  r@   r   r   r  r    sU        2 2 29 9 9  2E E E E Er   r  c                   F    e Zd Z	 d Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )TestOptionalsHelpVersionActionsc                    |                      t                    5 }|                    |                                           d d d            n# 1 swxY w Y   |                     |                                |j        j                   d S rN   )r   r   r:   r   r   r  r  r   )r   r1   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 rN   )r   r   r:   r   r1   ru   s      r   rL  z9TestOptionalsHelpVersionActions.assertArgumentParserError  s$    -v/@$GGGGGr   c                     t                      }|                    dddd           |                     |d           |                     |d           |                     t          t
          |d           d S )	Nr_  rp  rq  rr  rs  r4   rP  format_versionr   r   r  r   r  r   r0   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  r_  rp  rq  z%(prog)s 3.5rs  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  r_  rp  rq  rr  rs  r4   rP  r  )r   r   rL  r   r  r   r0   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 )Nr-  r  rd  rq  z%(prog)s 3.7rs  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  r4   rP  r_  rp  )r   rL  r0   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   rU  r   r  rq  r_  rp  r  )r   r   r  rL  r   r  r   r0   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 )Nrp  rq  rr  rs  r   r   r   r\  )r   r   r'   z-x barzbaz -xz--bad-optionzfoo bar bazz %s r4   rP  r  r  )r   r1   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  rL  r  r  r  r  r  r  r  r@   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                   @    e Zd Z	 d Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
TestStringsc                 f    t           t          fD ]!}|                      ||          |           "d S rN   )r   r  r   )r   objresult_stringr5   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  rs  r  rx  FHELPMETAVAR	r  r(  r   ru  rm  r  r  rU  rZ  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*   r7  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  rc  )rd  g      ?rc  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*   r7  re  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'})r@   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   rs  r  r  z Namespace(a=1, **{'"': 'quote'})r@   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)r@   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 )NrO  r  zvArgumentParser(prog='PROG', usage=None, description=None, formatter_class=%r, conflict_handler='error', add_help=True))r*   r+   HelpFormatterr  )r   r1   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@   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 )Nrs  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 )Nrs  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  r@   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
   rg   )rR   rZ   splitextri   r  )r   rZ   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 rN   )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 rN   )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  r@   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  r@   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   rO  Fr  r   rb  r-  z-usage: PROG x
PROG: error: argument x: spam!
)r   r   r   r   r:   r   r  r   )r   r  r1   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    r#  r@   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 )NrO  r   r1  req_posrb  -req_optTr  need_oner  )r   ru  req_optmyXargumentz
-req_opt=1)
r   r   r   r  r   r   r:   r  r=   r  r   r1   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 )NrO  r   r1  r'  rb  z	--req_optTr  z	--opt_optr  )r   ru  rm  r*  opt_optz--req_opt=1)r   r   r   r  boolr   r   r:   r  r=   r  r,  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 )	NrO  r   r1  r'  optional_positionalr  r   r  )	r   r   r   r   r:   r   r  r=   r  r,  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-  r1  r4  r@   r   r   r%  r%    sA        * * *2) ) )&5 5 5 5 5r   r%  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   rD  r  z--foo spam!r9  r  )r*   r+   r   r:   r   r   rz   r   r  r1   ru   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    r=  r@   r   r   r6  r6  4  s#        8 8 8 8 8r   r6  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   r9  r:  )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   rz   r<  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 )Nr9  r@   )rB  s    r   r  zYTestTypeFunctionCalledOnDefault.test_type_function_call_with_string_default.<locals>.spamR  s    "?r   r   0r  r9  r  rC  r<  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  r@   )str_to_converts    r   rC  zYTestTypeFunctionCalledOnDefault.test_no_double_type_conversion_of_default.<locals>.extend\  s    !C''r   --testr  r  z**)r  rC  )r   rC  r1   ru   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 )NrL  r  r  )r(  r   rm  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    rD  rH  rM  rO  r@   r   r   r?  r?  D  sP        	* 	* 	*8 8 8
. 
. 
.( ( ( ( (r   r?  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 )Nr@   r*   r+   r:   r0   s     r   test_arguments_tuplez'TestParseKnownArgs.test_arguments_tuplew  *    (**"r   c                 V    t          j                    }|                    g            d S rN   rS  r0   s     r   test_arguments_listz&TestParseKnownArgs.test_arguments_list{  rU  r   c                     t          j                    }|                    d           |                    d           d S )Nr   r   r*   r+   r   r:   r0   s     r   test_arguments_tuple_positionalz2TestParseKnownArgs.test_arguments_tuple_positional  s>    (**C   &!!!!!r   c                     t          j                    }|                    d           |                    dg           d S )Nr   rY  r0   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  r/  rc  )r*   r+   r   r  r   r   rz   )r   r1   ru   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 )Nr_  r  rs  )ru  r  r   rZ  r  r   r4  )rB  r  r   r_  r  rF  rx  TrB  )vr  r4  )r  r   rF  )r*   r+   r   r  r  r   rz   )r   r1   r   ru   r_  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    rT  rW  rZ  r\  r`  rc  r@   r   r   rQ  rQ  u  sn            " " "
! ! !
5 5 5	6 	6 	6 	6 	6r   rQ  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 )NrO  r  r   r'   r'  r/  rD  Tr  cmdrestr  )ru  r   zcmd --foo x 1 --bar y 2 3r\  r   r  )rD  rg  r'   rh  r	  r  r  z!cmd --foo x 1 --error 2 --bar y 3rs  )z--errorr  r  )r*   r+   r   r  r   parse_intermixed_argsr   rz   r  parse_known_intermixed_argsr  r  r  )r   r1   rD  r   ru   r_  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 )
NrO  r  r  r   r\  r[  rt  r]  z\.\.\.)	r   r   r   r   r   rj  r=   r   r  )r   r1   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 )NrO  r  Tr  r   r   ra  rT  rZ  rb  r  r4  r  r6  rc  rd  z	1 --foo 2r	  r  )r4  r'   r  r  )
r   r  r   rj  r   r   rz   r   r   r  )r   r1   r   ru   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 )NrO  r  Tr  r   r   ra  rT  rZ  rb  r  r4  r  r6  rc  rd  )r   r  r   r   r   rj  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    rl  rn  rp  rr  r@   r   r   re  re    sP        - - -67 7 7
/ 
/ 
// / / / /r   re  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 )
NrO  r   r1  r'  rb  r(  Tr  r*  )r   r   r   r  r   r   r:   r  r=   rj  assertNotRegexr,  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-  r@   r   r   rt  rt    s#        ) ) ) ) )r   rt  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   ru  rZ  )r*   r+   r   )r   ru  rZ  r1   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   rz  r   )	r*   r+   r   r  r   r   r  ru   EXPECTED_MESSAGE)r   ru  rZ  r1   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	  rz  r{  r   s    r   test_nargs_None_metavar_stringz5TestAddArgumentMetavar.test_nargs_None_metavar_string  s!    !!c!:::::r   c                 L    |                      d t                                 d S )Nrz  r~  tupler   s    r   test_nargs_None_metavar_length0z6TestAddArgumentMetavar.test_nargs_None_metavar_length0	  s%    T577;;;;;r   c                 4    |                      d d           d S )Nri  rz  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  rz  r~  r   s    r   test_nargs_None_metavar_length2z6TestAddArgumentMetavar.test_nargs_None_metavar_length2  s!    T:>>>>>r   c                 4    |                      d d           d S )Nri  rz  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	  rz  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  rz  r  r   s    r   #test_nargs_optional_metavar_length0z:TestAddArgumentMetavar.test_nargs_optional_metavar_length0  %    S%'':::::r   c                 4    |                      dd           d S )Nr  ri  rz  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  rz  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  ri  rz  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	  rz  r  r   s    r   $test_nargs_zeroormore_metavar_stringz;TestAddArgumentMetavar.test_nargs_zeroormore_metavar_string(  r  r   c                 L    |                      dt                                 d S )Nr  rz  r  r   s    r   %test_nargs_zeroormore_metavar_length0z<TestAddArgumentMetavar.test_nargs_zeroormore_metavar_length0+  r  r   c                 4    |                      dd           d S )Nr  ri  rz  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  rz  r  r   s    r   %test_nargs_zeroormore_metavar_length2z<TestAddArgumentMetavar.test_nargs_zeroormore_metavar_length21  !    !!Z!@@@@@r   c                 4    |                      dd           d S )Nr  ri  rz  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	  rz  r  r   s    r   #test_nargs_oneormore_metavar_stringz:TestAddArgumentMetavar.test_nargs_oneormore_metavar_string9  r  r   c                 L    |                      dt                                 d S )Nr  rz  r  r   s    r   $test_nargs_oneormore_metavar_length0z;TestAddArgumentMetavar.test_nargs_oneormore_metavar_length0<  r  r   c                 4    |                      dd           d S )Nr  ri  rz  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  rz  r  r   s    r   $test_nargs_oneormore_metavar_length2z;TestAddArgumentMetavar.test_nargs_oneormore_metavar_length2B  r  r   c                 4    |                      dd           d S )Nr  ri  rz  r  r   s    r   $test_nargs_oneormore_metavar_length3z;TestAddArgumentMetavar.test_nargs_oneormore_metavar_length3E  r  r   c                 4    |                      dd           d S )Nr[  r	  rz  r  r   s    r   #test_nargs_remainder_metavar_stringz:TestAddArgumentMetavar.test_nargs_remainder_metavar_stringJ  s!    !!s!;;;;;r   c                 L    |                      dt                                 d S )Nr[  rz  )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 )Nr[  ri  rz  r  r   s    r   $test_nargs_remainder_metavar_length1z;TestAddArgumentMetavar.test_nargs_remainder_metavar_length1P  s!    !!v!>>>>>r   c                 4    |                      dd           d S )Nr[  r  rz  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 )Nr[  ri  rz  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	  rz  r  r   s    r    test_nargs_parser_metavar_stringz7TestAddArgumentMetavar.test_nargs_parser_metavar_string[  s!    !!!<<<<<r   c                 L    |                      dt                                 d S )Nr  rz  r  r   s    r   !test_nargs_parser_metavar_length0z8TestAddArgumentMetavar.test_nargs_parser_metavar_length0^  s%    VUWW=====r   c                 4    |                      dd           d S )Nr  ri  rz  r  r   s    r   !test_nargs_parser_metavar_length1z8TestAddArgumentMetavar.test_nargs_parser_metavar_length1a  s!    !!!?????r   c                 4    |                      dd           d S )Nr  r  rz  r  r   s    r   !test_nargs_parser_metavar_length2z8TestAddArgumentMetavar.test_nargs_parser_metavar_length2d  s!    VZ@@@@@r   c                 4    |                      dd           d S )Nr  ri  rz  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 )Nrs  r	  rz  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 )Nrs  rz  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 )Nrs  ri  rz  r  r   s    r   test_nargs_1_metavar_length1z3TestAddArgumentMetavar.test_nargs_1_metavar_length1r  s!    !!6!:::::r   c                 4    |                      dd           d S )Nrs  r  rz  r  r   s    r   test_nargs_1_metavar_length2z3TestAddArgumentMetavar.test_nargs_1_metavar_length2u  !    Q
;;;;;r   c                 4    |                      dd           d S )Nrs  ri  rz  r  r   s    r   test_nargs_1_metavar_length3z3TestAddArgumentMetavar.test_nargs_1_metavar_length3x  !    Q@@@@@r   c                 4    |                      dd           d S )Nr  r	  rz  r  r   s    r   test_nargs_2_metavar_stringz2TestAddArgumentMetavar.test_nargs_2_metavar_string}  r  r   c                 L    |                      dt                                 d S )Nr  rz  r  r   s    r   test_nargs_2_metavar_length0z3TestAddArgumentMetavar.test_nargs_2_metavar_length0  r  r   c                 4    |                      dd           d S )Nr  ri  rz  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  rz  r  r   s    r   test_nargs_2_metavar_length2z3TestAddArgumentMetavar.test_nargs_2_metavar_length2  s!    !!:!>>>>>r   c                 4    |                      dd           d S )Nr  ri  rz  r  r   s    r   test_nargs_2_metavar_length3z3TestAddArgumentMetavar.test_nargs_2_metavar_length3  r  r   c                 4    |                      dd           d S )Nrx  r	  rz  r  r   s    r   test_nargs_3_metavar_stringz2TestAddArgumentMetavar.test_nargs_3_metavar_string  r  r   c                 L    |                      dt                                 d S )Nrx  rz  r  r   s    r   test_nargs_3_metavar_length0z3TestAddArgumentMetavar.test_nargs_3_metavar_length0  r  r   c                 4    |                      dd           d S )Nrx  ri  rz  r  r   s    r   test_nargs_3_metavar_length1z3TestAddArgumentMetavar.test_nargs_3_metavar_length1  r  r   c                 4    |                      dd           d S )Nrx  r  rz  r  r   s    r   test_nargs_3_metavar_length2z3TestAddArgumentMetavar.test_nargs_3_metavar_length2  r  r   c                 4    |                      dd           d S )Nrx  ri  rz  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  r@   r   r   rx  rx    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   rx  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   rt  r   )	r*   r+   r   r  r   r   r  ru   EXPECTED_RANGE_MESSAGEr   ru  r1   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  ru   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   rt  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   rt  )r  r   s    r   test_nargs_zeroz TestInvalidNargs.test_nargs_zero  s    $$1$-----r   N)	r   r   r    r  r  r  r  r  r  r@   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 rN   )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   rc   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  r@   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   rJ   r   r1   r   )r   rZ  r   s     r   rJ   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>
            )r1   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    rJ   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)rZ  r   )r*   r+   r1   r   r  r   s    r   rJ   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)r1   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  r1   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    rJ   r  r  r@   r   r   r  r    sD        F F F= = =; ; ; ; ;r   r  c                  N    i t           _        t                      t          _        d S rN   )r  r  rB  r  r@   r   r   tearDownModuler    s    EJEJJJr   __main__)r,   r8   r  r   r  rR   r^   r\   r   r  rO   unittestr*   ry  test.supportr   r   TextIOWrapperr   rB   r$   skip_unless_working_chmodr   rL   rs   rz   r   r   r   r+   r   r   r   r   r   r   r   r  r  r#  r%  r+  r-  r;  r>  rG  rW  rY  r^  rb  rk  rp  rr  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  r  r  r  r  r  r  r  r  r   r"  r$  r&  r(  r*  r,  r.  r1  r4  r7  r9  r;  r=  rD  rJ  rL  rO  rQ  rS  rX  rZ  ra  rg  rk  ro  ru  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#  r9  rB  rI  r  r  r  r"  rA  rL  rT  rX  r_  rg  ro  rt  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(  r*  r,  r0  r3  r5  r8  r;  r?  rB  rD  rF  rH  rJ  rT  r\  r_  rc  rf  rh  rn  rr  rw  r  r  r  r  r  r  r  r  r%  r6  r?  rQ  re  rt  rx  r  r  r  r  r  r   mainr@   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   