Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/python/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyc


=Nc@sdZddlZddlZddlZddlZyddlZddlZWnek
rodZZnXddl
mZddlm
Z
ddlmZddlmZddlmZddlmZdd	lmZdd
lmZdejfdYZd
ejfdYZdejfdYZdejfdYZdejfdYZdefdYZ dejfdYZ!dejfdYZ"dd3dYZ#dejfdYZ$dejfd YZ%d!e
j&fd"YZ'd#e
j&fd$YZ(d%e'fd&YZ)d'e*fd(YZ+d)e*fd*YZ,d+ejfd,YZ-d-ejfd.YZ.d/ejfd0YZ/d1ejfd2YZ0dS(4s#
Tests for L{twisted.python.util}.
iN(tunittest(tutil(treactor(tIReactorProcess(tProcessProtocol(tDeferred(tProcessDone(tMockOStUtilTestCasecBseZdZdZdZdZdZdZedkrTde_
ndZdZe
dkr~d	e_
nd
ZRS(cCsYdddddddddddg}|jtj|dddddddgdS(Ntaitabiiii(tassertEqualRtuniquify(tselftl((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttestUniqs'cCs||jtjttdd|jtjttddytjttddWntk
rkn
XtjddS(Niis,util.raises didn't raise when it should have(	t
failUnlessRtraisestZeroDivisionErrortdivmodtfailIft	TypeErrorRtFailTest(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt
testRaises#s
csfd}dg_d_jtj|dddjjddttg_d_jtj|dddjjddS(NcsGjd7_jj}|dk	r?|tjdn||S(NisInterrupted system call!(tcallst
exceptionstpoptNoneterrnotEINTR(R	tbtexc(R
(sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pytf/s
iiiii(RRRRRtuntilConcludestOSErrortIOError(R
R ((R
sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttestUninterruptably.s		cCs_d
ddddg}xC|D];\}}tj|}|j||d|||fqWdS(sK
        Test the various kinds of inputs L{nameToLabel} supports.
        R tFtfotFotfootFootfooBarsFoo Bart	fooBarBazsFoo Bar BazsnameToLabel(%r) == %r != %rN(R R%(R&R'(sfoosFoo(R*sFoo Bar(R+sFoo Bar Baz(RtnameToLabelR(R
tnameDatatinptouttgot((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttestNameToLabel@s	cCs|jtjdddS(s
        When L{uidFromString} is called with a base-ten string representation
        of an integer, it returns the integer.
        t100idN(RRt
uidFromString(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_uidFromNumericStringRscCs8tjtj}|jtj|j|jdS(s
        When L{uidFromString} is called with a base-ten string representation
        of an integer, it returns the integer.
        N(	tpwdtgetpwuidtostgetuidRRR3tpw_nametpw_uid(R
tpwent((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_uidFromUsernameStringZss0Username/UID conversion requires the pwd module.cCs|jtjdddS(s
        When L{gidFromString} is called with a base-ten string representation
        of an integer, it returns the integer.
        R2idN(RRt
gidFromString(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_gidFromNumericStringfscCs8tjtj}|jtj|j|jdS(s
        When L{gidFromString} is called with a base-ten string representation
        of an integer, it returns the integer.
        N(	tgrptgetgrgidR7tgetgidRRR=tgr_nametgr_gid(R
tgrent((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_gidFromGroupnameStringnss2Group Name/GID conversion requires the grp module.cCs~tjdddddi|jd|jg}|j|ddd	|j|dd
t|jt|ddS(
sR
        Calling L{moduleMovedForSplit} results in a deprecation warning.
        R(tbartbaztquuxtcorgetoffendingFunctionsitmessages4moduleMovedForSplit is deprecated since Twisted 9.0.tcategoryiN(RtmoduleMovedForSplitt
flushWarningst#test_moduleMovedForSplitDeprecationRtDeprecationWarningtlen(R
twarnings((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyROzs	N(t__name__t
__module__RRR$R1R4R<R5RtskipR>RER?RO(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRs								t
SwitchUIDTestcBseeZdZeedd	d	kr-dZndZdZdZ	dZ
dZdZRS(
s&
    Tests for L{util.switchUID}.
    R8sgetuid/setuid not availablecCsEt|_|jtd|j|jtd|jg|_dS(NR7t
initgroups(RtmockostpatchRRWtinitgroupsCalls(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pytsetUpscCs|jj||fdS(sK
        Save L{util.initgroups} calls in C{self.initgroupsCalls}.
        N(RZtappend(R
tuidtgid((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRWscCsCtjdd|j|jdg|j|jjdgdS(sn
        L{util.switchUID} calls L{util.initgroups} and then C{os.setuid} with
        the given uid.
        i.tsetuidN(i.N(ssetuidi.(Rt	switchUIDRRRZRXtactions(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_uidscCsFtjddt|j|jdg|j|jjdgdS(s
        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}.
        i.N(i.N(RR`RtTrueRRZRXtseteuidCalls(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt	test_euidscCs|jj}tj|d|j|jg|j|jjg|jtjg}|jt	|d|j
d||dd|j
d||dddS(s
        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.
        is&tried to drop privileges and setuid %iiRKsbut uid is already %iN(RXR8RR`RRRZRaRNRQtassertIn(R
R]RR((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_currentUIDs
cCs|jj}tj|dt|j|jg|j|jjg|j	tjg}|jt
|d|jd||dd|jd||dddS(s
        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.
        is'tried to drop privileges and seteuid %iiRKsbut euid is already %iN(RXtgeteuidRR`RRcRRZRdRNRQRf(R
teuidRR((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_currentEUIDs
N(
RSRTt__doc__tgetattrR7RRUR[RWRbReRgRj(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRVs				
	
	tTestMergeFunctionMetadatacBs;eZdZdZdZdZdZdZRS(s-
    Tests for L{mergeFunctionMetadata}.
    cskttfd}dfd}tj||}|j|ddd
ddd	S(st
        After merging C{foo}'s data into C{bar}, the returned function behaves
        as if it is C{bar}.
        csS(N(((t
foo_object(sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR(si
cs|\}}S(N((txtyt.2tctdteR	R(t
bar_object(sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRFs	iiiiRHN(ii(tobjectRtmergeFunctionMetadatatassertIdentical(R
R(RFRG((RuRnsA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt)test_mergedFunctionBehavesLikeMergeTargets		cCsGd}d}d|_tj||}|j|j|jdS(sd
        Merging C{foo} into C{bar} returns a function with C{foo}'s
        C{__module__}.
        cSsdS(N((((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR(scSsdS(N((((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRFsssomewhere.elseN(RTRRwR(R
R(RFRG((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_moduleIsMergeds
			cCs>d}d}tj||}|j|j|jdS(sX
        Merging C{foo} into C{bar} returns a function with C{foo}'s docstring.
        cSsdS(s&
            This is foo.
            N((((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR(scSsdS(s&
            This is bar.
            N((((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRFsN(RRwRRk(R
R(RFRG((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_docstringIsMergeds		cCs>d}d}tj||}|j|j|jdS(sS
        Merging C{foo} into C{bar} returns a function with C{foo}'s name.
        cSsdS(N((((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR(scSsdS(N((((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRFsN(RRwRRS(R
R(RFRG((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_nameIsMergeds		cCsd}d|_d|_d}d|_d|_tj||}|j|j|j|j|j|j|j|j|jdS(sv
        Merging C{foo} into C{bar} returns a function with C{bar}'s
        dictionary, updated by C{foo}'s.
        cSsdS(N((((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR($siicSsdS(N((((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRF)siiN(R	RRrRRwR(R
R(RFRG((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_instanceDictionaryIsMergeds						(RSRTRkRyRzR{R|R}(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRms				tOrderedDictTestcBseZdZdZRS(cCstj}d|d<d|d<d|d<d|d<|jt|d|j|jddddg|d=|jt|d|j|idd6dd6dd6|j|jdddg|jt|jd	d
dg|j}|j|ddS(
NRR	iiiis'{'a': 'b', 'b': 'a', 3: 12, 1234: 4321}s {'a': 'b', 'b': 'a', 1234: 4321}(R	R(RR	(ii(ii(	RtOrderedDictRtreprtvaluestkeystlistt	iteritemstpopitem(R
Rstitem((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttestOrderedDict6s



"%cCsbtjidd6dd6}|j|jtjd
ddd
f}|jt|d	dS(Ntooktmonkeytredtappleiiiis{1: 1, 3: 3, 2: 2, 0: 0}(ii(ii(ii(ii(RRRt_orderRR(R
Rs((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttestInitializationGs

(RSRTRR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR~5s	tInsensitiveDictTestcBseZdZdZRS(cCs[tj}|idd6dd6idd6d6dd}|j|didd6|j|dd|j|j||j|d|jdd|krd|kst|jtt||dddg}xH|D]@}||jkst|||f|j	kstqW|jt
|t
||d=|d=dS(NRFR)iitfnztpreserveR((RtInsensitiveDictRtcopytgettAssertionErrortevalRRtitemsRQ(R
RtdctRRo((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttestPreservePs	.
&cCstj}|idd6dd6idd6d6dd}dddg}xH|D]@}||jkskt|||f|jksMtqMW|jt|t||d=|d=dS(	NRFR)iiRRiR((RRRRRRRQ(R
RRRRo((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttestNoPreserveas	.
&(RSRTRR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyROs	tPasswordTestingProcessProtocolcBs)eZdZdZdZdZRS(s
    Write the string C{"secret
"} to a subprocess and then collect all of
    its output and fire a Deferred with it when the process ends.
    cCsg|_|jjddS(Nssecret
(toutputt	transporttwrite(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pytconnectionMadets	cCs|jj||fdS(N(RR\(R
tfdR((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pytchildDataReceivedxscCs|jj||jfdS(N(tfinishedtcallbackR(R
treason((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pytprocessEnded{s(RSRTRkRRR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRos		tGetPasswordTestcBs)eZejesdZndZRS(s,Process support required to test getPasswordcsrt}t|_tj|tjtjddgditjj	tj
d6fd}|jj|S(s.
        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()
tenvt
PYTHONPATHcs-|\}}|jtjd|dS(Nitsecret(iR(ttrapRRf(t.0RR(R
(sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pytprocessFinisheds	
(RRRRtspawnProcesstsyst
executableR7tpathseptjointpathtaddCallback(R
tpR((R
sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt
test_stdins		(RSRTRt
providedByRRUR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRs	tSearchUpwardsTestcBseZdZRS(cCstjdtddjtddjtddjtjdtjdtjdtjd	tjdd
dgdd
dg}tjjdtj	}|j
||tjdtjdd
dgdd
dg}d}|j
||dS(Nssearchupwards/a/b/cssearchupwards/foo.txttwssearchupwards/a/foo.txtssearchupwards/a/b/c/foo.txtssearchupwards/barssearchupwards/bamssearchupwards/a/barssearchupwards/a/b/bamtfilessfoo.txttdirsRFtbamt
searchupwards(R7tmakedirstfiletclosetmkdirRRRtabspathtsepRtshutiltrmtreeR(R
tactualtexpected((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttestSearchupwardss&




	
	(RSRTR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRsR)cBseZdZRS(cCs
||_dS(N(Ro(R
Ro((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt__init__s(RSRTR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR)stDSUcBs eZdZdZdZRS(s
    Tests for L{util.dsu}
    cCssgtdddD]}t|^q}tj|d}|jtddg|D]}|j^qYdS(Nii	icSs|jS(N(Ro(to((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt<lambda>si
i(trangeR)RtdsuRRo(R
RotLtL2R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_dsus+cCs|jtdtddS(NsHdsu is deprecated since Twisted 10.1. Use the built-in sorted() instead.cSstjgdS(NcSsdS(Ni((((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRs(RR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRs(tassertWarnsRPt__file__(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_deprecations	(RSRTRkRR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRs	tIntervalDifferentialTestCasecBs>eZdZdZdZdZdZdZRS(cCsIttjgd}x*tdD]}|j|jdq%WdS(Ni
id(i
N(titerRtIntervalDifferentialRRtnextR(R
Rsti((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttestDefaultscCsLttjdgd}x*tdD]}|j|jdq(WdS(Nii
idi(ii(RRRRRR(R
RsR((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt
testSinglescCsAttjddgd}xtdD]}|j|jd
|j|jd|j|jd|j|jd
|j|jd|j|jd|j|jd|j|jd|j|jd|j|jd|j|jd|j|jdq+WdS(Niii
idiiiii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(RRRRRR(R
RsR((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttestPairscCsttjdddgd}xtdD]}|j|jd|j|jd	|j|jd
|j|jd|j|jd|j|jd
|j|jd|j|jd|j|jd|j|jd|j|jd|j|jd|j|jd|j|jd|j|jd|j|jd|j|jd|j|jd|j|jdq.WdS(Niiii
idii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(ii(RRRRRR(R
RsR((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt
testTriples*!cCsttjgd}|j|jd|jd|j|jd|j|jd|jd|j|jd	|j|jd
|j|jd|j|jd|j|jd
|j|jddS(Ni
iiii(i
N(ii(ii(ii(ii(ii(ii(ii(ii(RRRRRRtaddInterval(R
Rs((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt
testInserts

cCsttjddgd}|j|jd|j|jd	|j|jd
|jd|j|jd|j|jd|jd|j|jd
|jt|jddS(Niii
iiii(ii(ii(ii(ii(ii(i
N(	RRRRRtremoveIntervalRtassertRaisest
ValueError(R
Rs((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt
testRemoves

(RSRTRRRRRR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRs					tRecordcBseZdZdZdZRS(s8
    Trivial user of L{FancyEqMixin} used by tests.
    R	RcCs||_||_dS(N(R	R(R
R	R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRs	(R	R(RSRTRktcompareAttributesR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRstDifferentRecordcBseZdZdZdZRS(sL
    Trivial user of L{FancyEqMixin} which is not related to L{Record}.
    R	RcCs||_||_dS(N(R	R(R
R	R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR+s	(R	R(RSRTRkRR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR%st
DerivedRecordcBseZdZRS(s@
    A class with an inheritance relationship to L{Record}.
    (RSRTRk(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR1stEqualToEverythingcBs eZdZdZdZRS(sQ
    A class the instances of which consider themselves equal to everything.
    cCstS(N(Rc(R
tother((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt__eq__<scCstS(N(tFalse(R
R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt__ne__@s(RSRTRkRR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR8s	tEqualToNothingcBs eZdZdZdZRS(sN
    A class the instances of which consider themselves equal to nothing.
    cCstS(N(R(R
R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRIscCstS(N(Rc(R
R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRMs(RSRTRkRR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyREs	t
EqualityTestscBs_eZdZdZdZdZdZdZdZdZ	dZ
d	ZRS(
s$
    Tests for L{FancyEqMixin}.
    cCs~dtjfdY}|j||k|j||k|}|j||k|j||kdS(s
        Instances of a class which mixes in L{FancyEqMixin} but which
        defines no comparison attributes compare by identity.
        tEmptycBseZRS((RSRT(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR[sN(RtFancyEqMixintassertFalset
assertTrue(R
Rtempty((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt
test_identityVs	cCs|jtddtddk|jtddtddk|jtddtddk|jtddtddkdS(s
        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.
        iiiiN(RRR(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt
test_equalityes%%%cCs|jtddtddk|jtddtddk|jtddtddk|jtddtddkdS(s
        Unequality between instances of a particular L{record} should be
        defined as the negation of equality.
        iiiiN(RRR(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_unequalityqs%%%cCs)|jtddtddkdS(so
        Instances of different classes which mix in L{FancyEqMixin} should not
        compare equal.
        iiN(RRR(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_differentClassesEquality|scCs)|jtddtddkdS(sm
        Instances of different classes which mix in L{FancyEqMixin} should
        compare unequal.
        iiN(RRR(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_differentClassesInequalityscCs|jtddtddk|jtddtddk|jtddtddk|jtddtddkdS(s
        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.
        iiiiN(RRRR(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_inheritedClassesEqualitys%%%cCs|jtddtddk|jtddtddk|jtddtddk|jtddtddkdS(s
        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.
        iiiiN(RRRR(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_inheritedClassesInequalitys%%%cCsB|jtddtk|jtddtkdS(s
        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.
        iiN(RRRRR(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt(test_rightHandArgumentImplementsEqualityscCsB|jtddtk|jtddtkdS(s
        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.
        iiN(RRRRR(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt*test_rightHandArgumentImplementsUnequalitys(RSRTRkRRRRRRRRR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRRs								tRunAsEffectiveUserTestscBseZdZeedd
d
kr-dZndZdZdZ	dZ
dZdZd	Z
d
ZdZdZRS(s;
    Test for the L{util.runAsEffectiveUser} function.
    Rhsgeteuid/seteuid not availablecCstt|_|jtd|jj|jtd|jj|jtd|jj|jtd|jjdS(NRhtgetegidtseteuidtsetegid(RRXRYR7RhRRR(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR[s
cCsV|j||kp%||jjdk|j||kpN||jjdkdS(sF
        Check if wanted UID/GID matched start or saved ones.
        iN(RRXRdtsetegidCalls(R
tstartUIDtstartGIDtwantUIDtwantGID((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt_securedFunctionscCs,tjddd}|j|ddS(so
        L{util.runAsEffectiveUser} forwards the result obtained by calling the
        given function
        icSsdS(Ni((((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRsiN(RtrunAsEffectiveUserR(R
tresult((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_forwardResultscCs/tjdddd}|j|ddS(se
        L{util.runAsEffectiveUser} pass the given parameters to the given
        function.
        icSsd|S(Ni((Ro((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRsiiN(RRR(R
R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_takeParametersscCs;tjdddddddd}|j|ddS(	sg
        L{util.runAsEffectiveUser} pass the keyword parameters to the given
        function.
        iicSs|||S(N((RoRptz((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRsiR	iiN(RRR(R
R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_takesKeyworkArgumentss'cCs||j_||j_tj|||j|||||j|jj||j|jj|g|j_g|j_dS(s
        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(	RXRitegidRRRRRdR(R
RRRRtexpectedUIDSwitchestexpectedGIDSwitches((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt_testUIDGIDSwitchscCs|jddddgg|jddddddgg|jddddgddg|jddddddgddgdS(sL
        Check UID/GID switches when current effective UID is root.
        iiN(R(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt	test_roots""c	Cs|jddddddgg|jddddgg|jddddddddgddg|jddddddddgddgdS(sP
        Check UID/GID switches when current effective UID is non-root.
        iiiN(R(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_UIDs".cCs|jddddgddg|jddddgg|jddddddgg|jddddddgddgdS(sP
        Check UID/GID switches when current effective GID is non-root.
        iiiN(R(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_GIDs""c	Cs|jddddddgddg|jddddddgg|jddddddddgddg|jddddgg|jddddddddgg|jddddddddgddg|jddddddddgddgdS(sT
        Check UID/GID switches when current effective UID/GID is non-root.
        iiiN(R(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_UIDGID s(".(.N(RSRTRkRlR7RRUR[RRRR
RRRRR(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRs			
								
	
	
tUnsignedIDTestscBs2eZdZdZdZdZdZRS(sA
    Tests for L{util.unsignedID} and L{util.setIDFunction}.
    cCs|jttdtjdS(sv
        Save the value of L{util._idFunction} and arrange for it to be restored
        after the test runs.
        t_idFunctionN(t
addCleanuptsetattrRR(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR[2scCs;t}tj|}tj|}|j||dS(sL
        L{util.setIDFunction} returns the last value passed to it.
        N(RvRt
setIDFunctionRx(R
tvaluetpreviousR((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_setIDFunction:s	cst}t}id|6d|6fd}tj||jtj|d|jtj|tjddddS(s
        L{util.unsignedID} uses the function passed to L{util.setIDFunction} to
        determine the unique integer id of an object and then adjusts it to be
        positive if necessary.
        iics|S(N((tobj(tobjects(sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pytfakeIdOsiiiIN(RvRRRt
unsignedIDRtmaxint(R
R(RFR((RsA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_unsignedIDDs		
cCsVt}t|}|dkr9|tjdd7}n|jtj||dS(sH
        L{util.unsignedID} uses the built in L{id} by default.
        iiiN(RvtidRRRRR(R
RtidValue((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_defaultIDFunctionXs
	(RSRTRkR[RR R#(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR.s
		
	tInitGroupsTestscBsbeZdZedkr!dZndZdZdZdZ	e
jdkr`de	_nRS(s'
    Tests for L{util.initgroups}.
    spwd not availablecCs6|jttdtj|jttdtjdS(Nt
_c_initgroupst	setgroups(RRRR%R&(R
((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR[nscs}gfdt_g}jt_tjtjd|jtj	tjddfg|j
|dS(sw
        If we fake the presence of the C extension, it's called instead of the
        Python implementation.
        csj||fS(N(R\(RoRp(R(sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyRysiiN(RR%R\R&RWR7R8RR5R6R(R
tsetgroupsCalls((RsA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_initgroupsForceCss,cCsHdt_g}|jt_tjtjtj|j	|dS(s
        If we fake the absence of the C extension, the Python implementation is
        called instead, calling C{os.setgroups}.
        N(
RRR%R\R&RWR7R8RAR(R
R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_initgroupsForcePythons
	cCsWg}|jt_y tjtjtjWntk
rEnX|j|dS(s
        If the C extension is present, it's called instead of the Python
        version.  We check that by making sure C{os.setgroups} is not called.
        N(	R\RR&RWR7R8RAR"R(R
R((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyttest_initgroupsInCs 
sC initgroups not availableN(RSRTRkR5RRUR[R(R)R*RR%(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyR$es				
	((1Rktos.pathR7RRRR5R?tImportErrorRt
twisted.trialRttwisted.pythonRttwisted.internetRttwisted.internet.interfacesRttwisted.internet.protocolRttwisted.internet.deferRttwisted.internet.errorRttwisted.test.test_processRtTestCaseRRVRmR~RRRRR)RRRRRRRvRRRRRR$(((sA/usr/lib/python2.7/dist-packages/twisted/python/test/test_util.pyt<module>sD
lL`  N

is7