CasperSecurity

Current Path : /usr/lib/python3/dist-packages/twisted/python/test/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/twisted/python/test/__pycache__/test_util.cpython-310.pyc

o

�bH��@s�dZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZddlm
Z
z
ddlZddlZWn
ey?dZdZYnweZeZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlm Z ddl!m"Z"dd
l#m$Z$m%Z%ddl&m'Z(e ej)��*�Z+Gdd�de%�Z,Gdd�de%�Z-Gdd�de%�Z.e
e/edd�d�Gdd�de%��Z0Gdd�de%�Z1Gdd�de%�Z2Gdd�de%�Z3Gdd �d e�Z4e
e�5e�d!�Gd"d#�d#e%��Z6Gd$d%�d%e%�Z7Gd&d'�d'e%�Z8Gd(d)�d)ej9�Z:Gd*d+�d+ej9�Z;Gd,d-�d-e:�Z<Gd.d/�d/�Z=Gd0d1�d1�Z>Gd2d3�d3e%�Z?e
e/ed4d�d5�Gd6d7�d7e%��Z@e
ejAd8�Gd9d:�d:e%��ZBGd;d<�d<e%�ZCGd=d>�d>e%�ZDGd?d@�d@e%�ZEGdAdB�dBe%�ZFdS)Cz#
Tests for L{twisted.python.util}.
�N)�Iterable�Mapping�MutableMapping�Sequence)�skipIf)�reactor)�Deferred)�ProcessDone)�IReactorProcess)�ProcessProtocol)�util)�FilePath)�MockOS)�FailTest�TestCase)�suppressc@sXeZdZdd�Zdd�Zdd�Zeedud�d	d
��Zdd�Z	ee
dud
�dd��ZdS)�	UtilTestscCs"gd�}|�t�|�gd��dS)N)�a��abr��r�rr�)rrrrrrr)�assertEqualr�uniquify)�self�
listWithDupes�r�?/usr/lib/python3/dist-packages/twisted/python/test/test_util.py�testUniq+szUtilTests.testUniqcCs\|�t�ttdd��|�t�ttdd��z
t�ttdd�Wtd��ty-YdSw)Nrrz,util.raises didn't raise when it should have)�
assertTruer�raises�ZeroDivisionError�divmod�assertFalse�	TypeErrorr�rrrr�
testRaises/s��zUtilTests.testRaisescC�|�t�d�d�dS)��
        When L{uidFromString} is called with a base-ten string representation
        of an integer, it returns the integer.
        �100�dN)rr�
uidFromStringr'rrr�test_uidFromNumericString:�z#UtilTests.test_uidFromNumericStringNz0Username/UID conversion requires the pwd module.cC�(t�t���}|�t�|j�|j�dS)r*N)	�pwd�getpwuid�os�getuidrrr-�pw_name�pw_uid)r�pwentrrr�test_uidFromUsernameStringA�z$UtilTests.test_uidFromUsernameStringcCr))��
        When L{gidFromString} is called with a base-ten string representation
        of an integer, it returns the integer.
        r+r,N)rr�
gidFromStringr'rrr�test_gidFromNumericStringJr/z#UtilTests.test_gidFromNumericStringz2Group Name/GID conversion requires the grp module.cCr0)r:N)	�grp�getgrgidr3�getgidrrr;�gr_name�gr_gid)r�grentrrr�test_gidFromGroupnameStringQr9z%UtilTests.test_gidFromGroupnameString)�__name__�
__module__�__qualname__r r(r.rr1r8r<r=rCrrrrr*s
rc@�eZdZdZdd�ZdS)�NameToLabelTestsz#
    Tests for L{nameToLabel}.
    cCsDgd�}|D]\}}t�|�}|�||d|�d|�d|���qdS)zK
        Test the various kinds of inputs L{nameToLabel} supports.
        ))�f�F)�fo�Fo)�foo�Foo)�fooBarzFoo Bar)�	fooBarBazzFoo Bar BazznameToLabel(z) == z != N)r�nameToLabelr)r�nameData�inp�out�gotrrr�test_nameToLabel`s

"�z!NameToLabelTests.test_nameToLabelN)rDrErF�__doc__rVrrrrrH[�rHc@rG)�UntilConcludesTestsz:
    Tests for L{untilConcludes}, an C{EINTR} helper.
    csx�fdd�}dg�_d�_��t�|dd�d����jd�dttg�_d�_��t�|dd�d����jd�dS)	a
        L{untilConcludes} calls the function passed to it until the function
        does not raise either L{OSError} or L{IOError} with C{errno} of
        C{EINTR}.  It otherwise completes with the same result as the function
        passed to it.
        cs4�jd7_�j��}|dur|tjd��||S)NrzInterrupted system call!)�calls�
exceptions�pop�errno�EINTR)r�b�excr'rrrI}s

z3UntilConcludesTests.test_uninterruptably.<locals>.fNrrrr�)r[rZrr�untilConcludes�OSError�IOError)rrIrr'r�test_uninterruptablyusz(UntilConcludesTests.test_uninterruptablyN)rDrErFrWrerrrrrYprXrYr4zgetuid/setuid not availablec@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�SwitchUIDTestsz&
    Tests for L{util.switchUID}.
    cCs2t�|_|�td|j�|�td|j�g|_dS)Nr3�
initgroups)r�mockos�patchrrg�initgroupsCallsr'rrr�setUp�s
zSwitchUIDTests.setUpcCs|j�||f�dS)zK
        Save L{util.initgroups} calls in C{self.initgroupsCalls}.
        N)rj�append)r�uid�gidrrrrg�szSwitchUIDTests.initgroupscCs2t�dd�|�|jdg�|�|jjdg�dS)zn
        L{util.switchUID} calls L{util.initgroups} and then C{os.setuid} with
        the given uid.
        ��.N�roN)�setuidro)r�	switchUIDrrjrh�actionsr'rrr�test_uid�szSwitchUIDTests.test_uidcCs4t�ddd�|�|jdg�|�|jjdg�dS)z�
        L{util.switchUID} calls L{util.initgroups} and then C{os.seteuid} with
        the given uid if the C{euid} parameter is set to C{True}.
        roNTrp)rrrrrjrh�seteuidCallsr'rrr�	test_euid�szSwitchUIDTests.test_euidcCs�|j��}t�|d�|�|jg�|�|jjg�|�tjg�}|�t|�d�|�	d||dd�|�	d||dd�dS)z�
        If the current uid is the same as the uid passed to L{util.switchUID},
        then initgroups does not get called, but a warning is issued.
        Nrz&tried to drop privileges and setuid %ir�messagezbut uid is already %i)
rhr4rrrrrjrs�
flushWarnings�len�assertIn)rrm�currentWarningsrrr�test_currentUID�s

�zSwitchUIDTests.test_currentUIDcCs�|j��}t�|dd�|�|jg�|�|jjg�|�tjg�}|�t|�d�|�	d||dd�|�	d||dd�dS)z�
        If the current euid is the same as the euid passed to L{util.switchUID},
        then initgroups does not get called, but a warning is issued.
        NTrz'tried to drop privileges and seteuid %irrwzbut euid is already %i)
rh�geteuidrrrrrjrurxryrz)r�euidr{rrr�test_currentEUID�s

�zSwitchUIDTests.test_currentEUIDN)
rDrErFrWrkrgrtrvr|rrrrrrf�s		rfc@�8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�MergeFunctionMetadataTestsz-
    Tests for L{mergeFunctionMetadata}.
    csNt��t���fdd�}d�fdd�	}t�||�}|�|ddddd	���d
S)zt
        After merging C{foo}'s data into C{bar}, the returned function behaves
        as if it is C{bar}.
        cs�S�Nrr)�
foo_objectrrrM��zQMergeFunctionMetadataTests.test_mergedFunctionBehavesLikeMergeTarget.<locals>.foo�
cs|\}}�Sr�r)�x�yr�c�d�err_)�
bar_objectrr�bar�szQMergeFunctionMetadataTests.test_mergedFunctionBehavesLikeMergeTarget.<locals>.barrr)rr)�quuxN)r�)�objectr�mergeFunctionMetadata�assertIs�rrMr��bazr)r�r�r�)test_mergedFunctionBehavesLikeMergeTarget�szDMergeFunctionMetadataTests.test_mergedFunctionBehavesLikeMergeTargetcCs6dd�}dd�}d|_t�||�}|�|j|j�dS)zd
        Merging C{foo} into C{bar} returns a function with C{foo}'s
        C{__module__}.
        cS�dSr�rrrrrrM�r�z;MergeFunctionMetadataTests.test_moduleIsMerged.<locals>.foocSr�r�rrrrrr��r�z;MergeFunctionMetadataTests.test_moduleIsMerged.<locals>.barzsomewhere.elseN)rErr�rr�rrr�test_moduleIsMerged�s
z.MergeFunctionMetadataTests.test_moduleIsMergedcC�0dd�}dd�}t�||�}|�|j|j�dS)zX
        Merging C{foo} into C{bar} returns a function with C{foo}'s docstring.
        cS�dS)z&
            This is foo.
            NrrrrrrM�z>MergeFunctionMetadataTests.test_docstringIsMerged.<locals>.foocSr�)z&
            This is bar.
            Nrrrrrr�r�z>MergeFunctionMetadataTests.test_docstringIsMerged.<locals>.barN)rr�rrWr�rrr�test_docstringIsMerged�sz1MergeFunctionMetadataTests.test_docstringIsMergedcCr�)zS
        Merging C{foo} into C{bar} returns a function with C{foo}'s name.
        cSr�r�rrrrrrMr�z9MergeFunctionMetadataTests.test_nameIsMerged.<locals>.foocSr�r�rrrrrr�r�z9MergeFunctionMetadataTests.test_nameIsMerged.<locals>.barN)rr�rrDr�rrr�test_nameIsMergedsz,MergeFunctionMetadataTests.test_nameIsMergedcCshdd�}d|_d|_dd�}d|_d|_t�||�}|�|j|j�|�|j|j�|�|j|j�d	S)
zv
        Merging C{foo} into C{bar} returns a function with C{bar}'s
        dictionary, updated by C{foo}'s.
        cSr�r�rrrrrrM$r�zGMergeFunctionMetadataTests.test_instanceDictionaryIsMerged.<locals>.foorrcSr�r�rrrrrr�*r�zGMergeFunctionMetadataTests.test_instanceDictionaryIsMerged.<locals>.barrrN)rr_r�rr�rr�rrr�test_instanceDictionaryIsMergedsz:MergeFunctionMetadataTests.test_instanceDictionaryIsMergedN)	rDrErFrWr�r�r�r�r�rrrrr��sr�c@rG)�OrderedDictTestsz(
    Tests for L{util.OrderedDict}.
    cCs\ddlm}||j|jgd�}|�|ddd�|�|ddt�|�t|�d�dS)	z4
        L{util.OrderedDict} is deprecated.
        r)�OrderedDict��offendingFunctionsrwzftwisted.python.util.OrderedDict was deprecated in Twisted 15.5.0: Use collections.OrderedDict instead.�categoryrN)�twisted.python.utilr�rx�test_deprecatedr�DeprecationWarningry)rr�r{rrrr�;s
�z OrderedDictTests.test_deprecatedN)rDrErFrWr�rrrrr�6rXr�c@r�)
�InsensitiveDictTestsz,
    Tests for L{util.InsensitiveDict}.
    cCsLt��}|�t|t��|�t|t��|�t|t��|�t|t��dS)zN
        L{util.InsensitiveDict} implements L{typing.MutableMapping}.
        N)	r�InsensitiveDictr!�
isinstancerrrr%r)r�dctrrr�test_abcRs
zInsensitiveDictTests.test_abccCstjddddid�dd�}|�|dddi�|�|dd�|�|��|�|�|d|�d��|�d|�|�d|�tt|�|tjd	��}|�||�gd
�}|D]}|�||���|�|||f|�	��qU|�t
|�t
|��|d=|d=|�|��dg�dS)zr
        L{util.InsensitiveDict} preserves the case of keys if constructed with
        C{preserve=True}.
        r�rr�rNr�fnz��preserver�rMrN)r�r�)rNr�rN)rr�r�copy�getrz�eval�repr�keys�itemsry)rr��resultr�r�rrr�
test_preserve\s,��z"InsensitiveDictTests.test_preservecCs�tjddddid�dd�}gd�}|D]}|�||���|�|||f|���q|�t|�t|��|d=|d=|�|��d	g�d
S)z|
        L{util.InsensitiveDict} does not preserves the case of keys if
        constructed with C{preserve=False}.
        r�rrr�rr�)rMr�rrMr�N)rr�rzr�r�rry)rr�r�r�rrr�test_noPreserve{sz$InsensitiveDictTests.test_noPreservecC�:tjdd�}d|d<|�|dd�|�|��dg�dS)z4
        Unicode keys are case insensitive.
        Fr�rrN�FOOrMN�rr�rr��rr�rrr�test_unicode��z!InsensitiveDictTests.test_unicodecCr�)z2
        Bytes keys are case insensitive.
        Fr�rsFoosFOOsfooNr�r�rrr�
test_bytes�r�zInsensitiveDictTests.test_bytesN)	rDrErFrWr�r�r�r�r�rrrrr�Ms
	r�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�PasswordTestingProcessProtocolz�
    Write the string C{"secret\n"} to a subprocess and then collect all of
    its output and fire a Deferred with it when the process ends.
    cCsg|_|j�d�dS)Nssecret
)�output�	transport�writer'rrr�connectionMade�sz-PasswordTestingProcessProtocol.connectionMadecCs|j�||f�dSr�)r�rl)r�fdr�rrr�childDataReceived�sz0PasswordTestingProcessProtocol.childDataReceivedcCs|j�||jf�dSr�)�finished�callbackr�)r�reasonrrr�processEnded�sz+PasswordTestingProcessProtocol.processEndedN)rDrErFrWr�r�r�rrrrr��s
r�z,Process support required to test getPasswordc@�eZdZdd�ZdS)�GetPasswordTestscsRt�}t�|_tj|ttddgdtj�t	j
��d�id��fdd�}|j�|�S)a.
        Making sure getPassword accepts a password from standard input by
        running a child process which uses getPassword to read in a string
        which it then writes it out again.  Write a string to the child
        process and then read one and make sure it is the right string.
        s-csjimport sys
from twisted.python.util import getPassword
sys.stdout.write(getPassword())
sys.stdout.flush()
s
PYTHONPATH�utf8)�envcs"|\}}|�t���d|�dS)N)rssecret)�trapr	rz)r�r�r�r'rr�processFinished�s
z4GetPasswordTests.test_stdin.<locals>.processFinished)
r�rr�r�spawnProcess�pyExer3�pathsep�join�sys�path�encode�addCallback)r�pr�rr'r�
test_stdin�s�
�zGetPasswordTests.test_stdinN)rDrErFr�rrrrr��sr�c@r�)�SearchUpwardsTestscCs�t�d�tdd���tdd���tdd���t�d�t�d�t�d�t�d	�tjdd
gddgd
�}tj�d�tj	}|�
||�t�d�tjdd
gddgd
�}d}|�
||�dS)Nzsearchupwards/a/b/czsearchupwards/foo.txt�wzsearchupwards/a/foo.txtzsearchupwards/a/b/c/foo.txtzsearchupwards/barzsearchupwards/bamzsearchupwards/a/barzsearchupwards/a/b/bamzfoo.txtr��bam)�files�dirs�
searchupwards)
r3�makedirs�open�close�mkdirrr�r��abspath�sepr�shutil�rmtree)r�actual�expectedrrr�testSearchupwards�s&




�
�z$SearchUpwardsTests.testSearchupwardsN)rDrErFr�rrrrr��sr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�IntervalDifferentialTestscCs2tt�gd��}td�D]
}|�t|�d�qdS)Nr�r,�r�N��iterr�IntervalDifferential�ranger�next�rr��irrr�testDefault�s�z%IntervalDifferentialTests.testDefaultcCs4tt�dgd��}td�D]
}|�t|�d�q
dS)Nrar�r,�rarr�r�rrr�
testSingle�s�z$IntervalDifferentialTests.testSinglecCs�tt�ddgd��}td�D]b}|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d	�|�t|�d�|�t|�d
�|�t|�d�|�t|�d�|�t|�d
�|�t|�d�|�t|�d�qdS)Nra�r�r,r��rr�rr)rr�rr�rr�rr)rr�rr�rrr�r�rrr�testPair�s�z"IntervalDifferentialTests.testPaircCsVtt�gd�d��}td�D]�}|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�qdS)	N)rrrar�r,r�r�)rrr�)rrr�r�rrr�
testTriples,�z$IntervalDifferentialTests.testTriplecCs�tt�gd��}|�t|�d�|�d�|�t|�d�|�t|�d�|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�|�t|�d�dS)Nr�r�rr�rr�)r�rr�rr��addIntervalr�rrr�
testInserts

z$IntervalDifferentialTests.testInsertcCs�tt�ddgd��}|�t|�d�|�t|�d�|�t|�d�|�d�|�t|�d�|�t|�d�|�d�|�t|�d	�|�t|jd�dS)
Nrrar�r�r�r�r�r�r�)r�rr�rr��removeInterval�assertRaises�
ValueErrorr�rrr�
testRemove+s

z$IntervalDifferentialTests.testRemoveN)	rDrErFr�r�r�r�rrrrrrr��sr�c@�eZdZdZdZdd�ZdS)�Recordz8
    Trivial user of L{FancyEqMixin} used by tests.
    �rr_cC�||_||_dSr�r�rrr_rrr�__init__?�
zRecord.__init__N�rDrErFrW�compareAttributesr
rrrrr8�rc@r)�DifferentRecordzL
    Trivial user of L{FancyEqMixin} which is not related to L{Record}.
    rcCrr�rr	rrrr
KrzDifferentRecord.__init__NrrrrrrDrrc@�eZdZdZdS)�
DerivedRecordz@
    A class with an inheritance relationship to L{Record}.
    N)rDrErFrWrrrrrP�rc@�"eZdZdZdedefdd�ZdS)�EqualToEverythingzQ
    A class the instances of which consider themselves equal to everything.
    �other�returncCr�)NTr�rrrrr�__eq__[r�zEqualToEverything.__eq__N�rDrErFrWr��boolrrrrrrV�rc@r)�EqualToNothingzN
    A class the instances of which consider themselves equal to nothing.
    rrcCr�)NFrrrrrrdr�zEqualToNothing.__eq__Nrrrrrr_rrc@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�
EqualityTestsz$
    Tests for L{FancyEqMixin}.
    cCs\Gdd�dtj�}|�|�|�k�|�|�|�k�|�}|�||k�|�||k�dS)z�
        Instances of a class which mixes in L{FancyEqMixin} but which
        defines no comparison attributes compare by identity.
        c@seZdZdS)z*EqualityTests.test_identity.<locals>.EmptyN)rDrErFrrrr�EmptyssrN)r�FancyEqMixinr%r!)rr�emptyrrr�
test_identitymszEqualityTests.test_identitycCsl|�tdd�tdd�k�|�tdd�tdd�k�|�tdd�tdd�k�|�tdd�tdd�k�dS)z�
        Instances of a class which mixes in L{FancyEqMixin} should compare
        equal if all of their attributes compare equal.  They should not
        compare equal if any of their attributes do not compare equal.
        rrrrN)r!rr%r'rrr�
test_equality|�zEqualityTests.test_equalitycCsl|�tdd�tdd�k�|�tdd�tdd�k�|�tdd�tdd�k�|�tdd�tdd�k�dS)z
        Inequality between instances of a particular L{record} should be
        defined as the negation of equality.
        rrrrN)r%rr!r'rrr�test_unequality�szEqualityTests.test_unequalitycCs|�tdd�tdd�k�dS)zo
        Instances of different classes which mix in L{FancyEqMixin} should not
        compare equal.
        rrN)r%rrr'rrr�test_differentClassesEquality��z+EqualityTests.test_differentClassesEqualitycCs|�tdd�tdd�k�dS)zm
        Instances of different classes which mix in L{FancyEqMixin} should
        compare unequal.
        rrN)r!rrr'rrr�test_differentClassesInequality�r&z-EqualityTests.test_differentClassesInequalitycCsl|�tdd�tdd�k�|�tdd�tdd�k�|�tdd�tdd�k�|�tdd�tdd�k�dS)z�
        An instance of a class which derives from a class which mixes in
        L{FancyEqMixin} should compare equal to an instance of the base class
        if and only if all of their attributes compare equal.
        rrrrN)r!rrr%r'rrr�test_inheritedClassesEquality�r#z+EqualityTests.test_inheritedClassesEqualitycCsl|�tdd�tdd�k�|�tdd�tdd�k�|�tdd�tdd�k�|�tdd�tdd�k�dS)z�
        An instance of a class which derives from a class which mixes in
        L{FancyEqMixin} should compare unequal to an instance of the base
        class if any of their attributes compare unequal.
        rrrrN)r%rrr!r'rrr�test_inheritedClassesInequality�r#z-EqualityTests.test_inheritedClassesInequalitycCs0|�tdd�t�k�|�tdd�t�k�dS)z�
        The right-hand argument to the equality operator is given a chance
        to determine the result of the operation if it is of a type
        unrelated to the L{FancyEqMixin}-based instance on the left-hand
        side.
        rrN)r!rrr%rr'rrr�(test_rightHandArgumentImplementsEquality��z6EqualityTests.test_rightHandArgumentImplementsEqualitycCs0|�tdd�t�k�|�tdd�t�k�dS)z�
        The right-hand argument to the non-equality operator is given a
        chance to determine the result of the operation if it is of a type
        unrelated to the L{FancyEqMixin}-based instance on the left-hand
        side.
        rrN)r%rrr!rr'rrr�*test_rightHandArgumentImplementsUnequality�r+z8EqualityTests.test_rightHandArgumentImplementsUnequalityN)
rDrErFrWr!r"r$r%r'r(r)r*r,rrrrrhs

rr}zgeteuid/seteuid not availablec@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�RunAsEffectiveUserTestsz;
    Test for the L{util.runAsEffectiveUser} function.
    cCsTt�|_|�td|jj�|�td|jj�|�td|jj�|�td|jj�dS)Nr}�getegid�seteuid�setegid)rrhrir3r}r.r/r0r'rrrrk�s
zRunAsEffectiveUserTests.setUpcCs@|�||kp
||jjdk�|�||kp||jjdk�dS)zF
        Check if wanted UID/GID matched start or saved ones.
        ���N)r!rhru�setegidCalls)r�startUID�startGID�wantUID�wantGIDrrr�_securedFunction�s"z(RunAsEffectiveUserTests._securedFunctioncCs"t�dddd��}|�|d�dS)zo
        L{util.runAsEffectiveUser} forwards the result obtained by calling the
        given function
        rcSr�)Nrrrrrr�<lambda>�r�z<RunAsEffectiveUserTests.test_forwardResult.<locals>.<lambda>rN�r�runAsEffectiveUserr�rr�rrr�test_forwardResult�sz*RunAsEffectiveUserTests.test_forwardResultcCs$t�dddd�d�}|�|d�dS)ze
        L{util.runAsEffectiveUser} pass the given parameters to the given
        function.
        rcSsd|S)Nrr)r�rrrr8�sz=RunAsEffectiveUserTests.test_takeParameters.<locals>.<lambda>rrNr9r;rrr�test_takeParameters�sz+RunAsEffectiveUserTests.test_takeParameterscCs*tjddd
dd�ddd�}|�|d�d	S)zg
        L{util.runAsEffectiveUser} pass the keyword parameters to the given
        function.
        rrcSs|||Sr�r)r�r��zrrrr8�szDRunAsEffectiveUserTests.test_takesKeyworkArguments.<locals>.<lambda>rr)r>rNr�r9r;rrr�test_takesKeyworkArguments�sz2RunAsEffectiveUserTests.test_takesKeyworkArgumentsc	Cs\||j_||j_t�|||j||||�|�|jj|�|�|jj|�g|j_g|j_dS)z�
        Helper method checking the calls to C{os.seteuid} and C{os.setegid}
        made by L{util.runAsEffectiveUser}, when switching from startUID to
        wantUID and from startGID to wantGID.
        N)	rhr~�egidrr:r7rrur2)rr3r4r5r6�expectedUIDSwitches�expectedGIDSwitchesrrr�_testUIDGIDSwitch�s�	z)RunAsEffectiveUserTests._testUIDGIDSwitchc	Csd|�ddddgg�|�ddddddgg�|�ddddgddg�|�ddddddgddg�dS)zL
        Check UID/GID switches when current effective UID is root.
        rrN�rCr'rrr�	test_roots z!RunAsEffectiveUserTests.test_rootc	Csh|�ddddddgg�|�ddddgg�|�ddddgd�ddg�|�ddddgd�ddg�dS)zP
        Check UID/GID switches when current effective UID is non-root.
        rr�rrrrr�rrrrNrDr'rrr�test_UIDs z RunAsEffectiveUserTests.test_UIDc	Csd|�ddddgddg�|�ddddgg�|�ddddddgg�|�ddddddgddg�dS)zP
        Check UID/GID switches when current effective GID is non-root.
        rrrNrDr'rrr�test_GID&s z RunAsEffectiveUserTests.test_GIDc	Cs�|�ddddddgddg�|�ddddddgg�|�ddddgd�ddg�|�ddddgg�|�ddddgd�g�|�ddddgd�ddg�|�ddddgd�ddg�dS)zT
        Check UID/GID switches when current effective UID/GID is non-root.
        rrrFrrGNrDr'rrr�test_UIDGID/s z#RunAsEffectiveUserTests.test_UIDGIDN)rDrErFrWrkr7r<r=r?rCrErHrIrJrrrrr-�s			r-z.stdlib support for initgroups is not availablec@s eZdZdZdd�Zdd�ZdS)�InitGroupsTestsz'
    Tests for L{util.initgroups}.
    csng��fdd�}|�td|�g}|�td|j�t�t��d�|��t�t���j	dfg�|�
|�dS)zc
        Calling L{util.initgroups} will call the underlying stdlib
        implmentation.
        cs��||f�dSr�)rl)r�r��rZrr�mockInitgroupsIsz?InitGroupsTests.test_initgroupsInStdlib.<locals>.mockInitgroups�_initgroups�	setgroupsrN)rirrlrgr3r4rr1r2r5r%)rrM�setgroupsCallsrrLr�test_initgroupsInStdlibBsz'InitGroupsTests.test_initgroupsInStdlibcCs|�ttjt��d�dS)zN
        Calling L{util.initgroups} with None for gid gives an error.
        N)rr&rrgr3r4r'rrr�test_initgroupsNoneGidTsz&InitGroupsTests.test_initgroupsNoneGidN)rDrErFrWrQrRrrrrrK<srKc@s0eZdZdZdd�Zdd�Zeedd�ge_dS)	�DeprecationTestsz;
    Tests for deprecations in C{twisted.python.util}.
    cC�Tt��|j|jgd�}|�|ddd�|�|ddt�|�t|�d�dS)z6
        L{util.getPluginDirs} is deprecated.
        r�rrwzCtwisted.python.util.getPluginDirs is deprecated since Twisted 12.2.r�rN)r�
getPluginDirsrx�test_getPluginDirsrr�ry�rr{rrrrV`��
�z#DeprecationTests.test_getPluginDirscCrT)z5
        L{util.addPluginDir} is deprecated.
        r�rrwzBtwisted.python.util.addPluginDir is deprecated since Twisted 12.2.r�rN)r�addPluginDirrx�test_addPluginDirrr�ryrWrrrrZorXz"DeprecationTests.test_addPluginDirz/twisted.python.util.getPluginDirs is deprecated)r�rwN)	rDrErFrWrVrZ�SUPPRESSr�rrrrrrS[s�
�rSc@s:eZdZdZeej�Zdd�Zdd�Zdd�Z	dd	�Z
d
S)�SuppressedWarningsTestsz6
    Tests for L{util.runWithWarningsSuppressed}.
    cCsDdifdifg}|�|tjd�|�|tjd�|�g|���dS)z�
        Warnings from the function called by C{runWithWarningsSuppressed} are
        suppressed if they match the passed in filter.
        ��ignorez.*foo.*�r^z.*bar.*�
ignore fooz
ignore barN��runWithWarningsSuppressed�warnings�warnrrx�r�filtersrrr�&test_runWithWarningsSuppressedFiltered�sz>SuppressedWarningsTests.test_runWithWarningsSuppressedFilteredcCs@difdifg}|�|tjd�|�dgdd�|��D��dS)z�
        Warnings from the function called by C{runWithWarningsSuppressed} are
        not suppressed if they do not match the passed in filter.
        r]r_zdon't ignorecS�g|]}|d�qS�rwr��.0r�rrr�
<listcomp>��zTSuppressedWarningsTests.test_runWithWarningsSuppressedUnfiltered.<locals>.<listcomp>Nrarerrr�(test_runWithWarningsSuppressedUnfiltered�s z@SuppressedWarningsTests.test_runWithWarningsSuppressedUnfilteredcCs|�|�gdd��d�dS)zd
        C{runWithWarningsSuppressed} returns the result of the function it
        called.
        cSr�)Nrrrrrrr8�r�z:SuppressedWarningsTests.test_passThrough.<locals>.<lambda>rN)rrbr'rrr�test_passThrough�sz(SuppressedWarningsTests.test_passThroughcCsJdifdifg}|�|dd��t�d�|�dgdd�|��D��dS)	zk
        Once C{runWithWarningsSuppressed} has returned, it no longer
        suppresses warnings.
        r]r_cSr�r�rrrrrr8�r�z<SuppressedWarningsTests.test_noSideEffects.<locals>.<lambda>r`cSrhrirrjrrrrl�rmz>SuppressedWarningsTests.test_noSideEffects.<locals>.<listcomp>Nrarerrr�test_noSideEffects�s
 z*SuppressedWarningsTests.test_noSideEffectsN)rDrErFrW�staticmethodrrbrgrnrorprrrrr\�s

	r\c@r�)
�FancyStrMixinTestsz*
    Tests for L{util.FancyStrMixin}.
    cC�(Gdd�dtj�}|�t|��d�dS)z�
        If C{showAttributes} is set to a sequence of strings, C{__str__}
        renders using those by looking them up as attributes on the object.
        c@�eZdZdZdZdZdS)z6FancyStrMixinTests.test_sequenceOfStrings.<locals>.Foo��first�secondr�helloN�rDrErF�showAttributesrvrwrrrrrN��rNz<Foo first=1 second='hello'>N�r�
FancyStrMixinr�str�rrNrrr�test_sequenceOfStrings�sz)FancyStrMixinTests.test_sequenceOfStringscCs(Gdd�dtj�}|�dt|���dS)a
        If C{showAttributes} has an item that is a 2-tuple, C{__str__} renders
        the first item in the tuple as a key and the result of calling the
        second item with the value of the attribute named by the first item as
        the value.
        c@s$eZdZdddd�ffZdZdZdS)z.FancyStrMixinTests.test_formatter.<locals>.FoorvrwcSst|ddd��S)Nr1)r�)�valuerrrr8�sz7FancyStrMixinTests.test_formatter.<locals>.Foo.<lambda>rx�worldNryrrrrrN�srNz"<Foo first='hello' second='dlrow'>Nr|rrrr�test_formatter��z!FancyStrMixinTests.test_formattercCrs)a&
        If C{showAttributes} has an item that is a 3-tuple, C{__str__} renders
        the second item in the tuple as a key, and the contents of the
        attribute named in the first item are rendered as the value. The value
        is formatted using the third item in the tuple.
        c@rt)z-FancyStrMixinTests.test_override.<locals>.Foo)rv)rw�2ndz%.1frg��S�@NryrrrrrN�r{rNz<Foo first=1 2nd=2.1>Nr|rrrr�
test_override�r�z FancyStrMixinTests.test_overridecCrs)z_
        If C{fancybasename} is present, C{__str__} uses it instead of the class name.
        c@r)z2FancyStrMixinTests.test_fancybasename.<locals>.Foo�BarN)rDrErF�
fancybasenamerrrrrN�rrNz<Bar>Nr|rrrr�test_fancybasename�sz%FancyStrMixinTests.test_fancybasenamecCs0Gdd�dtj�}|�}|�t|�t|��dS)zE
        C{__repr__} outputs the same content as C{__str__}.
        c@rt)z)FancyStrMixinTests.test_repr.<locals>.FoorurrxNryrrrrrN�r{rNN)rr}rr~r�)rrN�objrrr�	test_repr�szFancyStrMixinTests.test_reprN)	rDrErFrWr�r�r�r�r�rrrrrr�s

rrc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�
PadToTestsz"
    Tests for L{util.padTo}.
    cCs"t�dg�}|�dgd|�dS)ze
        L{None} values can be added to a list to cause it to have a certain
        length.
        rN�r�padTor�r�paddedrrr�test_default�szPadToTests.test_defaultcCs$t�dgd�}|�dgd|�dS)zg
        A specific value can be added to a list to cause it to have a certain
        length.
        rr�Nr�r�rrr�test_specificDefaultValuesz$PadToTests.test_specificDefaultValuecCs&t�dddgd�}|�gd�|�dS)zl
        A list which already has some items has the padding value added after
        those items.
        rrrr>)rrr>Nr�r�rrr�test_padNonEmptyListszPadToTests.test_padNonEmptyListcCs|�ttjdddg�dS)z{
        L{util.padTo} can't pad a list if the size requested is smaller than
        the size of the list to pad.
        rrN)rrrr�r'rrr�test_padToSmallerSizesz PadToTests.test_padToSmallerSizecCs(ddg}t�t|�|�}|�||�dS)z�
        If the list is already the length indicated by the padding argument
        then a list with the same value is returned.
        rrN)rr�ryr�rr�r�rrr�test_alreadyPadded�zPadToTests.test_alreadyPaddedcCs(ddg}t�t|�|�}|�||�dS)z�
        If the list is already the length indicated by the padding argument
        then the return value is a copy of the input.
        rrN)rr�ry�assertIsNotr�rrr�test_alreadyPaddedCopies'r�z#PadToTests.test_alreadyPaddedCopiescCs g}t�d|�|�g|�dS)zO
        L{util.padTo} doesn't modify the input list but makes a copy.
        rNr�)rr�rrr�
test_makeCopy0szPadToTests.test_makeCopyN)rDrErFrWr�r�r�r�r�r�r�rrrrr��s		r�)GrWr]�os.pathr3r�r�rc�typingrrrr�unittestrr=�_grpr1�_pwd�ImportError�twisted.internetr�twisted.internet.deferr�twisted.internet.errorr	�twisted.internet.interfacesr
�twisted.internet.protocolr�twisted.pythonr�twisted.python.filepathr
�twisted.test.test_processr�twisted.trial.unittestrr�twisted.trial.utilrr[�
executable�_asBytesPathr�rrHrY�getattrrfr�r�r�r��
providedByr�r�r�rrrrrrrr-rNrKrSr\rrr�rrrr�<module>st�1F`P
�"M		bq+,H
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY