ϪfH$dZddlZddlZddlZddlZddlZddlmZm Z m Z m Z ddl m Z  ddlZddlZeZeZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lm Z dd l!m"Z"dd l#m$Z$m%Z%ddl&m'Z(e ejRjUZ+Gdde%Z,Gdde%Z-Gdde%Z.e e/edd dGdde%Z0Gdde%Z1Gdde%Z2Gdde%Z3Gdd eZ4e ejje d!Gd"d#e%Z6Gd$d%e%Z7Gd&d'e%Z8Gd(d)ejrZ:Gd*d+ejrZ;Gd,d-e:Z<Gd.d/Z=Gd0d1Z>Gd2d3e%Z?e e/ed4d d5Gd6d7e%Z@e ej d8Gd9d:e%ZBGd;de%ZDGd?d@e%ZEGdAdBe%ZFy#e$rdZdZYwxYw)Cz# Tests for L{twisted.python.util}. N)IterableMappingMutableMappingSequence)skipIf)reactor)Deferred) ProcessDone)IReactorProcess)ProcessProtocol)util)FilePath)MockOS)FailTestTestCase)suppresscheZdZdZdZdZeeduddZdZ ee dudd Z y) UtilTestscZgd}|jtj|gdy)N) aabrrrr)rrrrrrr) assertEqualr uniquify)self listWithDupess ?/usr/lib/python3/dist-packages/twisted/python/test/test_util.pytestUniqzUtilTests.testUniq+s!@  }57QRc4|jtjttdd|j tjttdd tjt tddtd#t$rYywxYw)Nrrz,util.raises didn't raise when it should have) assertTruer raisesZeroDivisionErrordivmod assertFalse TypeErrorrrs r! testRaiseszUtilTests.testRaises/sv  $5vq!DE %61EF K KK 61a 0IJ J!   s B BBcN|jtjddy) When L{uidFromString} is called with a base-ten string representation of an integer, it returns the integer. 100dN)rr uidFromStringr+s r!test_uidFromNumericStringz#UtilTests.test_uidFromNumericString: ++E2C8r#Nz0Username/UID conversion requires the pwd module.ctjtj}|j t j |j|jy)r.N) pwdgetpwuidosgetuidrr r1pw_namepw_uid)rpwents r!test_uidFromUsernameStringz$UtilTests.test_uidFromUsernameStringA;  RYY[) ++EMM:ELLIr#cN|jtjddy) When L{gidFromString} is called with a base-ten string representation of an integer, it returns the integer. r/r0N)rr gidFromStringr+s r!test_gidFromNumericStringz#UtilTests.test_gidFromNumericStringJr3r#z2Group Name/GID conversion requires the grp module.ctjtj}|j t j |j|jy)r?N) grpgetgrgidr7getgidrr r@gr_namegr_gid)rgrents r!test_gidFromGroupnameStringz%UtilTests.test_gidFromGroupnameStringQr=r#) __name__ __module__ __qualname__r"r,r2rr5r<rArCrIr#r!rr*s^S K9 C4KKLJMJ9 C4KMNJOJr#rceZdZdZdZy)NameToLabelTestsz# Tests for L{nameToLabel}. c gd}|D]6\}}tj|}|j||d|d|d|8y)zK Test the various kinds of inputs L{nameToLabel} supports. ))fF)foFo)fooFoo)fooBarzFoo Bar) fooBarBazz Foo Bar Bazz nameToLabel(z) == z != N)r nameToLabelr)rnameDatainpoutgots r!test_nameToLabelz!NameToLabelTests.test_nameToLabel`sU ! VHC""3'C   S#cWE#SG'T U Vr#N)rJrKrL__doc__r^rMr#r!rOrO[s  Vr#rOceZdZdZdZy)UntilConcludesTestsz: Tests for L{untilConcludes}, an C{EINTR} helper. clfd}dg_d_jtj|dddjjddt t g_d_jtj|dddjjdy)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. cxjdz c_jj}||tjd||zS)NrzInterrupted system call!)calls exceptionspoperrnoEINTR)rbexcrs r!rQz3UntilConcludesTests.test_uninterruptably..f}sB JJ!OJ//%%'C%++'ABBq5Lr#Nrrrr)rerdrr untilConcludesOSErrorIOError)rrQs` r!test_uninterruptablyz(UntilConcludesTests.test_uninterruptablyus  &  ,,Q15q9 Q''2  ,,Q15q9 Q'r#N)rJrKrLr_rorMr#r!raraps (r#rar8zgetuid/setuid not availablec4eZdZdZdZdZdZdZdZdZ y) SwitchUIDTestsz& Tests for L{util.switchUID}. ct|_|jtd|j|jtd|jg|_y)Nr7 initgroups)rmockospatchr rsinitgroupsCallsr+s r!setUpzSwitchUIDTests.setUps;h  4t{{+ 4t7!r#c>|jj||fy)zK Save L{util.initgroups} calls in C{self.initgroupsCalls}. N)rvappend)ruidgids r!rszSwitchUIDTests.initgroupss ##S#J/r#ctjdd|j|jdg|j|jj dgy)zn L{util.switchUID} calls L{util.initgroups} and then C{os.setuid} with the given uid. .Nr}N)setuidr})r switchUIDrrvrtactionsr+s r!test_uidzSwitchUIDTests.test_uidsH ud# -- ? ,,/@.ABr#ctjddd|j|jdg|j|jj dgy)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}. r}NTr~)r rrrvrt seteuidCallsr+s r! test_euidzSwitchUIDTests.test_euidsH udD) -- ? 11E7;r#c|jj}tj|d|j |j g|j |jj g|jtjg}|j t|d|jd|z|dd|jd|z|ddy)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 %irmessagezbut uid is already %i) rtr8r rrrvr flushWarningslenassertIn)rrzcurrentWarningss r!test_currentUIDzSwitchUIDTests.test_currentUIDs kk  " sD! --r2 ,,b1,,dnn-=> _-q1 4s : A y )  -3_Q5G 5RSr#c|jj}tj|dd|j |j g|j |jj g|jtjg}|j t|d|jd|z|dd|jd|z|ddy)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 %irrzbut euid is already %i) rtgeteuidr rrrvrrrr)reuidrs r!test_currentEUIDzSwitchUIDTests.test_currentEUIDs {{""$ tT4( --r2 1126,,dnn-=> _-q1 5 < A y )  .5q7I)7TUr#N) rJrKrLr_rwrsrrrrrMr#r!rqrqs(" 0 C<T"Vr#rqc.eZdZdZdZdZdZdZdZy)MergeFunctionMetadataTestsz- Tests for L{mergeFunctionMetadata}. cttfd}d fd }tj||}|j|ddddy) zt After merging C{foo}'s data into C{bar}, the returned function behaves as if it is C{bar}. cSNrM) foo_objectsr!rUzQMergeFunctionMetadataTests.test_mergedFunctionBehavesLikeMergeTarget..foos  r# c|\}}SrrM) xyrcderri bar_objects r!barzQMergeFunctionMetadataTests.test_mergedFunctionBehavesLikeMergeTarget..barsFQ r#rr)rr)quuxN)r)objectr mergeFunctionMetadataassertIs)rrUrbazrrs @@r!)test_mergedFunctionBehavesLikeMergeTargetzDMergeFunctionMetadataTests.test_mergedFunctionBehavesLikeMergeTargetsJ X X   ((c2 c!QR0*=r#cd}d}d|_tj||}|j|j|jy)zd Merging C{foo} into C{bar} returns a function with C{foo}'s C{__module__}. cyrrMrMr#r!rUz;MergeFunctionMetadataTests.test_moduleIsMerged..foo r#cyrrMrMr#r!rz;MergeFunctionMetadataTests.test_moduleIsMerged..barrr#zsomewhere.elseN)rKr rrrrUrrs r!test_moduleIsMergedz.MergeFunctionMetadataTests.test_moduleIsMergeds?   *((c2 8r#cd}d}tj||}|j|j|jy)zX Merging C{foo} into C{bar} returns a function with C{foo}'s docstring. cy)z& This is foo. NrMrMr#r!rUz>MergeFunctionMetadataTests.test_docstringIsMerged..foor#cy)z& This is bar. NrMrMr#r!rz>MergeFunctionMetadataTests.test_docstringIsMerged..barrr#N)r rrr_rs r!test_docstringIsMergedz1MergeFunctionMetadataTests.test_docstringIsMergeds8     ((c2 ckk2r#cd}d}tj||}|j|j|jy)zS Merging C{foo} into C{bar} returns a function with C{foo}'s name. cyrrMrMr#r!rUz9MergeFunctionMetadataTests.test_nameIsMerged..foorr#cyrrMrMr#r!rz9MergeFunctionMetadataTests.test_nameIsMerged..barrr#N)r rrrJrs r!test_nameIsMergedz,MergeFunctionMetadataTests.test_nameIsMergeds8   ((c2 s||4r#cXd}d|_d|_d}d|_d|_tj||}|j |j|j|j |j|j|j |j|jy)zv Merging C{foo} into C{bar} returns a function with C{bar}'s dictionary, updated by C{foo}'s. cyrrMrMr#r!rUzGMergeFunctionMetadataTests.test_instanceDictionaryIsMerged..foo$rr#rrcyrrMrMr#r!rzGMergeFunctionMetadataTests.test_instanceDictionaryIsMerged..bar*rr#rrN)rrirr rrrs r!test_instanceDictionaryIsMergedz:MergeFunctionMetadataTests.test_instanceDictionaryIsMergeds   ((c2 & & &r#N) rJrKrLr_rrrrrrMr#r!rrs >$9"3$ 5'r#rceZdZdZdZy)OrderedDictTestsz( Tests for L{util.OrderedDict}. cddlm}||j|jg}|j |ddd|j |ddt |j t |dy) z4 L{util.OrderedDict} is deprecated. r) OrderedDictoffendingFunctionsrzftwisted.python.util.OrderedDict was deprecated in Twisted 15.5.0: Use collections.OrderedDict instead.categoryrN)twisted.python.utilrrtest_deprecatedrDeprecationWarningr)rrrs r!rz OrderedDictTests.test_deprecated;sx 4,,AUAU@V,W  A y ) ; +J79KL _-q1r#N)rJrKrLr_rrMr#r!rr6s 2r#rc.eZdZdZdZdZdZdZdZy)InsensitiveDictTestsz, Tests for L{util.InsensitiveDict}. c$tj}|jt|t|jt|t |jt|t |jt|ty)zN L{util.InsensitiveDict} implements L{typing.MutableMapping}. N) r InsensitiveDictr% isinstancerrrr)r)rdcts r!test_abczInsensitiveDictTests.test_abcRs`""$  312  301  378 C23r#c tjddddidd}|j|dddi|j|dd|j|j||j|d|j d|j d||j d|t t||tjd }|j||gd }|D]G}|j ||j|j |||f|jI|jt|t||d=|d=|j|jdgy ) zr L{util.InsensitiveDict} preserves the case of keys if constructed with C{preserve=True}. rrrrVrfnzpreserverrUrV)rr)rVrrN) r rrcopygetrevalreprkeysitemsr)rrresultrrs r! test_preservez"InsensitiveDictTests.test_preserve\sT ""5Q1v#FQRS UaV, UU+ S) USWWU^4 a eS! I#'#7#7   %  4A MM!SXXZ ( MM1c!f+syy{ 3 4 TCH- F J eW-r#cttjddddidd}gd}|D]G}|j||j|j|||f|j I|j t |t ||d=|d=|j |jd gy ) z| L{util.InsensitiveDict} does not preserves the case of keys if constructed with C{preserve=False}. rrrrrr)rUrrrUrN)r rrrrrr)rrrrs r!test_noPreservez$InsensitiveDictTests.test_noPreserve{s ""5Q1v#FQRS  4A MM!SXXZ ( MM1c!f+syy{ 3 4 TCH- F J eW-r#ctjd}d|d<|j|dd|j|jdgy)z4 Unicode keys are case insensitive. FrrrVFOOrUNr rrrrrs r! test_unicodez!InsensitiveDictTests.test_unicodesI  % 0% 51% E7+r#ctjd}d|d<|j|dd|j|jdgy)z2 Bytes keys are case insensitive. FrrsFoosFOOsfooNrrs r! test_byteszInsensitiveDictTests.test_bytessI  % 0&  6A& F8,r#N) rJrKrLr_rrrrrrMr#r!rrMs 4.> .,-r#rc"eZdZdZdZdZdZy)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. cHg|_|jjdy)Nssecret )output transportwriter+s r!connectionMadez-PasswordTestingProcessProtocol.connectionMades  [)r#c>|jj||fyr)rry)rfdrs r!childDataReceivedz0PasswordTestingProcessProtocol.childDataReceiveds B<(r#cR|jj||jfyr)finishedcallbackr)rreasons r! processEndedz+PasswordTestingProcessProtocol.processEndeds  45r#N)rJrKrLr_rrrrMr#r!rrs *)6r#rz,Process support required to test getPasswordceZdZdZy)GetPasswordTestsc 6t}t|_tj|t t ddgdt jjtjjdifd}|jj|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 PYTHONPATHutf8)envc^|\}}|jtjd|y)N)rssecret)trapr r)rrrrs r!processFinishedz4GetPasswordTests.test_stdin..processFinisheds'% VV KK $ MM.& 1r#) rr rr spawnProcesspyExer7pathsepjoinsyspathencode addCallback)rprs` r! test_stdinzGetPasswordTests.test_stdins| + ,Z  ,   9 @ @ HI  2 zz%%o66r#N)rJrKrLrrMr#r!rrs 7r#rceZdZdZy)SearchUpwardsTestsctjdtddjtddjtddjtjdtjdtjdtjd t j dd gd d g }tjjdtjz}|j||tjdt j dd gd d g }d}|j||y)Nzsearchupwards/a/b/czsearchupwards/foo.txtwzsearchupwards/a/foo.txtzsearchupwards/a/b/c/foo.txtzsearchupwards/barzsearchupwards/bamzsearchupwards/a/barzsearchupwards/a/b/bamzfoo.txtrbam)filesdirs searchupwards) r7makedirsopenclosemkdirr rrabspathseprshutilrmtree)ractualexpecteds r!testSearchupwardsz$SearchUpwardsTests.testSearchupwardss  )* $c*002 &,224 *C0668 $% $% &' ()## !)E5> 77???3bff< * o&## !)E5>  *r#N)rJrKrLrrMr#r!rrs+r#rc0eZdZdZdZdZdZdZdZy)IntervalDifferentialTestscttjgd}tdD]}|j t |dy)Nrr0rNiterr IntervalDifferentialrangernextrris r! testDefaultz%IntervalDifferentialTests.testDefaults@ **2r2 3s 2A   T!Wj 1 2r#cttjdgd}tdD]}|j t |dy)Nrkrr0rkrrrs r! testSinglez$IntervalDifferentialTests.testSinglesB **A33 4s .A   T!Wf - .r#cttjddgd}tdD]G}|j t |d|j t |d|j t |d|j t |d|j t |d |j t |d|j t |d |j t |d |j t |d |j t |d |j t |d|j t |dJy)Nrkrr0r!rrrr)rrrrrrrr)rrrrrrrrs r!testPairz"IntervalDifferentialTests.testPairs  **Aq626 7s .A   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf - .r#clttjgdd}tdD]}|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |d|j t |dy) N)rrrkrr0r*r+)rrr')rrrrs r! testTriplez$IntervalDifferentialTests.testTriples **9b9 :s .A   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -   T!Wf -' .r#clttjgd}|jt |d|j d|jt |d|jt |d|j d|jt |d|jt |d|jt |d|jt |d|jt |d|jt |dy)Nrrrr&rr+)rr rrr addIntervalrs r! testInsertz$IntervalDifferentialTests.testInserts **2r2 3 a*- a a&) a&) a a&) a&) a&) a&) a&) a&)r#cttjddgd}|jt |d|jt |d|jt |d|j d|jt |d|jt |d|j d|jt |d |j t|j dy) Nrrkrr&r%r'r)r!r)rr rrrremoveInterval assertRaises ValueErrorrs r! testRemovez$IntervalDifferentialTests.testRemove+s **Aq626 7 a&) a&) a&)  a&) a&)  a*- *a&6&6;r#N) rJrKrLrr"r,r.r1r6rMr#r!rrs 2 . . .. * rMr#r!rBrBDr@r#rBceZdZdZy) DerivedRecordz@ A class with an inheritance relationship to L{Record}. N)rJrKrLr_rMr#r!rErEPsr#rEc eZdZdZdedefdZy)EqualToEverythingzQ A class the instances of which consider themselves equal to everything. otherreturncy)NTrMrrHs r!__eq__zEqualToEverything.__eq__[sr#NrJrKrLr_rboolrLrMr#r!rGrGVsFtr#rGc eZdZdZdedefdZy)EqualToNothingzN A class the instances of which consider themselves equal to nothing. rHrIcy)NFrMrKs r!rLzEqualToNothing.__eq__dsr#NrMrMr#r!rPrP_sFtr#rPcFeZdZdZdZdZdZdZdZdZ dZ d Z d Z y ) EqualityTestsz$ Tests for L{FancyEqMixin}. c Gddtj}|j||k(|j||k7|}|j||k(|j||k7y)z Instances of a class which mixes in L{FancyEqMixin} but which defines no comparison attributes compare by identity. c eZdZy)*EqualityTests.test_identity..EmptyN)rJrKrLrMr#r!EmptyrVss r#rWN)r FancyEqMixinr)r%)rrWemptys r! test_identityzEqualityTests.test_identitymsk  D%%  EG+, 57*+ ' %(r#cD|jtddtddk(|jtddtddk(|jtddtddk(|jtddtddk(y)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%r8r)r+s r! test_equalityzEqualityTests.test_equality|s~ q! q! 45 1156 1156 1156r#cD|jtddtddk7|jtddtddk7|jtddtddk7|jtddtddk7y)z Inequality between instances of a particular L{record} should be defined as the negation of equality. rrrrN)r)r8r%r+s r!test_unequalityzEqualityTests.test_unequalitysz 1156 q! q! 45 q! q! 45 q! q! 45r#cT|jtddtddk(y)zo Instances of different classes which mix in L{FancyEqMixin} should not compare equal. rrN)r)r8rBr+s r!test_differentClassesEqualityz+EqualityTests.test_differentClassesEqualitys$ 1A)>>?r#cT|jtddtddk7y)zm Instances of different classes which mix in L{FancyEqMixin} should compare unequal. rrN)r%r8rBr+s r!test_differentClassesInequalityz-EqualityTests.test_differentClassesInequalitys" q! 1(==>r#cD|jtddtddk(|jtddtddk(|jtddtddk(|jtddtddk(y)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%r8rEr)r+s r!test_inheritedClassesEqualityz+EqualityTests.test_inheritedClassesEqualitys q! a(;;< 1q!)<<= 1q!)<<= 1q!)<<=r#cD|jtddtddk7|jtddtddk7|jtddtddk7|jtddtddk7y)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)r8rEr%r+s r!test_inheritedClassesInequalityz-EqualityTests.test_inheritedClassesInequalitys~ 1q!)<<= q! a(;;< q! a(;;< q! a(;; =;:r#rSrzgeteuid/seteuid not availablecLeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z y ) RunAsEffectiveUserTestsz; Test for the L{util.runAsEffectiveUser} function. czt|_|jtd|jj|jtd|jj |jtd|jj |jtd|jjy)Nrgetegidseteuidsetegid)rrtrur7rrnrorpr+s r!rwzRunAsEffectiveUserTests.setUpssh  2y$++"5"56 2y$++"5"56 2y$++"5"56 2y$++"5"56r#c|j||k(xs||jjdk(|j||k(xs||jjdk(y)zF Check if wanted UID/GID matched start or saved ones. N)r%rtr setegidCalls)rstartUIDstartGIDwantUIDwantGIDs r!_securedFunctionz(RunAsEffectiveUserTests._securedFunctionsZ 8+Vw$++:R:RSU:V/VW 8+Vw$++:R:RSU:V/VWr#cXtjddd}|j|dy)zo L{util.runAsEffectiveUser} forwards the result obtained by calling the given function rcy)NrrMrMr#r!z.rr#rNr runAsEffectiveUserrrrs r!test_forwardResultz*RunAsEffectiveUserTests.test_forwardResults( ((Ay9 #r#cZtjdddd}|j|dy)ze L{util.runAsEffectiveUser} pass the given parameters to the given function. rc d|zS)NrrM)rs r!r{z=RunAsEffectiveUserTests.test_takeParameters..s Qr#rrNr|r~s r!test_takeParametersz+RunAsEffectiveUserTests.test_takeParameterss* ((AB #r#c`tjdddddd}|j|dy) zg L{util.runAsEffectiveUser} pass the keyword parameters to the given function. rc||z|zSrrM)rrzs r!r{zDRunAsEffectiveUserTests.test_takesKeyworkArguments..s1q519r#rr)rrNr(r|r~s r!test_takesKeyworkArgumentsz2RunAsEffectiveUserTests.test_takesKeyworkArgumentss. ((A/LaSTU #r#c n||j_||j_tj|||j |||||j |jj||j |jj|g|j_g|j_y)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) rtregidr r}rxrrrs)rrtrurvrwexpectedUIDSwitchesexpectedGIDSwitchess r!_testUIDGIDSwitchz)RunAsEffectiveUserTests._testUIDGIDSwitchs$ #      ! !      113FG 113FG#%  #%  r#c |jddddgg|jddddddgg|jddddgddg|jddddddgddgy)zL Check UID/GID switches when current effective UID is root. rrNrr+s r! test_rootz!RunAsEffectiveUserTests.test_rootst q!Q2r2 q!QAq626 q!Q21v6 q!QAq6Aq6:r#c |jddddddgg|jddddgg|jddddgdddg|jddddgdddgy)zP Check UID/GID switches when current effective UID is non-root. rrrrrrrrrrrNrr+s r!test_UIDz RunAsEffectiveUserTests.test_UIDsp q!QAq626 q!Q2r2 q!Q.mockInitgroupsIs LL!Q r# _initgroups setgroupsrN) rur ryrsr7r8rr5r6r9r))rrsetgroupsCallsrds @r!test_initgroupsInStdlibz'InitGroupsTests.test_initgroupsInStdlibBs  ! 47 4n&;&;<  Q' #,,ryy{";"C"CQ!G HI (r#ct|jttjt j dy)zN Calling L{util.initgroups} with None for gid gives an error. N)r4r*r rsr7r8r+s r!test_initgroupsNoneGidz&InitGroupsTests.test_initgroupsNoneGidTs" )T__biik4Hr#N)rJrKrLr_rrrMr#r!rr<s)$Ir#rc<eZdZdZdZdZeedge_y)DeprecationTestsz; Tests for deprecations in C{twisted.python.util}. ctj|j|jg}|j |ddd|j |ddt |j t |dy)z6 L{util.getPluginDirs} is deprecated. rrrzCtwisted.python.util.getPluginDirs is deprecated since Twisted 12.2.rrN)r getPluginDirsrtest_getPluginDirsrrrrrs r!rz#DeprecationTests.test_getPluginDirs`s ,, $ 7 78-   A y ) T  +J79KL _-q1r#ctj|j|jg}|j |ddd|j |ddt |j t |dy)z5 L{util.addPluginDir} is deprecated. rrrzBtwisted.python.util.addPluginDir is deprecated since Twisted 12.2.rrN)r addPluginDirrtest_addPluginDirrrrrs r!rz"DeprecationTests.test_addPluginDiros ,, $ 6 67-   A y ) S  +J79KL _-q1r#z/twisted.python.util.getPluginDirs is deprecated)rrN) rJrKrLr_rrSUPPRESSrrrMr#r!rr[s, 2 2 'E "r#rcLeZdZdZeej ZdZdZdZ dZ y)SuppressedWarningsTestsz6 Tests for L{util.runWithWarningsSuppressed}. cdifdifg}|j|tjd|j|tjd|jg|j y)z Warnings from the function called by C{runWithWarningsSuppressed} are suppressed if they match the passed in filter. ignorez.*foo.*rz.*bar.* ignore fooz ignore barNrunWithWarningsSuppressedwarningswarnrr)rfilterss r!&test_runWithWarningsSuppressedFilteredz>SuppressedWarningsTests.test_runWithWarningsSuppressedFiltereds^ *2.1F0KL &&w |L &&w |L T//12r#cdifdifg}|j|tjd|jdg|j Dcgc]}|d c}ycc}w)z Warnings from the function called by C{runWithWarningsSuppressed} are not suppressed if they do not match the passed in filter. rrz don't ignorerNrrrrs r!(test_runWithWarningsSuppressedUnfilteredz@SuppressedWarningsTests.test_runWithWarningsSuppressedUnfiltereds] *2.1F0KL &&w ~N .)$BTBTBV+WQAiL+WX+Ws A cJ|j|jgddy)zd C{runWithWarningsSuppressed} returns the result of the function it called. cy)NrrMrMr#r!r{z:SuppressedWarningsTests.test_passThrough..rr#rN)rrr+s r!test_passThroughz(SuppressedWarningsTests.test_passThroughs! 77IFJr#cdifdifg}|j|dtjd|jdg|j Dcgc]}|d c}ycc}w)zk Once C{runWithWarningsSuppressed} has returned, it no longer suppresses warnings. rrcyrrMrMr#r!r{z.rr#rrNrrs r!test_noSideEffectsz*SuppressedWarningsTests.test_noSideEffectssb *2.1F0KL &&w = l# ,@R@R@T)U1!I,)UV)Us A$ N) rJrKrLr_ staticmethodr rrrrrrMr#r!rrs1!-T-K-K L3YKWr#rc.eZdZdZdZdZdZdZdZy)FancyStrMixinTestsz* Tests for L{util.FancyStrMixin}. cvGddtj}|jt|dy)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. ceZdZdZdZdZy)6FancyStrMixinTests.test_sequenceOfStrings..FoofirstsecondrhelloNrJrKrLshowAttributesrrrMr#r!rVr0NEFr#rVzNr FancyStrMixinrstrrrVs r!test_sequenceOfStringsz)FancyStrMixinTests.test_sequenceOfStringss-  $$$  SU%CDr#cvGddtj}|jdt|y)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"eZdZdddffZdZdZy).FancyStrMixinTests.test_formatter..Foorrc$t|dddS)Nrr)r)values r!r{z7FancyStrMixinTests.test_formatter..Foo.sU4R4[@Qr#rworldNrrMr#r!rVrs%2Q'RSNEFr#rVz"Nrrs r!test_formatterz!FancyStrMixinTests.test_formatters- $$$  =s35zJr#cvGddtj}|jt|dy)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. ceZdZdZdZdZy)-FancyStrMixinTests.test_override..Foo)r)r2ndz%.1frgS@NrrMr#r!rVrsANEFr#rVzNrrs r! test_overridez FancyStrMixinTests.test_overrides- $$$  SU%<=r#cvGddtj}|jt|dy)z_ If C{fancybasename} is present, C{__str__} uses it instead of the class name. ceZdZdZy)2FancyStrMixinTests.test_fancybasename..FooBarN)rJrKrL fancybasenamerMr#r!rVrs!Mr#rVzNrrs r!test_fancybasenamez%FancyStrMixinTests.test_fancybasenames,  "$$$ " SUW-r#cGddtj}|}|jt|t |y)zE C{__repr__} outputs the same content as C{__str__}. ceZdZdZdZdZy))FancyStrMixinTests.test_repr..FoorrrNrrMr#r!rVrrr#rVN)r rrrr)rrVobjs r! test_reprzFancyStrMixinTests.test_reprs5  $$$  e S49-r#N) rJrKrLr_rrrrrrMr#r!rrs" E K >. .r#rc:eZdZdZdZdZdZdZdZdZ dZ y ) PadToTestsz" Tests for L{util.padTo}. c\tjdg}|jdgdz|y)ze L{None} values can be added to a list to cause it to have a certain length. rNr padTorrpaddeds r! test_defaultzPadToTests.test_defaults* Ar" $!V,r#c^tjdgd}|jdgdz|y)zg A specific value can be added to a list to cause it to have a certain length. rrNrrs r!test_specificDefaultValuez$PadToTests.test_specificDefaultValues, Ar3' #F+r#c^tjdddgd}|jgd|y)zl A list which already has some items has the padding value added after those items. rrrr)rrrNrrs r!test_padNonEmptyListzPadToTests.test_padNonEmptyLists* A1vs+ f-r#cT|jttjdddgy)z{ L{util.padTo} can't pad a list if the size requested is smaller than the size of the list to pad. rrN)r4r5r rr+s r!test_padToSmallerSizez PadToTests.test_padToSmallerSizes *djj!aVrse    >> C C$+.75,,53 --/.J.JbVxV*(((>GB$ '')FGCVXCVHCVL]']'@2x2.M-8M-`6_6""""7++27x7 7D++.J<J