
    Vh[                        d 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	 G d
 dej                        Z
 G d dej
                        Z G d dej
                        Z G d dej                        Z G d dej                        Z G d dej
                        Z G d dej
                        Z G d dej
                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d  d!ej                        Z G d" d#ej                        Z G d$ d%ej                        Z G d& d'ej                        Zy())zK
Tests for L{twisted.python.usage}, a command line option parsing library.
    )usage)unittestc                   D    e Zd Zg dg dg dg dgZg dddggZd Zd	 Zy
)WellBehaved)longwdefaultzand a docstring)anothernzno docstring)longonlyNnoshort)	shortlessNexceptzthis one got docstring)aflagfzO

                 flagallicious docstringness for this here

                 floutoc                 "    d| j                   d<   y )NPONY!myflagoptsselfs    G/home/dcms/DCMS/lib/python3.12/site-packages/twisted/test/test_usage.py
opt_myflagzWellBehaved.opt_myflag!   s    %		(    c                 (    | d| j                   d<   y )Nz WITH A PONY!myparamr   r   values     r   opt_myparamzWellBehaved.opt_myparam$   s    "'6		)r   N)__name__
__module____qualname__optParametersoptFlagsr   r"    r   r   r   r      s4    3(%?	M	
 
#H&7r   r   c                   (    e Zd ZdZd Zd Zd Zd Zy)ParseCorrectnessTestszZ
    Test L{usage.Options.parseOptions} for correct values under
    good conditions.
    c                     dj                         | _        t               | _        | j                  j	                  | j                         y)zL
        Instantiate and parseOptions a well-behaved Options class.
        A--long Alpha -n Beta --shortless Gamma -f --myflag --myparam TofuN)splitniceArgVr   niceparseOptionsr   s    r   setUpzParseCorrectnessTests.setUp.   s7     V
%' 	  M			t}}-r   c                 L   | j                  | j                  j                  d   d       | j                  | j                  j                  d   d       | j                  | j                  j                  d   d       | j                  | j                  j                  d   d       y	)
z1
        Parameters have correct values.
        r   Alphar
   Betar   r   r   GammaNassertEqualr/   r   r   s    r   test_checkParametersz*ParseCorrectnessTests.test_checkParameters;   sx     	/9	2F;
3Y?4g>r   c                     | j                  | j                  j                  d   d       | j                  | j                  j                  d   d       y)z,
        Flags have correct values.
        r      r   r   Nr6   r   s    r   test_checkFlagsz%ParseCorrectnessTests.test_checkFlagsD   s>     	0!40!4r   c                     | j                  | j                  j                  d   d       | j                  | j                  j                  d   d       y)zB
        Custom flags and parameters have correct values.
        r   r   r   zTofu WITH A PONY!Nr6   r   s    r   test_checkCustomsz'ParseCorrectnessTests.test_checkCustomsK   s?     	17;	24GHr   N)r#   r$   r%   __doc__r1   r8   r;   r=   r(   r   r   r*   r*   (   s    
.?5Ir   r*   c                   J    e Zd Zddddegddddegdddd	egd
dddeggZd ZeZy)TypedOptionsfoointN  zFoo intfoofloatQ@z	Foo floateggintzEgg int without defaulteggfloatzEgg float without defaultc                     || _         y)zg
        This option has an underscore in its name to exercise the _ to -
        translation.
        N)underscoreValuer    s     r   opt_under_scorezTypedOptions.opt_under_score[   s    
  %r   )r#   r$   r%   intfloatr&   rI   opt_ur(   r   r   r@   r@   S   sO    	4i-	T4e4	48#>	T4!<eD	M% Er   r@   c                   4    e Zd ZdZd Zd Zd Zd Zd Zd Z	y)	
TypedTestszK
    Test L{usage.Options.parseOptions} for options with forced types.
    c                 "    t               | _        y N)r@   r   r   s    r   r1   zTypedTests.setUpj   s    !^
r   c                 6   g }| j                   j                  |       | j                  | j                   j                  d   d       | j	                  | j                   j                  d   t
               | j                  | j                   j                  d   d       | j	                  | j                   j                  d   t               | j                  | j                   j                  d          | j                  | j                   j                  d          y)z,
        Default values are parsed.
        rA   rB   rC   rD   rE   rF   N)r   r0   r7   r   assertIsInstancerJ   rK   assertIsNoner   argVs     r   test_defaultValueszTypedTests.test_defaultValuesm   s     

%2C8djjooh7=4d;djjooj95A$**//(34$**//*56r   c                 
   dj                         }| j                  j                  |       | j                  | j                  j                  d   d       | j                  | j                  j                  d   t               | j                  | j                  j                  d   d       | j                  | j                  j                  d   t               | j                  | j                  j                  d   d       | j                  | j                  j                  d   t               | j                  | j                  j                  d   d	       | j                  | j                  j                  d   t               y
)z2
        int and float values are parsed.
        z8--fooint 912 --foofloat -823.1 --eggint 32 --eggfloat 21rA   i  rC   g̸rE       rF   g      5@N)r-   r   r0   r7   r   rR   rJ   rK   rT   s     r   test_parsingValueszTypedTests.test_parsingValuesz   s    NTTV

%2C8djjooh7=4f=djjooj95A2B7djjooh7=4d;djjooj95Ar   c                     | j                   j                  ddg       | j                  | j                   j                  d       y)zw
        A dash in an option name is translated to an underscore before being
        dispatched to a handler.
        z--under-scorefooNr   r0   r7   rH   r   s    r   test_underscoreOptionz TypedTests.test_underscoreOption   s5    
 	

% 8933U;r   c                     | j                   j                  ddg       | j                  | j                   j                  d       y)zE
        An option name with a dash in it can have an alias.
        z-ubarNr\   r   s    r   test_underscoreOptionAliasz%TypedTests.test_underscoreOptionAlias   s4     	

u.33U;r   c                     dj                         }| j                  t        j                  | j                  j                  |       y)z7
        Passing wrong values raises an error.
        z--fooint eggN)r-   assertRaisesr   
UsageErrorr0   rT   s     r   test_invalidValueszTypedTests.test_invalidValues   s4     ##%%**DJJ,C,CTJr   N)
r#   r$   r%   r>   r1   rV   rY   r]   r`   rd   r(   r   r   rN   rN   e   s'    $7B<<Kr   rN   c                       e Zd Zg dgZy)WrongTypedOptions)barwrongNNzBar with wrong coerceheN)r#   r$   r%   r&   r(   r   r   rf   rf      s
    LMMr   rf   c                   4    e Zd Zd Zd ZddddegddddeggZy)WeirdCallableOptionsc                     t        d      )NOuch)RuntimeErrorr!   s    r   _barzWeirdCallableOptions._bar   s    6""r   c                     t        d      )NYay)
ValueErrorrn   s    r   _foozWeirdCallableOptions._foo   s    r   rg   NzBar with strange callablefoowrongzFoo with strange callable)r#   r$   r%   ro   rs   r&   r(   r   r   rj   rj      s3    #  
T4!<dC	T4!<dCMr   rj   c                   "    e Zd ZdZd Zd Zd Zy)WrongTypedTestszF
    Test L{usage.Options.parseOptions} for wrong coerce options.
    c                 z    t               }dj                         }| j                  t        |j                  |       y)z2
        Using a non-callable type fails.
        z--barwrong eggN)rf   r-   rb   	TypeErrorr0   r   usrU   s      r   test_nonCallablez WrongTypedTests.test_nonCallable   s0      %%')R__d;r   c                 >    t               }g }|j                  |       y)zP
        The coerce functions are not called if no values are provided.
        N)rj   r0   ry   s      r   test_notCalledInDefaultz'WrongTypedTests.test_notCalledInDefault   s     "#
