o
    Óó·i[  ã                   @   sd  d Z ddlmZ ddlmZ G dd„ dejƒZG dd„ dejƒZG dd	„ d	ejƒZ	G d
d„ dejƒZ
G dd„ dejƒZG dd„ dejƒZG dd„ dejƒZG dd„ dejƒZG dd„ dejƒZG dd„ dejƒZG dd„ dejƒZG dd„ dejƒZG dd„ dejƒZG dd„ dejƒZG d d!„ d!ejƒZG d"d#„ d#ejƒZG d$d%„ d%ejƒZG d&d'„ d'ejƒZd(S ))zK
Tests for L{twisted.python.usage}, a command line option parsing library.
é    )Úusage)Úunittestc                   @   sH   e Zd Zg d¢g d¢g d¢g d¢gZg d¢ddggZdd	„ Zd
d„ ZdS )Ú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                 C   s   d| j d< d S )NúPONY!Úmyflag©Úopts©Úself© r   ú]C:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\twisted/test/test_usage.pyÚ
opt_myflag!   s   zWellBehaved.opt_myflagc                 C   s   |› d�| j d< d S )Nz WITH A PONY!Úmyparamr   ©r   Úvaluer   r   r   Úopt_myparam$   s   zWellBehaved.opt_myparamN)Ú__name__Ú
__module__Ú__qualname__ÚoptParametersÚoptFlagsr   r   r   r   r   r   r      s    ü	ör   c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚParseCorrectnessTestszZ
    Test L{usage.Options.parseOptions} for correct values under
    good conditions.
    c                 C   s$   d  ¡ | _tƒ | _| j | j¡ dS )zL
        Instantiate and parseOptions a well-behaved Options class.
        úA--long Alpha -n Beta --shortless Gamma -f --myflag --myparam TofuN)ÚsplitÚniceArgVr   ÚniceÚparseOptionsr   r   r   r   ÚsetUp.   s
   þzParseCorrectnessTests.setUpc                 C   sT   |   | jjd d¡ |   | jjd d¡ |   | jjd d¡ |   | jjd d¡ d	S )
z1
        Parameters have correct values.
        r   ÚAlphar   ÚBetar
   r   r   ÚGammaN©ÚassertEqualr(   r   r   r   r   r   Útest_checkParameters;   s   z*ParseCorrectnessTests.test_checkParametersc                 C   ó,   |   | jjd d¡ |   | jjd d¡ dS )z,
        Flags have correct values.
        r   é   r   r   Nr.   r   r   r   r   Útest_checkFlagsD   ó   z%ParseCorrectnessTests.test_checkFlagsc                 C   r1   )zB
        Custom flags and parameters have correct values.
        r   r   r   zTofu WITH A PONY!Nr.   r   r   r   r   Útest_checkCustomsK   r4   z'ParseCorrectnessTests.test_checkCustomsN)r   r    r!   Ú__doc__r*   r0   r3   r5   r   r   r   r   r$   (   s    	r$   c                   @   sL   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d„ ZeZdS )ÚTypedOptionsÚfoointNéˆ  zFoo intÚfoofloatçìQ¸…ë@z	Foo floatÚeggintzEgg int without defaultÚeggfloatzEgg float without defaultc                 C   s
   || _ dS )zg
        This option has an underscore in its name to exercise the _ to -
        translation.
        N)ÚunderscoreValuer   r   r   r   Úopt_under_score[   s   
zTypedOptions.opt_under_score)r   r    r!   ÚintÚfloatr"   r?   Zopt_ur   r   r   r   r7   S   s    ür7   c                   @   s@   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dS )Ú
TypedTestszK
    Test L{usage.Options.parseOptions} for options with forced types.
    c                 C   s   t ƒ | _d S ©N)r7   r   r   r   r   r   r*   j   s   zTypedTests.setUpc                 C   sˆ   g }| j  |¡ |  | j jd d¡ |  | j jd t¡ |  | j jd d¡ |  | j jd t¡ |  | j jd ¡ |  | j jd ¡ dS )z,
        Default values are parsed.
        r8   r9   r:   r;   r<   r=   N)r   r)   r/   r   ÚassertIsInstancer@   rA   ÚassertIsNone©r   ÚargVr   r   r   Útest_defaultValuesm   s   zTypedTests.test_defaultValuesc                 C   s¸   d  ¡ }| j |¡ |  | jjd d¡ |  | jjd t¡ |  | jjd d¡ |  | jjd t¡ |  | jjd d¡ |  | jjd t¡ |  | jjd d	¡ |  | jjd t¡ d
S )z2
        int and float values are parsed.
        z8--fooint 912 --foofloat -823.1 --eggint 32 --eggfloat 21r8   i�  r:   gÍÌÌÌÌ¸‰Àr<   é    r=   g      5@N)r&   r   r)   r/   r   rD   r@   rA   rF   r   r   r   Útest_parsingValuesz   s   zTypedTests.test_parsingValuesc                 C   ó$   | j  ddg¡ |  | j jd¡ dS )zw
        A dash in an option name is translated to an underscore before being
        dispatched to a handler.
        z--under-scoreÚfooN©r   r)   r/   r>   r   r   r   r   Útest_underscoreOption‰   s   z TypedTests.test_underscoreOptionc                 C   rK   )zE
        An option name with a dash in it can have an alias.
        z-uÚbarNrM   r   r   r   r   Útest_underscoreOptionAlias‘   s   z%TypedTests.test_underscoreOptionAliasc                 C   s    d  ¡ }|  tj| jj|¡ dS )z7
        Passing wrong values raises an error.
        z--fooint eggN)r&   ÚassertRaisesr   Ú
UsageErrorr)   rF   r   r   r   Útest_invalidValues˜   s   zTypedTests.test_invalidValuesN)
r   r    r!   r6   r*   rH   rJ   rN   rP   rS   r   r   r   r   rB   e   s    rB   c                   @   s   e Zd Zg d¢gZdS )ÚWrongTypedOptions)ÚbarwrongNNzBar with wrong coerceÚheN)r   r    r!   r"   r   r   r   r   rT       s    rT   c                   @   s8   e Zd Zdd„ Zdd„ Zddddegdddd	eggZdS )
ÚWeirdCallableOptionsc                 C   ó   t dƒ‚)NZOuch)ÚRuntimeError©r   r   r   r   Ú_bar¥   ó   zWeirdCallableOptions._barc                 C   rX   )NZYay)Ú
ValueErrorrZ   r   r   r   Ú_foo¨   r\   zWeirdCallableOptions._foorU   NzBar with strange callableZfoowrongzFoo with strange callable)r   r    r!   r[   r^   r"   r   r   r   r   rW   ¤   s    þrW   c                   @   ó(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚWrongTypedTestszF
    Test L{usage.Options.parseOptions} for wrong coerce options.
    c                 C   s"   t ƒ }d ¡ }|  t|j|¡ dS )z2
        Using a non-callable type fails.
        z--barwrong eggN)rT   r&   rQ   Ú	TypeErrorr)   ©r   ÚusrG   r   r   r   Útest_nonCallable¶   s   z WrongTypedTests.test_nonCallablec                 C   s   t ƒ }g }| |¡ dS )zP
        The coerce functions are not called if no values are provided.
        N)rW   r)   rb   r   r   r   Útest_notCalledInDefault¾   s   z'WrongTypedTests.test_notCalledInDefaultc                 C   sR   t ƒ }d ¡ }|  tj|j|¡}|  t|ƒd¡ t ƒ }d ¡ }|  t|j|¡ dS )zI
        Errors raised by coerce functions are handled properly.
        z--foowrong blahz&Parameter type enforcement failed: Yayz--barwrong blahN)	rW   r&   rQ   r   rR   r)   r/   ÚstrrY   )r   rc   rG   Úer   r   r   Útest_weirdCallableÆ   s   z"WrongTypedTests.test_weirdCallableN)r   r    r!   r6   rd   re   rh   r   r   r   r   r`   ±   s
    r`   c                   @   ó   e Zd Zdd„ ZdS )ÚOutputTestsc                 C   s.   t ƒ }|  tj|jdg¡}|  t|ƒd¡ dS )zF
        Error output case adjustment does not mangle options
        z-Zzoption -Z not recognizedN)r   rQ   r   rR   r)   r/   rf   )r   Úoptrg   r   r   r   Útest_uppercasing×   s   zOutputTests.test_uppercasingN)r   r    r!   rl   r   r   r   r   rj   Ö   ó    rj   c                   @   s   e Zd ZdgZdgZdS )ÚInquisitionOptions)Úexpectrg   )útorture-deviceÚtúcomfy-chairzset preferred torture deviceN)r   r    r!   r#   r"   r   r   r   r   rn   à   s
    ÿÿrn   c                   @   s   e Zd ZddgZdS )ÚHolyQuestOptions)Ú	horsebackÚhzuse a horse)ú	for-grailÚgN)r   r    r!   r#   r   r   r   r   rs   é   s    þrs   c                   @   s*   e Zd ZdgZddedfddedfgZdS )	ÚSubCommandOptions)úeuropian-swallowNz$set default swallow type to EuropianÚinquisitionÚinquestzPerform an inquisitionÚ	holyquestZquestzEmbark upon a holy questN)r   r    r!   r#   rn   rs   ÚsubCommandsr   r   r   r   rx   ð   s    ÿ

þrx   c                   @   sP   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚSubCommandTestszJ
    Test L{usage.Options.parseOptions} for options with subcommands.
    c                 C   sd   t ƒ }| ddg¡ |  |d ¡ |  |jd¡ |  |jt¡ |  |jd ¡ |  |jd d¡ dS )z-
        A subcommand is recognized.
        ú--europian-swallowrz   ry   ro   rp   rr   N)	rx   r)   Ú
assertTruer/   Ú
subCommandrD   Ú
subOptionsrn   ÚassertFalse©r   r   r   r   r   Útest_simpleSubcommandÿ   ó   z%SubCommandTests.test_simpleSubcommandc                 C   ód   t ƒ }| g d¢¡ |  |d ¡ |  |jd¡ |  |jt¡ |  |jd ¡ |  |jd d¡ dS )zA
        Flags and options of a subcommand are assigned.
        )rz   ú--expectú--torture-device=featherry   rz   ro   rp   ÚfeatherN©	rx   r)   rƒ   r/   r�   rD   r‚   rn   r€   r„   r   r   r   Ú"test_subcommandWithFlagsAndOptions  r†   z2SubCommandTests.test_subcommandWithFlagsAndOptionsc                 C   r‡   )zG
        Flags and options of a subcommand alias are assigned.
        )r{   rˆ   r‰   ry   rz   ro   rp   rŠ   Nr‹   r„   r   r   r   Ú'test_subcommandAliasWithFlagsAndOptions  r†   z7SubCommandTests.test_subcommandAliasWithFlagsAndOptionsc                 C   sb   t ƒ }| ddg¡ |  |d ¡ |  |jd¡ |  |jt¡ |  |jd ¡ |  |jd ¡ dS )zG
        Flags and options of another subcommand are assigned.
        r|   z--for-grailry   rt   rv   N)	rx   r)   rƒ   r/   r�   rD   r‚   rs   r€   r„   r   r   r   Ú)test_anotherSubcommandWithFlagsAndOptions#  s   z9SubCommandTests.test_anotherSubcommandWithFlagsAndOptionsc                 C   s@   t ƒ }| dg¡ |  |d ¡ |  |j¡ |  t|dƒ¡ dS )z€
        If no subcommand is specified and no default subcommand is assigned,
        a subcommand will not be implied.
        r   ry   r‚   N)rx   r)   r€   rE   r�   rƒ   Úhasattrr„   r   r   r   Útest_noSubcommand/  s
   z!SubCommandTests.test_noSubcommandc                 C   sh   t ƒ }d|_| dg¡ |  |d ¡ |  |jd¡ |  |jt¡ |  	|jd ¡ |  |jd d¡ dS )	zK
        Flags and options in the default subcommand are assigned.
        r{   r   ry   rz   ro   rp   rr   N)
rx   ZdefaultSubCommandr)   r€   r/   r�   rD   r‚   rn   rƒ   r„   r   r   r   Útest_defaultSubcommand:  s   z&SubCommandTests.test_defaultSubcommandc                    s`   G dd„ dt jƒ‰ G ‡ fdd„dt jƒ}|ƒ }| dg¡ |  t|jdƒ¡ |  |jj|¡ dS )zw
        The parseOptions method from the Options object specified for the
        given subcommand is called.
        c                   @   ri   )zDSubCommandTests.test_subCommandParseOptionsHasParent.<locals>.SubOptc                 _   s&   | j | _tjj| g|¢R i |¤Ž d S rC   )ÚparentÚ	sawParentr   ÚOptionsr)   )r   ÚaÚkwr   r   r   r)   N  s   zQSubCommandTests.test_subCommandParseOptionsHasParent.<locals>.SubOpt.parseOptionsN)r   r    r!   r)   r   r   r   r   ÚSubOptM  rm   r—   c                       ó   e Zd Zdd” dfgZdS )zASubCommandTests.test_subCommandParseOptionsHasParent.<locals>.OptrL   r   rO   N©r   r    r!   r}   r   ©r—   r   r   ÚOptR  ó    
ÿr›   rL   r“   N)r   r”   r)   r€   r�   r‚   r/   r“   )r   r›   r   r   rš   r   Ú$test_subCommandParseOptionsHasParentG  s   z4SubCommandTests.test_subCommandParseOptionsHasParentc                    sª   G dd„ dt jƒ‰ G ‡ fdd„dt jƒ}G ‡ fdd„dt jƒ}|ƒ }| dg¡ |ƒ }| dg¡ |  t|jd	ƒ¡ |  t|jd	ƒ¡ |  |jj|¡ |  |jj|¡ d
S )zh
        The .parent pointer is correct even when the same Options class is
        used twice.
        c                   @   s   e Zd ZdS )z:SubCommandTests.test_subCommandInTwoPlaces.<locals>.SubOptN)r   r    r!   r   r   r   r   r—   b  s    r—   c                       r˜   )z:SubCommandTests.test_subCommandInTwoPlaces.<locals>.OptFoorL   r   ÚquuxNr™   r   rš   r   r   ÚOptFooe  rœ   rŸ   c                       r˜   )z:SubCommandTests.test_subCommandInTwoPlaces.<locals>.OptBarrO   Úbrž   Nr™   r   rš   r   r   ÚOptBarj  rœ   r¡   rL   rO   r’   N)r   r”   r)   r€   r�   r‚   ZfailUnlessIdenticalr’   )r   rŸ   r¡   ZoFooZoBarr   rš   r   Útest_subCommandInTwoPlaces\  s   z*SubCommandTests.test_subCommandInTwoPlacesN)r   r    r!   r6   r…   rŒ   r�   rŽ   r�   r‘   r�   r¢   r   r   r   r   r~   ú   s    r~   c                   @   r_   )	ÚHelpStringTestsz&
    Test generated help strings.
    c                 C   s   d  ¡ | _tƒ | _dS )z;
        Instantiate a well-behaved Options class.
        r%   N)r&   r'   r   r(   r   r   r   r   r*   ~  s   þzHelpStringTests.setUpc              
   C   sB   z| j  ¡  W dS  ty  } z|  |¡ W Y d}~dS d}~ww )z,
        __str__ shouldn't go boom.
        N)r(   Ú__str__Ú	ExceptionZfail)r   rg   r   r   r   Útest_noGoBoom‰  s   €ÿzHelpStringTests.test_noGoBoomc                 C   sF   dd„ t | jƒ ¡ D ƒ}|  t|ƒdk¡ |  |d  d¡dk¡ dS )zK
        Extra whitespace in flag and parameters docs is stripped.
        c                 S   s   g | ]}|  d ¡dkr|‘qS )r   r   )Úfind)Ú.0Úsr   r   r   Ú
<listcomp>˜  s    zJHelpStringTests.test_whitespaceStripFlagsAndParameters.<locals>.<listcomp>r   ZflagalliciousN)rf   r(   Ú
splitlinesr€   Úlenr§   )r   Úlinesr   r   r   Ú&test_whitespaceStripFlagsAndParameters’  s   z6HelpStringTests.test_whitespaceStripFlagsAndParametersN)r   r    r!   r6   r*   r¦   r®   r   r   r   r   r£   y  s
    	r£   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚPortCoerceTestsz3
    Test the behavior of L{usage.portCoerce}.
    c                 C   s:   |   dt d¡¡ |   dt d¡¡ |   dt d¡¡ dS )z4
        Test the answers with valid input.
        r   Ú0iŠ  Z3210iÿÿ  Z65535N)r/   r   Ú
portCoercer   r   r   r   Útest_validCoerce¢  s   z PortCoerceTests.test_validCoercec                 C   sD   |   ttjd¡ |   ttjd¡ |   ttjd¡ |   ttjd¡ dS )z"
        Test error path.
        Ú z-21Z212189rL   N)rQ   r]   r   r±   r   r   r   r   Útest_errorCoerceª  s   z PortCoerceTests.test_errorCoerceN)r   r    r!   r6   r²   r´   r   r   r   r   r¯   �  s    r¯   c                   @   s`   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ ZdS )ÚZshCompleterTestsz‹
    Test the behavior of the various L{twisted.usage.Completer} classes
    for producing output usable by zsh tab-completion system.
    c                 C   óN   t  ¡ }| dt j¡}|  |d¡ t jddd�}| dt j¡}|  |d¡ dS )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Ú_ZSHr/   ©r   ÚcÚgotr   r   r   Útest_completerº  ó   z ZshCompleterTests.test_completerc                 C   st   t  ¡ }| dt j¡}|  |d¡ t  d¡}| dt j¡}|  |d¡ t jdddd�}| dt j¡}|  |d¡ d	S )
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¿   r/   rÀ   r   r   r   Ú
test_filesÆ  s   
zZshCompleterTests.test_filesc                 C   r¶   )zV
        CompleteDirs produces zsh shell-code that completes directory names.
        r·   z:some-option:_directoriesr¸   Tr¹   z*:some action:_directoriesN)r   ÚCompleteDirsr¾   r¿   r/   rÀ   r   r   r   Ú	test_dirs×  rÄ   zZshCompleterTests.test_dirsc                 C   s~   t  d¡}| dt j¡}|  |d¡ t  g d¢¡}| dt j¡}|  |d¡ t jg d¢ddd�}| dt j¡}|  |d	¡ d
S )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¿   r/   rÀ   r   r   r   Ú	test_listã  s   
zZshCompleterTests.test_listc                 C   s‚   t  d¡}| dt j¡}|  |d¡ t  g d¢¡}| dt j¡}|  |d¡ t jg d¢ddd�}| dt j¡}d	}|  ||¡ d
S )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¿   r/   )r   rÁ   rÂ   Úexpectedr   r   r   Útest_multiListô  s   
z ZshCompleterTests.test_multiListc                 C   r¶   )zd
        CompleteUsernames produces zsh shell-code that completes system
        usernames.
        r·   z:some-option:_usersr¸   Tr¹   z*:some action:_usersN)r   ÚCompleteUsernamesr¾   r¿   r/   ©r   rÁ   Úoutr   r   r   Útest_usernames  ó   z ZshCompleterTests.test_usernamesc                 C   r¶   )zc
        CompleteGroups produces zsh shell-code that completes system group
        names.
        r·   z:group:_groupsr¸   Tr¹   z*:some action:_groupsN)r   ÚCompleteGroupsr¾   r¿   r/   rÔ   r   r   r   Útest_groups  r×   zZshCompleterTests.test_groupsc                 C   r¶   )zU
        CompleteHostnames produces zsh shell-code that completes hostnames.
        r·   z:some-option:_hostsr¸   Tr¹   z*:some action:_hostsN)r   ÚCompleteHostnamesr¾   r¿   r/   rÔ   r   r   r   Útest_hostnames   rÄ   z ZshCompleterTests.test_hostnamesc                 C   sV   t  ¡ }| dt j¡}|  | d¡¡ t jddd�}| dt j¡}|  | d¡¡ dS )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Ô   r   r   r   Útest_userAtHost,  s   z!ZshCompleterTests.test_userAtHostc                 C   r¶   )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¿   r/   rÔ   r   r   r   Útest_netInterfaces9  r×   z$ZshCompleterTests.test_netInterfacesN)r   r    r!   r6   rÃ   rÆ   rÈ   rÏ   rÒ   rÖ   rÙ   rÛ   rÞ   rà   r   r   r   r   rµ   ´  s    rµ   c                   @   ó   e Zd ZdZdd„ ZdS )ÚCompleterNotImplementedTestszs
    Using an unknown shell constant with the various Completer() classes
    should raise NotImplementedError
    c              
   C   sr   t jt jt jt jt jt jt jt jt j	t j
g
}|D ]}z|ƒ }W n ty,   |dƒ}Y nw |  t|jdd¡ qdS )zM
        Using an unknown shellType should raise NotImplementedError
        NZbad_shell_type)r   r½   rÅ   rÇ   rÎ   rÐ   rÓ   rØ   rÚ   rÜ   rß   ÚBaseExceptionrQ   ÚNotImplementedErrorr¾   )r   ÚclassesÚclsÚactionr   r   r   Útest_unknownShellM  s*   ö
ÿ
ÿûz.CompleterNotImplementedTests.test_unknownShellN)r   r    r!   r6   rè   r   r   r   r   râ   G  s    râ   c                   @   s>   e Zd ZdZG dd„ dƒZdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚFlagFunctionTestsz*
    Tests for L{usage.flagFunction}.
    c                   @   r_   )	zFlagFunctionTests.SomeClassz>
        Dummy class for L{usage.flagFunction} tests.
        c                 C   ó   dS )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•   r   r   r   ÚoneArgr  ó    z"FlagFunctionTests.SomeClass.oneArgc                 C   rê   )zU
            A no argument method to be tested by L{usage.flagFunction}.
            Nr   r   r   r   r   ÚnoArgy  rì   z!FlagFunctionTests.SomeClass.noArgc                 C   rê   )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Á   r   r   r   ÚmanyArgs~  rì   z$FlagFunctionTests.SomeClass.manyArgsN)r   r    r!   r6   rë   rí   rî   r   r   r   r   Ú	SomeClassm  s
    rï   c                 C   ó   |   dt |  ¡ j¡¡ dS )zs
        L{usage.flagFunction} returns C{False} if the method checked allows
        exactly one argument.
        FN)ÚassertIsr   ÚflagFunctionrï   rë   r   r   r   r   Útest_hasArg‡  ó   zFlagFunctionTests.test_hasArgc                 C   rð   )zq
        L{usage.flagFunction} returns C{True} if the method checked allows
        exactly no argument.
        TN)rñ   r   rò   rï   rí   r   r   r   r   Ú
test_noArgŽ  rô   zFlagFunctionTests.test_noArgc                 C   s,   |   tjtj|  ¡ j¡}|  dt|ƒ¡ dS )z
        L{usage.flagFunction} raises L{usage.UsageError} if the method checked
        allows more than one argument.
        z$Invalid Option function for manyArgsN©rQ   r   rR   rò   rï   rî   r/   rf   ©r   Úexcr   r   r   Útest_tooManyArguments•  s   ÿz'FlagFunctionTests.test_tooManyArgumentsc                 C   s.   |   tjtj|  ¡ jd¡}|  dt|ƒ¡ dS )z‘
        L{usage.flagFunction} uses the given method name in the error message
        raised when the method allows too many arguments.
        Zflubudufz$Invalid Option function for flubudufNrö   r÷   r   r   r   Ú,test_tooManyArgumentsAndSpecificErrorMessageŸ  s   ÿz>FlagFunctionTests.test_tooManyArgumentsAndSpecificErrorMessageN)	r   r    r!   r6   rï   ró   rõ   rù   rú   r   r   r   r   ré   h  s    
ré   c                   @   rá   )ÚOptionsInternalTestsz6
    Tests internal behavior of C{usage.Options}.
    c                 C   sN   G dd„ dt jƒ}|ƒ }|  t g d¢d¡|jd |jd |jd dœ¡ dS )zs
        Options which are synonyms to another option are aliases towards the
        longest option name.
        c                   @   s   e Zd Zdd„ ZeZeZdS )z;OptionsInternalTests.test_optionsAliasesOrder.<locals>.Optsc                 S   rê   )z~
                This is an option method with a very long name, that is going to
                be aliased.
                Nr   r   r   r   r   Úopt_very_very_long¶  rì   zNOptionsInternalTests.test_optionsAliasesOrder.<locals>.Opts.opt_very_very_longN)r   r    r!   rü   Z	opt_shortZopt_sr   r   r   r   ÚOptsµ  s    rý   )r©   Úshortúvery-very-longrÿ   r©   rþ   N)r   r”   r/   ÚdictÚfromkeysZsynonyms)r   rý   r   r   r   r   Útest_optionsAliasesOrder¯  s   
ýþz-OptionsInternalTests.test_optionsAliasesOrderN)r   r    r!   r6   r  r   r   r   r   rû   ª  s    rû   N)r6   Ztwisted.pythonr   Ztwisted.trialr   r”   r   ZTestCaser$   r7   rB   rT   rW   r`   rj   rn   rs   rx   r~   r£   r¯   rµ   râ   ré   rû   r   r   r   r   Ú<module>   s,   +;%
	
$ !B