r   c                 :   t               }dj                         }| j                  t        j                  |j
                  |      }| j                  t        |      d       t               }dj                         }| j                  t        |j
                  |       y)zI
        Errors raised by coerce functions are handled properly.
        z--foowrong blahz&Parameter type enforcement failed: Yayz--barwrong blahN)	rj   r-   rb   r   rc   r0   r7   strrm   )r   rz   rU   es       r   test_weirdCallablez"WrongTypedTests.test_weirdCallable   sy     "# &&(e..FQ!IJ!# &&(,>r   N)r#   r$   r%   r>   r{   r}   r   r(   r   r   rv   rv      s    <?r   rv   c                       e Zd Zd Zy)OutputTestsc                     t               }| j                  t        j                  |j                  dg      }| j                  t        |      d       y)zF
        Error output case adjustment does not mangle options
        z-Zzoption -Z not recognizedN)r   rb   r   rc   r0   r7   r   )r   optr   s      r   test_uppercasingzOutputTests.test_uppercasing   sB     me..0@0@4&IQ!;<r   N)r#   r$   r%   r   r(   r   r   r   r      s    =r   r   c                       e Zd ZdgZdgZy)InquisitionOptions)expectr   )torture-devicetcomfy-chairzset preferred torture deviceN)r#   r$   r%   r'   r&   r(   r   r   r   r      s    H 	OMr   r   c                       e Zd ZddgZy)HolyQuestOptions)	horsebackhzuse a horse)	for-grailgN)r#   r$   r%   r'   r(   r   r   r   r      s    )Hr   r   c                   *    e Zd ZdgZddedfddedfgZy)	SubCommandOptions)europian-swallowNz$set default swallow type to EuropianinquisitioninquestzPerform an inquisition	holyquestquestzEmbark upon a holy questN)r#   r$   r%   r'   r   r   subCommandsr(   r   r   r   r      s1    JH 
	#57OP	g/1KLKr   r   c                   @    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)SubCommandTestszJ
    Test L{usage.Options.parseOptions} for options with subcommands.
    c                 X   t               }|j                  ddg       | j                  |d          | j                  |j                  d       | j                  |j                  t               | j                  |j                  d          | j                  |j                  d   d       y)z-
        A subcommand is recognized.
        --europian-swallowr   r   r   r   r   N)	r   r0   
assertTruer7   
subCommandrR   
subOptionsr   assertFalser   r   s     r   test_simpleSubcommandz%SubCommandTests.test_simpleSubcommand   s     	,m<=,-.}5all,>?h/0&67Gr   c                 X   t               }|j                  g d       | j                  |d          | j                  |j                  d       | j                  |j                  t               | j                  |j                  d          | j                  |j                  d   d       y)zA
        Flags and options of a subcommand are assigned.
        )r   --expect--torture-device=featherr   r   r   r   featherN	r   r0   r   r7   r   rR   r   r   r   r   s     r   "test_subcommandWithFlagsAndOptionsz2SubCommandTests.test_subcommandWithFlagsAndOptions  s     	NO-./}5all,>?X./&67Cr   c                 X   t               }|j                  g d       | j                  |d          | j                  |j                  d       | j                  |j                  t               | j                  |j                  d          | j                  |j                  d   d       y)zG
        Flags and options of a subcommand alias are assigned.
        )r   r   r   r   r   r   r   r   Nr   r   s     r   'test_subcommandAliasWithFlagsAndOptionsz7SubCommandTests.test_subcommandAliasWithFlagsAndOptions  s     	JK-./}5all,>?X./&67Cr   c                 V   t               }|j                  ddg       | j                  |d          | j                  |j                  d       | j                  |j                  t               | j                  |j                  d          | j                  |j                  d          y)zG
        Flags and options of another subcommand are assigned.
        r   z--for-grailr   r   r   N)	r   r0   r   r7   r   rR   r   r   r   r   s     r   )test_anotherSubcommandWithFlagsAndOptionsz9SubCommandTests.test_anotherSubcommandWithFlagsAndOptions#  s     	]34-./{3all,<=k23[12r   c                     t               }|j                  dg       | j                  |d          | j                  |j                         | j                  t        |d             y)z
        If no subcommand is specified and no default subcommand is assigned,
        a subcommand will not be implied.
        r   r   r   N)r   r0   r   rS   r   r   hasattrr   s     r   test_noSubcommandz!SubCommandTests.test_noSubcommand/  sU    
 	,-.,-.!,,'L12r   c                 d   t               }d|_        |j                  dg       | j                  |d          | j	                  |j
                  d       | j                  |j                  t               | j                  |j                  d          | j	                  |j                  d   d       y)	zK
        Flags and options in the default subcommand are assigned.
        r   r   r   r   r   r   r   N)
r   defaultSubCommandr0   r   r7   r   rR   r   r   r   r   s     r   test_defaultSubcommandz&SubCommandTests.test_defaultSubcommand:  s     '	,-.,-.}5all,>?h/0&67Gr   c                 6    G d dt         j                         G fddt         j                        } |       }|j                  dg       | j                  t	        |j
                  d             | j                  |j
                  j                  |       y)zw
        The parseOptions method from the Options object specified for the
        given subcommand is called.
        c                       e Zd Zd Zy)DSubCommandTests.test_subCommandParseOptionsHasParent.<locals>.SubOptc                 l    | j                   | _        t        j                  j                  | g|i | y rP   )parent	sawParentr   Optionsr0   )r   akws      r   r0   zQSubCommandTests.test_subCommandParseOptionsHasParent.<locals>.SubOpt.parseOptionsN  s)    !%**4:!:r:r   N)r#   r$   r%   r0   r(   r   r   SubOptr   M  s    ;r   r   c                       e Zd ZddW  dfgZy)ASubCommandTests.test_subCommandParseOptionsHasParent.<locals>.Optr[   r   r_   Nr#   r$   r%   r   r   s   r   Optr   R  s    VU+Kr   r   r[   r   N)r   r   r0   r   r   r   r7   r   )r   r   r   r   s      @r   $test_subCommandParseOptionsHasParentz4SubCommandTests.test_subCommandParseOptionsHasParentG  sk    	;U]] 	;
	%-- 	
 E	wk:;//3r   c                 4    G d dt         j                         G fddt         j                        } G fddt         j                        } |       }|j                  dg        |       }|j                  dg       | j                  t	        |j
                  d	             | j                  t	        |j
                  d	             | j                  |j
                  j                  |       | j                  |j
                  j                  |       y
)zh
        The .parent pointer is correct even when the same Options class is
        used twice.
        c                       e Zd Zy):SubCommandTests.test_subCommandInTwoPlaces.<locals>.SubOptN)r#   r$   r%   r(   r   r   r   r   b  s    r   r   c                       e Zd ZddW  dfgZy):SubCommandTests.test_subCommandInTwoPlaces.<locals>.OptFoor[   r   quuxNr   r   s   r   OptFoor   e      VV,Kr   r   c                       e Zd ZddW  dfgZy):SubCommandTests.test_subCommandInTwoPlaces.<locals>.OptBarr_   br   Nr   r   s   r   OptBarr   j  r   r   r   r[   r_   r   N)r   r   r0   r   r   r   failUnlessIdenticalr   )r   r   r   oFoooBarr   s        @r   test_subCommandInTwoPlacesz*SubCommandTests.test_subCommandInTwoPlaces\  s    	U]] 		U]] 	
	U]] 	
 x5'"x5'":;:;  !7!7>  !7!7>r   N)r#   r$   r%   r>   r   r   r   r   r   r   r   r   r(   r   r   r   r      s3    
H
D
D
3	3H4*?r   r   c                   "    e Zd ZdZd Zd Zd Zy)HelpStringTestsz&
    Test generated help strings.
    c                 L    dj                         | _        t               | _        y)z;
        Instantiate a well-behaved Options class.
        r,   N)r-   r.   r   r/   r   s    r   r1   zHelpStringTests.setUp~  s!     V
%' 	  M	r   c                     	 | j                   j                          y# t        $ r}| j                  |       Y d}~yd}~ww xY w)z,
        __str__ shouldn't go boom.
        N)r/   __str__	Exceptionfail)r   r   s     r   test_noGoBoomzHelpStringTests.test_noGoBoom  s4    	II 	IIaLL	s    	A<Ac                    t        | j                        j                         D cg c]  }|j                  d      dk\  s| }}| j	                  t        |      dkD         | j	                  |d   j                  d      dk\         yc c}w )zK
        Extra whitespace in flag and parameters docs is stripped.
        r   r   flagalliciousN)r   r/   
splitlinesfindr   len)r   sliness      r   &test_whitespaceStripFlagsAndParametersz6HelpStringTests.test_whitespaceStripFlagsAndParameters  so      		N557Pq166'?a;OPPE
Q'ao6!;< Qs   B
 B
N)r#   r$   r%   r>   r1   r   r   r(   r   r   r   r   y  s    	"=r   r   c                       e Zd ZdZd Zd Zy)PortCoerceTestsz3
    Test the behavior of L{usage.portCoerce}.
    c                     | j                  dt        j                  d             | j                  dt        j                  d             | j                  dt        j                  d             y)z4
        Test the answers with valid input.
        r   0i  3210i  65535N)r7   r   
portCoercer   s    r   test_validCoercez PortCoerceTests.test_validCoerce  sU     	E,,S12u//78 0 0 9:r   c                 ,   | j                  t        t        j                  d       | j                  t        t        j                  d       | j                  t        t        j                  d       | j                  t        t        j                  d       y)z"
        Test error path.
         z-21212189r[   N)rb   rr   r   r   r   s    r   test_errorCoercez PortCoerceTests.test_errorCoerce  sd     	*e&6&6;*e&6&6>*e&6&6A*e&6&6>r   N)r#   r$   r%   r>   r   r   r(   r   r   r   r     s    ;?r   r   c                   L    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zy)ZshCompleterTestsz
    Test the behavior of the various L{twisted.usage.Completer} classes
    for producing output usable by zsh tab-completion system.
    c                 "   t        j                         }|j                  dt         j                        }| j	                  |d       t        j                  dd      }|j                  dt         j                        }| j	                  |d       y)zX
        Completer produces zsh shell-code that produces no completion matches.
        some-optionz:some-option:some actionTdescrrepeat*:some action:N)r   	Completer
_shellCode_ZSHr7   r   cgots      r   test_completerz ZshCompleterTests.test_completer  si     OOll=%**5o.OO-=ll=%**5./r   c                    t        j                         }|j                  dt         j                        }| j	                  |d       t        j                  d      }|j                  dt         j                        }| j	                  |d       t        j                  ddd      }|j                  dt         j                        }| j	                  |d       y	)
zn
        CompleteFiles produces zsh shell-code that completes file names
        according to a glob.
        r   z:some-option (*):_files -g "*"z*.pyz$:some-option (*.py):_files -g "*.py"r   Tr   z%*:some action (*.py):_files -g "*.py"N)r   CompleteFilesr   r   r7   r   s      r   
test_fileszZshCompleterTests.test_files  s    
 !ll=%**5>?'ll=%**5DEmDIll=%**5EFr   c                 "   t        j                         }|j                  dt         j                        }| j	                  |d       t        j                  dd      }|j                  dt         j                        }| j	                  |d       y)zV
        CompleteDirs produces zsh shell-code that completes directory names.
        r   z:some-option:_directoriesr   Tr   z*:some action:_directoriesN)r   CompleteDirsr   r   r7   r   s      r   	test_dirszZshCompleterTests.test_dirs  sn      ll=%**59:]4@ll=%**5:;r   c                    t        j                  d      }|j                  dt         j                        }| j	                  |d       t        j                  g d      }|j                  dt         j                        }| j	                  |d       t        j                  g ddd      }|j                  dt         j                        }| j	                  |d	       y
)zw
        CompleteList produces zsh shell-code that completes words from a fixed
        list of possibilities.
        ABCr   z:some-option:(A B C)123z:some-option:(1 2 3)r   Tr   z*:some action:(1 2 3)N)r   CompleteListr   r   r7   r   s      r   	test_listzZshCompleterTests.test_list  s    
 u%ll=%**545/ll=%**545mDQll=%**556r   c                    t        j                  d      }|j                  dt         j                        }| j	                  |d       t        j                  g d      }|j                  dt         j                        }| j	                  |d       t        j                  g ddd      }|j                  dt         j                        }d	}| j	                  ||       y
)z
        CompleteMultiList produces zsh shell-code that completes multiple
        comma-separated words from a fixed list of possibilities.
        r  r   z-:some-option:_values -s , 'some-option' A B Cr	  z-:some-option:_values -s , 'some-option' 1 2 3r   Tr   z.*:some action:_values -s , 'some action' 1 2 3N)r   CompleteMultiListr   r   r7   )r   r   r   expecteds       r   test_multiListz ZshCompleterTests.test_multiList  s    
 ##E*ll=%**5MN##O4ll=%**5MN##O=QUVll=%**5Ch'r   c                 "   t        j                         }|j                  dt         j                        }| j	                  |d       t        j                  dd      }|j                  dt         j                        }| j	                  |d       y)zd
        CompleteUsernames produces zsh shell-code that completes system
        usernames.
        r   z:some-option:_usersr   Tr   z*:some action:_usersN)r   CompleteUsernamesr   r   r7   r   r   outs      r   test_usernamesz ZshCompleterTests.test_usernames  sn    
 ##%ll=%**534##-Ell=%**545r   c                 "   t        j                         }|j                  dt         j                        }| j	                  |d       t        j                  dd      }|j                  dt         j                        }| j	                  |d       y)zc
        CompleteGroups produces zsh shell-code that completes system group
        names.
        r   z:group:_groupsr   Tr   z*:some action:_groupsN)r   CompleteGroupsr   r   r7   r  s      r   test_groupszZshCompleterTests.test_groups  sn    
   "ll=%**5./  }TBll=%**556r   c                 "   t        j                         }|j                  dt         j                        }| j	                  |d       t        j                  dd      }|j                  dt         j                        }| j	                  |d       y)zU
        CompleteHostnames produces zsh shell-code that completes hostnames.
        r   z:some-option:_hostsr   Tr   z*:some action:_hostsN)r   CompleteHostnamesr   r   r7   r  s      r   test_hostnamesz ZshCompleterTests.test_hostnames   sn     ##%ll=%**534##-Ell=%**545r   c                 Z   t        j                         }|j                  dt         j                        }| j	                  |j                  d             t        j                  dd      }|j                  dt         j                        }| j	                  |j                  d             y)z
        CompleteUserAtHost produces zsh shell-code that completes hostnames or
        a word of the form <username>@<hostname>.
        r   z:host | user@host:r   Tr   r   N)r   CompleteUserAtHostr   r   r   
startswithr  s      r   test_userAtHostz!ZshCompleterTests.test_userAtHost,  sx    
 $$&ll=%**5';<=$$=Fll=%**5'789r   c                 "   t        j                         }|j                  dt         j                        }| j	                  |d       t        j                  dd      }|j                  dt         j                        }| j	                  |d       y)zv
        CompleteNetInterfaces produces zsh shell-code that completes system
        network interface names.
        r   z:some-option:_net_interfacesr   Tr   z*:some action:_net_interfacesN)r   CompleteNetInterfacesr   r   r7   r  s      r   test_netInterfacesz$ZshCompleterTests.test_netInterfaces9  sn    
 '')ll=%**5<=''mDIll=%**5=>r   N)r#   r$   r%   r>   r   r  r  r  r  r  r  r  r!  r$  r(   r   r   r   r     s:    

0G"
<7"($67
6:?r   r   c                       e Zd ZdZd Zy)CompleterNotImplementedTestszs
    Using an unknown shell constant with the various Completer() classes
    should raise NotImplementedError
    c           
         t         j                  t         j                  t         j                  t         j                  t         j
                  t         j                  t         j                  t         j                  t         j                  t         j                  g
}|D ],  }	  |       }| j                  t        |j                  dd       . y# t        $ r  |d      }Y 8w xY w)zM
        Using an unknown shellType should raise NotImplementedError
        Nbad_shell_type)r   r   r  r  r  r  r  r  r  r  r#  BaseExceptionrb   NotImplementedErrorr   )r   classesclsactions       r   test_unknownShellz.CompleterNotImplementedTests.test_unknownShellM  s    
 OO####  ##$$''
  	C# #V%6%6>N	 ! #T#s   CCCN)r#   r$   r%   r>   r.  r(   r   r   r&  r&  G  s    
r   r&  c                   <    e Zd ZdZ G d d      Zd Zd Zd Zd Zy)	FlagFunctionTestsz*
    Tests for L{usage.flagFunction}.
    c                   "    e Zd ZdZd Zd Zd Zy)FlagFunctionTests.SomeClassz>
        Dummy class for L{usage.flagFunction} tests.
        c                      y)z
            A one argument method to be tested by L{usage.flagFunction}.

            @param a: a useless argument to satisfy the function's signature.
            Nr(   )r   r   s     r   oneArgz"FlagFunctionTests.SomeClass.oneArgr      r   c                      y)zU
            A no argument method to be tested by L{usage.flagFunction}.
            Nr(   r   s    r   noArgz!FlagFunctionTests.SomeClass.noArgy  r5  r   c                      y)aG  
            A multiple arguments method to be tested by L{usage.flagFunction}.

            @param a: a useless argument to satisfy the function's signature.
            @param b: a useless argument to satisfy the function's signature.
            @param c: a useless argument to satisfy the function's signature.
            Nr(   )r   r   r   r   s       r   manyArgsz$FlagFunctionTests.SomeClass.manyArgs~  r5  r   N)r#   r$   r%   r>   r4  r7  r9  r(   r   r   	SomeClassr2  m  s    			
	r   r:  c                 ~    | j                  dt        j                  | j                         j                               y)zs
        L{usage.flagFunction} returns C{False} if the method checked allows
        exactly one argument.
        FN)assertIsr   flagFunctionr:  r4  r   s    r   test_hasArgzFlagFunctionTests.test_hasArg  s*    
 	eU//0@0G0GHIr   c                 ~    | j                  dt        j                  | j                         j                               y)zq
        L{usage.flagFunction} returns C{True} if the method checked allows
        exactly no argument.
        TN)r<  r   r=  r:  r7  r   s    r   
test_noArgzFlagFunctionTests.test_noArg  s*    
 	dE..t~~/?/E/EFGr   c                     | j                  t        j                  t        j                  | j	                         j
                        }| j                  dt        |             y)z
        L{usage.flagFunction} raises L{usage.UsageError} if the method checked
        allows more than one argument.
        z$Invalid Option function for manyArgsNrb   r   rc   r=  r:  r9  r7   r   r   excs     r   test_tooManyArgumentsz'FlagFunctionTests.test_tooManyArguments  sK    
 e00$..2B2K2K
 	?SJr   c                     | j                  t        j                  t        j                  | j	                         j
                  d      }| j                  dt        |             y)z
        L{usage.flagFunction} uses the given method name in the error message
        raised when the method allows too many arguments.
        flubudufz$Invalid Option function for flubudufNrB  rC  s     r   ,test_tooManyArgumentsAndSpecificErrorMessagez>FlagFunctionTests.test_tooManyArgumentsAndSpecificErrorMessage  sM    
 e00$..2B2K2KZ
 	?SJr   N)	r#   r$   r%   r>   r:  r>  r@  rE  rH  r(   r   r   r0  r0  h  s)     4JHKKr   r0  c                       e Zd ZdZd Zy)OptionsInternalTestsz6
    Tests internal behavior of C{usage.Options}.
    c                      G d dt         j                        } |       }| j                  t        j	                  g dd      |j
                  d   |j
                  d   |j
                  d   d       y)zs
        Options which are synonyms to another option are aliases towards the
        longest option name.
        c                       e Zd Zd ZeZeZy);OptionsInternalTests.test_optionsAliasesOrder.<locals>.Optsc                      y)z~
                This is an option method with a very long name, that is going to
                be aliased.
                Nr(   r   s    r   opt_very_very_longzNOptionsInternalTests.test_optionsAliasesOrder.<locals>.Opts.opt_very_very_long  r5  r   N)r#   r$   r%   rO  	opt_shortopt_sr(   r   r   OptsrM    s     +I&Er   rR  )r   shortvery-very-longrT  r   rS  N)r   r   r7   dictfromkeyssynonyms)r   rR  r   s      r   test_optionsAliasesOrderz-OptionsInternalTests.test_optionsAliasesOrder  sc    	'5== 	' vMM:<LM]]3'w/"&--0@"A	
r   N)r#   r$   r%   r>   rX  r(   r   r   rJ  rJ    s    
r   rJ  N)r>   twisted.pythonr   twisted.trialr   r   r   TestCaser*   r@   rN   rf   rj   rv   r   r   r   r   r   r   r   r   r&  r0  rJ  r(   r   r   <module>r\     s\  
 ! "7%-- 76(IH-- (IV5== $8K"" 8KvN N
5== 
"?h'' "?J=(## = u}}  |?h'' |?~!=h'' !=H?h'' ?.P?)) P?f8#4#4 B?K)) ?KD
8,, 
r   