+
    üÐj$! ã                   ó\  € R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt ^ RIt^ RI	t
]
t	]t^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHtHtHt ^ RIHtHtHt ^ RIHt ^ R	IHt ^ R
I H!t! ^ RI"H#t#H$t$ ^ RI%H&t& ^ RI'H(t( ^ RI)H*t*H+t+H,t, ^ RI-H.t. ^ RI/H0t0 ^ RI1H2t2 ^ RI3H*t4H5t5 ^ RI6H7t7 ^ RI8H9t9 ^ RI:H;t; ^ RI<H=t= ^ RI>H?t? ^ RI@HAtA ]7! R4      tB]B'       d   ^ RICHDtDHEtEHFtF ]7! R4      tG]7! R4      tH]7! R4      tI]7! R4      tJR tK ! R  R!4      tL ! R" R#]Pš                  4      tN ! R$ R%]=Pž                  4      tP ! R& R']A4      tQ]! ]B'       * R(4       ! R) R*]A4      4       tR ! R+ R,]A4      tS ! R- R.4      tT ! R/ R0]Pª                  4      tV ! R1 R2]A4      tW]! ]B'       * R(4       ! R3 R4]A4      4       tX]! ]B'       * R(4       ! R5 R6]A4      4       tY]! ]B'       * R(4       ! R7 R8]A4      4       tZ ! R9 R:4      t[]! ]#4       ! R; R<][4      4       t\ ! R= R>4      t] ! R? R@]A4      t^RA t_RB t` ! RC RD]A4      ta]! ]B'       * R(4       ! RE RF]A4      4       tb]! ]B'       * RG4       ! RH RI]A4      4       tc]! ]$4       ! RJ RK](4      4       td ! RL RM]=Pž                  4      teRN tf ! RO RP]A4      tgR#   ] d	    Rt	Rt EL‚i ; i)QzE
Tests for L{twisted.application.app} and L{twisted.scripts.twistd}.
N)ÚStringIO)ÚskipIf)Úimplementer)ÚverifyObject)ÚinternetÚloggerÚplugin)ÚappÚreactorsÚservice)ÚIServiceMaker)ÚReactorBase)ÚDeferred)ÚIReactorDaemonizeÚ_ISupportsExitSignalCapturing)ÚAlternateReactor)ÚMemoryReactor)ÚILogObserverÚglobalLogBeginnerÚglobalLogPublisher)Úutil)ÚComponentized)ÚUserDatabase)r   ÚtextFromEventDict)ÚrequireModule)ÚplatformType)Ú
UsageError)Útwistd)ÚMockOS)ÚTestCaseztwisted.scripts._twistd_unix)ÚUnixApplicationRunnerÚUnixAppLoggerÚcheckPIDztwisted.python.syslogÚprofileÚpstatsÚcProfilec           	     óÈ  aaa€ \         P                  \        P                  ! 4       4      p\        P                  \        P                  ! 4       4      o\        4       pVP                  WP                  VSVP                  VP                  VP                  4       VVV3R lpV ! \         RVP                  4       V ! \        RV4       V ! \         RVP                  4       R# )a=  
Patch L{pwd.getpwnam} so that it behaves as though only one user exists
and patch L{grp.getgrnam} so that it behaves as though only one group
exists.

@param patch: A function like L{TestCase.patch} which will be used to
    install the fake implementations.

@type user: C{str}
@param user: The name of the single user which will exist.

@type uid: C{int}
@param uid: The UID of the single user which will exist.

@type group: C{str}
@param group: The name of the single user which will exist.

@type gid: C{int}
@param gid: The GID of the single group which will exist.
c                 óº   <€ \        S4      pSWP                  SP                  4      &   SWP                  SP                  4      &   \	        V4      pSV/V ,          # ©N)ÚlistÚindexÚgr_nameÚgr_gidÚtuple)ÚnameÚresultÚgidÚgrentÚgroups   & €€€Ú:/usr/lib/python3/dist-packages/twisted/test/test_twistd.pyÚgetgrnamÚ#patchUserDatabase.<locals>.getgrnamd   sN   ø€ Ü�e“ˆØ.3ˆ�|‰|˜EŸM™MÓ*Ñ+Ø-0ˆ�|‰|˜EŸL™LÓ)Ñ*Ü�v“ˆØ�vˆ˜tÕ$Ð$ó    Úgetpwnamr4   ÚgetpwuidN)Úpwdr8   ÚosÚgetuidÚgrpÚgetgrgidÚgetgidr   ÚaddUserÚ	pw_passwdÚpw_gecosÚpw_dirÚpw_shellr7   )	ÚpatchÚuserÚuidr2   r0   ÚpwentÚdatabaser4   r1   s	   &&&ff   @r3   ÚpatchUserDatabaserI   C   s–   ú€ ô2 �L‰LœŸš›Ó%€EÜ�L‰LœŸš›Ó%€Eä‹~€HØ×ÑØ�o‰o˜s C¨¯©¸¿¹ÀuÇ~Á~ô÷%ñ 
Œ#ˆz˜8×,Ñ,Ô-Ù	Œ#ˆz˜8Ô$Ù	Œ#ˆz˜8×,Ñ,Ö-r6   c                   ó.   a € ] tR t^pt o RtRtR tRtV tR# )ÚMockServiceMakerzG
A non-implementation of L{twisted.application.service.IServiceMaker}.
Úueoac                óZ   € Wn         \        P                  ! 4       V n        V P                  # )zM
Take a L{usage.Options} instance and return a
L{service.IService} provider.
)Úoptionsr   ÚService©ÚselfrN   s   &&r3   ÚmakeServiceÚMockServiceMaker.makeServicew   s!   € ð
 ŒÜ—’Ó(ˆŒØ�|‰|Ðr6   )rN   r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚtapnamerR   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r3   rK   rK   p   s   ø‡ € ñð €G÷ð r6   rK   c                   ó*   a € ] tR t^�t o RtR tRtV tR# )ÚCrippledAppLoggerz"
@see: CrippledApplicationRunner.
c                ó   € R # r(   © ©rQ   Úapplications   &&r3   ÚstartÚCrippledAppLogger.start†   ó   € Ùr6   ra   N)rT   rU   rV   rW   rX   rd   rZ   r[   r\   s   @r3   r_   r_   �   s   ø‡ € ñ÷ð r6   r_   c                   ó4   a € ] tR t^Št o Rt]tR tR tRt	V t
R# )ÚCrippledApplicationRunnerz³
An application runner that cripples the platform-specific runner and
nasty side-effect-having code so that we can use it without actually
running any environment-affecting code.
c                ó   € R # r(   ra   ©rQ   s   &r3   ÚpreApplicationÚ(CrippledApplicationRunner.preApplication“   rf   r6   c                ó   € R # r(   ra   rj   s   &r3   ÚpostApplicationÚ)CrippledApplicationRunner.postApplication–   rf   r6   ra   N)rT   rU   rV   rW   rX   r_   ÚloggerFactoryrk   rn   rZ   r[   r\   s   @r3   rh   rh   Š   s    ø‡ € ñð &€Mò÷ð r6   rh   c                   óÒ   a € ] tR t^št o RtR tR tR tR tR t	]
! ]'       * R4      R 4       t]
! ]'       * R4      R	 4       t]
! ]'       * R4      R
 4       tR tR tR tR tRtV tR# )ÚServerOptionsTestszL
Non-platform-specific tests for the platform-specific ServerOptions class.
c                ó*  a aaaa€  ! R R4      pV! R4      oV! R4      oV! R4      oV! R4      oVVVVV 3R lp\         P                  ! 4       pS P                  VP                  \        P
                  4       W#n        VP                  pSSSS.p\        WE4       Fs  w  rgVw  r‰r«S P                  W‡P                  4       S P                  V	4       S P                  V
! 4       VP                  4      3 S P                  W·P                  4       Ku  	  R# )	zP
subCommands is built from IServiceMaker plugins, and is sorted
alphabetically.
c                   ó,   a € ] tR t^¥t o R tR tRtV tR# )Ú7ServerOptionsTests.test_subCommands.<locals>.FakePluginc                óJ   € Wn         R V,           V n        RV,           V n        R# )zoptions for údescription of N)rY   Ú_optionsÚdescription©rQ   r.   s   &&r3   Ú__init__Ú@ServerOptionsTests.test_subCommands.<locals>.FakePlugin.__init__¦   s    € Ø#”Ø .°Õ 5�”Ø#4°tÕ#;�Ö r6   c                ó   € V P                   # r(   )rx   rj   s   &r3   rN   Ú?ServerOptionsTests.test_subCommands.<locals>.FakePlugin.options«   s   € Ø—}‘}Ð$r6   )rx   ry   rY   N)rT   rU   rV   rW   r{   rN   rZ   r[   r\   s   @r3   Ú
FakePluginru   ¥   s   ø‡ € ò<÷
%ð %r6   r   ÚappleÚbananaÚcoconutÚdonutc              3   ó\   <"  € SP                  V \        4       Sx € Sx € Sx € Sx € R # 5ir(   )ÚassertEqualr   )Ú	interfacer€   r�   r‚   rƒ   rQ   s   &€€€€€r3   Ú
getPluginsÚ7ServerOptionsTests.test_subCommands.<locals>.getPlugins³   s*   øé € Ø×Ñ˜Y¬Ô6ØŠMØŠLØŠKØŒKùs   ƒ),N)r   ÚServerOptionsr…   Ú_getPluginsr   r‡   ÚsubCommandsÚziprY   ÚassertIsNonerx   ry   )rQ   r   r‡   Úconfigr‹   ÚexpectedOrderÚ
subCommandÚexpectedCommandr.   ÚshortcutÚparserClassÚdocumentationr€   r�   r‚   rƒ   s   f           @@@@r3   Útest_subCommandsÚ#ServerOptionsTests.test_subCommandsŸ   sü   ü€ ÷	%ñ 	%ñ ˜7Ó#ˆÙ˜HÓ%ˆÙ˜YÓ'ˆÙ˜7Ó#ˆ÷	ñ 	ô ×%Ò%Ó'ˆØ×Ñ˜×+Ñ+¬V×->Ñ->Ô?Ø'Ôð ×(Ñ(ˆØ ¨°Ð7ˆä+.¨{Ö+JÑ'ˆJØ9CÑ6ˆD˜KØ×Ñ˜T×#:Ñ#:Ô;Ø×Ñ˜hÔ'Ø×Ñ™[›]¨O×,DÑ,DÓEÑFØ×Ñ˜]×,GÑ,GÖHó ,Kr6   c                óf  a aaaa	a
a€  ! R R4      pV! R4      oV! R4      oV! R4      oV! R4      o	VVVV	3R lp\         P                  ! 4       pS P                  VP                  \        P
                  4       W#n        \        4       Vn        S P                  \        VP                  R.4       VP                  P                  4       o
. oSSSS	3 F/  pV
VV 3R	 lpV! VP                  4       V! VP                  4       K1  	  S P                  S\        S4      R
P                  S
4      4       R# )z@
Reactor names are listed alphabetically by I{--help-reactors}.
c                   ó&   a € ] tR t^Ït o R tRtV tR# )ÚGServerOptionsTests.test_sortedReactorHelp.<locals>.FakeReactorInstallerc                óL   € R V,           V n         RV,           V n        RV n        R# )zname of rw   ztwisted.internet.defaultN)Ú	shortNamery   Ú
moduleNamerz   s   &&r3   r{   ÚPServerOptionsTests.test_sortedReactorHelp.<locals>.FakeReactorInstaller.__init__Ð   s"   € Ø!+¨dÕ!2�”Ø#4°tÕ#;�Ô Ø"<�–r6   )ry   rœ   r›   N)rT   rU   rV   rW   r{   rZ   r[   r\   s   @r3   ÚFakeReactorInstallerr™   Ï   s   ø‡ € ÷=ð =r6   rž   r€   r�   r‚   rƒ   c               3   ó0   <"  € Sx € Sx € Sx € S x € R # 5ir(   ra   )r€   r�   r‚   rƒ   s   €€€€r3   ÚgetReactorTypesÚBServerOptionsTests.test_sortedReactorHelp.<locals>.getReactorTypesÚ   s   øé € ØŠMØŠLØŠKØŒKùs   ƒz--help-reactorsc                 ól   <€ SP                  V S4       SP                  SP                  V 4      4       R # r(   )ÚassertInÚappendr*   )ÚsÚ
helpOutputÚindexesrQ   s   &€€€r3   ÚgetIndexÚ;ServerOptionsTests.test_sortedReactorHelp.<locals>.getIndexê   s(   ø€ Ø—‘˜a Ô,Ø—‘˜z×/Ñ/°Ó2Ö3r6   z9reactor descriptions were not in alphabetical order: {!r}N)r   r‰   r…   Ú_getReactorTypesr
   r    r   ÚmessageOutputÚassertRaisesÚ
SystemExitÚparseOptionsÚgetvaluer›   ry   ÚsortedÚformat)rQ   rž   r    rŽ   Úreactorr¨   r€   r�   r‚   rƒ   r¦   r§   s   f     @@@@@@r3   Útest_sortedReactorHelpÚ)ServerOptionsTests.test_sortedReactorHelpÊ   s  þ€ ÷
	=ñ 	=ñ % WÓ-ˆÙ% hÓ/ˆÙ& yÓ1ˆÙ$ WÓ-ˆ÷	ð 	ô ×%Ò%Ó'ˆØ×Ñ˜×0Ñ0´(×2JÑ2JÔKØ"1ÔÜ'›zˆÔà×Ñœ* f×&9Ñ&9Ð<MÐ;NÔOØ×)Ñ)×2Ñ2Ó4ˆ
ØˆØ˜f g¨uÓ4ˆG÷4ñ �W×&Ñ&Ô'Ù�W×(Ñ(Ö)ñ 5ð 	×ÑØÜ�7‹OØG×NÑNØóö	
r6   c                óŽ   € \         P                  ! 4       pRVn        VP                  4        V P	                  VR,          4       R# )zC
postOptions should set no_save to True when a subcommand is used.
rL   Úno_saveN)r   r‰   r�   ÚpostOptionsÚ
assertTrue©rQ   rŽ   s   & r3   Ú&test_postOptionsSubCommandCausesNoSaveÚ9ServerOptionsTests.test_postOptionsSubCommandCausesNoSaveù   s7   € ô ×%Ò%Ó'ˆØ"ˆÔØ×ÑÔØ�‰˜˜yÕ)Ö*r6   c                ó€   € \         P                  ! 4       pVP                  4        V P                  VR,          4       R# )zB
If no sub command is used, postOptions should not touch no_save.
r¶   N)r   r‰   r·   ÚassertFalser¹   s   & r3   Ú(test_postOptionsNoSubCommandSavesAsUsualÚ;ServerOptionsTests.test_postOptionsNoSubCommandSavesAsUsual  s1   € ô ×%Ò%Ó'ˆØ×ÑÔØ×Ñ˜ 	Õ*Ö+r6   c                óª   € \         P                  ! 4       p\        V4      p\        P                  P
                   F  pV P                  W24       K  	  R# )zY
All the profilers that can be used in L{app.AppProfiler} are listed in
the help output.
N)r   r‰   Ústrr	   ÚAppProfilerÚ	profilersr£   )rQ   rŽ   r¦   Úprofilers   &   r3   Útest_listAllProfilersÚ(ServerOptionsTests.test_listAllProfilers
  s;   € ô
 ×%Ò%Ó'ˆÜ˜“[ˆ
ÜŸ™×1Ô1ˆHØ�M‰M˜(Ö/ó 2r6   útwistd unix not availablec                ó`   € \         P                  ! 4       pV P                  VR,          4       R# )z7
The default value for the C{umask} option is L{None}.
ÚumaskN)r   r‰   r�   r¹   s   & r3   Útest_defaultUmaskÚ$ServerOptionsTests.test_defaultUmask  s$   € ô
 ×%Ò%Ó'ˆØ×Ñ˜& �/Ö*r6   c                óà   € \         P                  ! 4       pVP                  RR.4       V P                  VR,          ^S4       VP                  RR.4       V P                  VR,          ^S4       R# )zP
The value given for the C{umask} option is parsed as an octal integer
literal.
ú--umaskÚ123rÉ   Ú0123N)r   r‰   r®   r…   r¹   s   & r3   Ú
test_umaskÚServerOptionsTests.test_umask  s`   € ô ×%Ò%Ó'ˆØ×Ñ˜Y¨Ð.Ô/Ø×Ñ˜ �¨"Ô-Ø×Ñ˜Y¨Ð/Ô0Ø×Ñ˜ �¨"Ö-r6   c                óv   € \         P                  ! 4       pV P                  \        VP                  RR.4       R# )z�
If a value is given for the C{umask} option which cannot be parsed as
an integer, L{UsageError} is raised by L{ServerOptions.parseOptions}.
rÍ   ÚabcdefN)r   r‰   r¬   r   r®   r¹   s   & r3   Útest_invalidUmaskÚ$ServerOptionsTests.test_invalidUmask(  s/   € ô ×%Ò%Ó'ˆØ×Ñœ* f×&9Ñ&9¸IÀxÐ;PÖQr6   c                ó  € \         P                  ! 4       pV P                  \        VP                  RR.4      pV P                  VP                  ^ ,          P                  R4      4       V P                  RVP                  ^ ,          4       R# )zA
C{--logger} with an unimportable module raises a L{UsageError}.
ú--loggerzno.such.module.I.hopezeLogger 'no.such.module.I.hope' could not be imported: 'no.such.module.I.hope' does not name an objectÚ
N©	r   r‰   r¬   r   r®   r¸   ÚargsÚ
startswithÚassertNotIn©rQ   rŽ   Úes   &  r3   Ú&test_unimportableConfiguredLogObserverÚ9ServerOptionsTests.test_unimportableConfiguredLogObserver1  sy   € ô ×%Ò%Ó'ˆØ×ÑÜ˜×+Ñ+¨jÐ:QÐ-Ró
ˆð 	�‰Ø�F‰F�1�I× Ñ ðBóô	
ð 	×Ñ˜˜qŸv™v a�yÖ)r6   c                ó  € \         P                  ! 4       pV P                  \        VP                  RR.4      pV P                  VP                  ^ ,          P                  R4      4       V P                  RVP                  ^ ,          4       R# )z@
C{--logger} with a non-existent object raises a L{UsageError}.
r×   ztwisted.test.test_twistd.FOOBARz{Logger 'twisted.test.test_twistd.FOOBAR' could not be imported: module 'twisted.test.test_twistd' has no attribute 'FOOBAR'rØ   NrÙ   rÝ   s   &  r3   Ú*test_badAttributeWithConfiguredLogObserverÚ=ServerOptionsTests.test_badAttributeWithConfiguredLogObserverA  sz   € ô ×%Ò%Ó'ˆØ×ÑÜØ×ÑØÐ:Ð;ó
ˆð
 	�‰Ø�F‰F�1�I× Ñ ð,óô	
ð 	×Ñ˜˜qŸv™v a�yÖ)r6   c                ó|  € ^ RI Hp \        R8X  d   RpMRpRP                  W!P                  VP                  4      p\        4       p\        P                  ! VR7      pV P                  \        VP                  R.4      pV P                  VP                  R4       V P                  VP                  4       V4       R# )	z"
C{--version} prints the version.
)Ú	copyrightÚwin32z(the Twisted Windows runner)z(the Twisted daemon)ztwistd {} {}
{}
©Ústdoutz	--versionN)Útwistedrå   r   r±   Úversionr   r   r‰   r¬   r­   r®   ÚassertIsÚcoder…   r¯   )rQ   rå   r.   ÚexpectedOutputrè   rŽ   rÞ   s   &      r3   Útest_versionÚServerOptionsTests.test_versionT  s˜   € õ 	&ä˜7Ô"Ø1‰Dà)ˆDØ-×4Ñ4Ø×#Ñ# Y×%8Ñ%8ó
ˆô “ˆÜ×%Ò%¨VÔ4ˆØ×Ñœj¨&×*=Ñ*=À¸}ÓMˆØ�‰�a—f‘f˜dÔ#Ø×Ñ˜Ÿ™Ó*¨NÖ;r6   c                óŒ   € \        4       p\        P                  ! VR7      pV P                  \        VP
                  R.4       R# )z9
Command is printed when an invalid option is requested.
rç   z	web --fooN)r   r   r‰   r¬   r   r®   )rQ   rè   rŽ   s   &  r3   Ú!test_printSubCommandForUsageErrorÚ4ServerOptionsTests.test_printSubCommandForUsageErrorh  s5   € ô “ˆÜ×%Ò%¨VÔ4ˆà×Ñœ* f×&9Ñ&9¸K¸=ÖIr6   ra   N)rT   rU   rV   rW   rX   r•   r³   rº   r¾   rÅ   r   Ú_twistd_unixrÊ   rÐ   rÔ   rß   râ   rî   rñ   rZ   r[   r\   s   @r3   rr   rr   š   s    ø‡ € ñò)IòV-
ò^+ò,ò0ñ �ÔÐ9Ó:ñ+ó ;ð+ñ �ÔÐ9Ó:ñ	.ó ;ð	.ñ �ÔÐ9Ó:ñRó ;ðRò*ò *ò&<÷(Jð Jr6   rr   rÇ   c                   óB   a € ] tR tRt o RtR tR tR tR tR t	Rt
V tR	# )
ÚCheckPIDTestsir  z
Tests for L{checkPID}.
c                ó`   € V P                  \        P                  RR 4       \        R4       R# )z'
Nonexistent PID file is not an error.
Úexistsc                 ó   € R # )Fra   )Ú_s   &r3   Ú<lambda>Ú.CheckPIDTests.test_notExists.<locals>.<lambda>|  s   € ±r6   znon-existent PID fileN)rD   r:   Úpathr"   rj   s   &r3   Útest_notExistsÚCheckPIDTests.test_notExistsx  s!   € ð 	�
‰
”2—7‘7˜H¡oÔ6ÜÐ(Ö)r6   c                ó  € V P                  4       p\        VR4      ;_uu_ 4       pVP                  R4       RRR4       V P                  \        \
        V4      pV P                  RVP                  4       R#   + '       g   i     LI; i)z9
Non-numeric content in a PID file causes a system exit.
Úwznon-numericNznon-numeric value)ÚmktempÚopenÚwriter¬   r­   r"   r£   rì   )rQ   ÚpidfileÚfrÞ   s   &   r3   Útest_nonNumericÚCheckPIDTests.test_nonNumeric  s_   € ð —+‘+“-ˆÜ�'˜3×Ô 1Ø�G‰G�MÔ"÷  à×Ñœj¬(°GÓ<ˆØ�‰Ð)¨1¯6©6Ö2÷  ×ús   ¥A8Á8B	c                óJ  € V P                  4       p\        VR4      ;_uu_ 4       pVP                  R4       RRR4       R pV P                  \        RV4       V P                  \        \        V4      pV P                  RVP                  4       R#   + '       g   i     Lc; i)z5
Another running twistd server causes a system exit.
r   Ú42Nc                 ó   € R # r(   ra   ©ÚpidÚsigs   &&r3   ÚkillÚ/CheckPIDTests.test_anotherRunning.<locals>.kill‘  s   € Ùr6   r  zAnother twistd server)
r  r  r  rD   r:   r¬   r­   r"   r£   rì   ©rQ   r  r  r  rÞ   s   &    r3   Útest_anotherRunningÚ!CheckPIDTests.test_anotherRunning‰  su   € ð —+‘+“-ˆÜ�'˜3×Ô 1Ø�G‰G�DŒM÷  ò	ð 	�
‰
”2�v˜tÔ$Ø×Ñœj¬(°GÓ<ˆØ�‰Ð-¨q¯v©vÖ6÷  ×ús   ¥BÂB"	c                ó”  € V P                  4       p\        VR4      ;_uu_ 4       pVP                  \        \        P
                  ! 4       ^,           4      4       RRR4       R pV P                  \        RV4       \        V4       V P                  \        P                  P                  V4      4       R#   + '       g   i     Le; i)z:
Stale PID file is removed without causing a system exit.
r   Nc                 ó6   € \        \        P                  R 4      h©Úfake)ÚOSErrorÚerrnoÚESRCHr  s   &&r3   r  Ú&CheckPIDTests.test_stale.<locals>.kill   ó   € Üœ%Ÿ+™+ vÓ.Ð.r6   r  )r  r  r  rÁ   r:   ÚgetpidrD   r"   r½   rü   r÷   )rQ   r  r  r  s   &   r3   Ú
test_staleÚCheckPIDTests.test_stale˜  s�   € ð —+‘+“-ˆÜ�'˜3×Ô 1Ø�G‰G”CœŸ	š	› a�Ó(Ô)÷  ò	/ð 	�
‰
”2�v˜tÔ$Ü�ÔØ×ÑœŸ™Ÿ™¨Ó0Ö1÷  ×ús   ¥5B7Â7C	c                ó¬  € V P                  4       p\        VR4      ;_uu_ 4       pVP                  R4       RRR4       R pV P                  \        RV4       V P                  \        \        V4      pV P                  VP                  R4       V P                  VP                  ^ ,          P                  R4      4       R#   + '       g   i     L”; i)zx
An unexpected L{OSError} when checking the validity of a
PID in a C{pidfile} terminates the process via L{SystemExit}.
r   Ú3581Nc                 ó6   € \        \        P                  R 4      hr  ©r  r  ÚEBADFr  s   &&r3   r  Ú2CheckPIDTests.test_unexpectedOSError.<locals>.kill°  r  r6   r  zCan't check status of PID)r  r  r  rD   r:   r¬   r­   r"   ÚassertIsNotrì   r¸   rÚ   rÛ   r  s   &    r3   Útest_unexpectedOSErrorÚ$CheckPIDTests.test_unexpectedOSError§  s–   € ð
 —+‘+“-ˆÜ�'˜3×Ô 1Ø�G‰G�FŒO÷  ò	/ð 	�
‰
”2�v˜tÔ$Ø×Ñœj¬(°GÓ<ˆØ×Ñ˜Ÿ™ Ô&Ø�‰˜Ÿ™˜q�	×,Ñ,Ð-HÓIÖJ÷  ×ús   ¥CÃC	ra   N)rT   rU   rV   rW   rX   rý   r  r  r  r&  rZ   r[   r\   s   @r3   rõ   rõ   r  s*   ø‡ € ñò*ò3ò7ò2÷Kð Kr6   rõ   c                   ó0   a € ] tR tRt o RtR tR tRtV tR# )ÚTapFileTestsi¹  zE
Test twistd-related functionality that requires a tap file on disk.
c                óü   € V P                  4       V n        \        V P                  R4      ;_uu_ 4       p\        P                  ! \
        P                  ! R4      V4       RRR4       R#   + '       g   i     R# ; i)z@
Create a trivial Application and put it in a tap file on disk.
ÚwbúHi!N)r  Útapfiler  ÚpickleÚdumpr   ÚApplication)rQ   r  s   & r3   ÚsetUpÚTapFileTests.setUp¾  sL   € ð —{‘{“}ˆŒÜ�$—,‘, ×%Ô%¨Ü�KŠKœ×+Ò+¨EÓ2°AÔ6÷ &×%×%Ò%ús   ´,A*Á*A;	c                óü   € \         P                  ! 4       pVP                  RV P                  .4       \	        V4      P                  4       pV P                  \        P                  ! V4      P                  R4       R# )zv
Ensure that the createOrGetApplication call that 'twistd -f foo.tap'
makes will load the Application out of foo.tap.
z-fr,  N)
r   r‰   r®   r-  rh   ÚcreateOrGetApplicationr…   r   ÚIServicer.   )rQ   rŽ   rc   s   &  r3   Ú&test_createOrGetApplicationWithTapFileÚ3TapFileTests.test_createOrGetApplicationWithTapFileÆ  s]   € ô
 ×%Ò%Ó'ˆØ×Ñ˜T 4§<¡<Ð0Ô1Ü/°Ó7×NÑNÓPˆØ×Ñœ×)Ò)¨+Ó6×;Ñ;¸UÖCr6   )r-  N)	rT   rU   rV   rW   rX   r1  r6  rZ   r[   r\   s   @r3   r)  r)  ¹  s   ø‡ € ñò7÷Dð Dr6   r)  c                   ó6   a € ] tR tRt o RtR tR tR tRtV t	R# )ÚTestLoggerFactoryiÑ  z0
A logger factory for L{TestApplicationRunner}.
c                ó   € Wn         R # r(   ©Úrunner)rQ   r<  s   &&r3   r{   ÚTestLoggerFactory.__init__Ö  s   € ØŽr6   c                óš   € V P                   P                  P                  R4       \        V P                   R4      V P                   n        R# )z3
Save the logging start on the C{runner} instance.
Úlogrc   N)r<  Úorderr¤   ÚhasattrÚhadApplicationLogObserverrb   s   &&r3   rd   ÚTestLoggerFactory.startÙ  s3   € ð 	�‰×Ñ× Ñ  Ô'Ü07¸¿¹À]Ó0Sˆ�‰Ö-r6   c                ó   € R# )z
Don't log anything.
Nra   rj   s   &r3   ÚstopÚTestLoggerFactory.stopà  ó   ‚ r6   r;  N)
rT   rU   rV   rW   rX   r{   rd   rE  rZ   r[   r\   s   @r3   r9  r9  Ñ  s   ø‡ € ñòòT÷ð r6   r9  c                   ó6   a € ] tR tRt o RtR tR tR tRtV t	R# )ÚTestApplicationRunneriæ  zT
An ApplicationRunner which tracks the environment in which its methods are
called.
c                ór   € \         P                  P                  W4       . V n        \	        V 4      V n        R # r(   )r	   ÚApplicationRunnerr{   r@  r9  r   rP   s   &&r3   r{   ÚTestApplicationRunner.__init__ì  s)   € Ü×Ñ×&Ñ& tÔ5ØˆŒ
Ü'¨Ó-ˆŽr6   c                ó^   € V P                   P                  R 4       \        V R4      V n        R# )Úprerc   N)r@  r¤   rA  ÚhadApplicationPreApplicationrj   s   &r3   rk   Ú$TestApplicationRunner.preApplicationñ  s#   € Ø�
‰
×Ñ˜%Ô Ü,3°D¸-Ó,HˆÖ)r6   c                ó^   € V P                   P                  R 4       \        V R4      V n        R# )Úpostrc   N)r@  r¤   rA  ÚhadApplicationPostApplicationrj   s   &r3   rn   Ú%TestApplicationRunner.postApplicationõ  s#   € Ø�
‰
×Ñ˜&Ô!Ü-4°T¸=Ó-IˆÖ*r6   )rS  rO  r   r@  N)
rT   rU   rV   rW   rX   r{   rk   rn   rZ   r[   r\   s   @r3   rI  rI  æ  s!   ø‡ € ñò
.ò
I÷Jð Jr6   rI  c                   óÄ   a € ] tR tRt o RtR tR tR tR t]	! ]
! ]RR4      '       * R	4      R
 4       t]	! ]
! ]RR4      '       * R	4      R 4       tR tR tR tR tRtV tR# )ÚApplicationRunnerTestsiú  zJ
Non-platform-specific tests for the platform-specific ApplicationRunner.
c                ó¬   € \         P                  ! 4       p\        4       V n        R V P                  /Vn        \        4       Vn        R Vn        Wn        R# )Útest_commandN)	r   r‰   rK   ÚserviceMakerÚloadedPluginsÚobjectÚ
subOptionsr�   rŽ   r¹   s   & r3   r1  ÚApplicationRunnerTests.setUpÿ  sE   € Ü×%Ò%Ó'ˆÜ,Ó.ˆÔà .°×0AÑ0AÐBˆÔÜ"›HˆÔØ*ˆÔØŽr6   c                ór  € \        V P                  4      pVP                  4        V P                  V P                  P
                  V P                  P                  R4       V P                  V P                  P                  \        P                  ! VP                  4      P                  ^ ,          R4       R# )z—
Ensure that a twistd plugin gets used in appropriate ways: it
is passed its Options instance, and the service it returns is
added to the application.
zKServiceMaker.makeService needs to be passed the correct sub Command object.zPServiceMaker.makeService's result needs to be set as a child of the Application.N)rh   rŽ   Úrunrë   rY  rN   r\  r   r5  rc   Úservices)rQ   Úarunners   & r3   Ú,test_applicationRunnerGetsCorrectApplicationÚCApplicationRunnerTests.test_applicationRunnerGetsCorrectApplication  s‰   € ô ,¨D¯K©KÓ8ˆØ�‰Œà�‰Ø×Ñ×%Ñ%Ø�K‰K×"Ñ"ð"ô	
ð 	�‰Ø×Ñ×%Ñ%Ü×Ò˜W×0Ñ0Ó1×:Ñ:¸1Õ=ð"ö	
r6   c                ó.  € \        V P                  4      pVP                  4        V P                  VP                  4       V P                  VP                  4       V P                  VP                  4       V P                  VP                  . RO4       R# )zn
Test thet preApplication and postApplication methods are
called by ApplicationRunner.run() when appropriate.
N)rN  r?  rR  )
rI  rŽ   r_  r½   rO  r¸   rS  rB  r…   r@  )rQ   r¥   s   & r3   Útest_preAndPostApplicationÚ1ApplicationRunnerTests.test_preAndPostApplication  sh   € ô
 " $§+¡+Ó.ˆØ	�‰ŒØ×Ñ˜×7Ñ7Ô8Ø�‰˜×7Ñ7Ô8Ø�‰˜×3Ñ3Ô4Ø×Ñ˜Ÿ™Ò"8Ö9r6   c           	     ó  a€ V P                   P                  V4       . o ! V3R lR\        P                  4      p\	        \
        P                  \
        P                  4       ! V3R lR4      4       pV! 4       p\        \
        P                  V4       \        \
        P                  V4       V! V P                   4      pVP                  4        Wgn
        VP                  4        V P                  SRRRRW#3R	R
.4       R# )zþ
Assert that given a particular command line, an application is started
as a particular UID/GID.

@param argv: A list of strings giving the options to parse.
@param uid: An integer giving the expected UID.
@param gid: An integer giving the expected GID.
c                   óL   <a € ] tR tRt o V3R ltV3R ltV3R ltR tRtV t	R# )Ú\ApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunneri7  c                ó*   <€ SP                  R 4       R# )ÚenvironmentN©r¤   )rQ   ÚchrootÚrundirÚnodaemonrÉ   r  Úeventss   &&&&&&€r3   ÚsetupEnvironmentÚmApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunner.setupEnvironment8  s   ø€ Ø—‘˜mÖ,r6   c                ó0   <€ SP                  R WV34       R# )Ú
privilegesNrl  )rQ   ÚeuidrF   r0   rp  s   &&&&€r3   ÚshedPrivilegesÚkApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunner.shedPrivileges;  s   ø€ Ø—‘˜|¨T¸Ð<Ö=r6   c                ó*   <€ SP                  R 4       R# )r²   Nrl  )rQ   r²   Ú	oldstdoutÚ	oldstderrrp  s   &&&&€r3   ÚstartReactorÚiApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunner.startReactor>  s   ø€ Ø—‘˜iÖ(r6   c                ó   € R # r(   ra   )rQ   r  s   &&r3   Ú	removePIDÚfApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunner.removePIDA  ó   € Ùr6   ra   N)
rT   rU   rV   rW   rq  rv  r{  r~  rZ   r[   ©r]   rp  s   @€r3   ÚFakeUnixApplicationRunnerri  7  s   ù‡ € õ-õ>õ)÷ð r6   r‚  c                   ój   <a € ] tR tRt o RtRtRtRtRtRt	R t
R tR tV3R ltV3R ltR tR	tV tR# )
ÚNApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeServiceiD  Nc                ó   € R # r(   ra   rz   s   &&r3   ÚsetNameÚVApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.setNameM  r€  r6   c                ó   € R # r(   ra   )rQ   Úparents   &&r3   ÚsetServiceParentÚ_ApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.setServiceParentP  r€  r6   c                ó   € R # r(   ra   rj   s   &r3   ÚdisownServiceParentÚbApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.disownServiceParentS  r€  r6   c                ó*   <€ SP                  R 4       R# )ÚprivilegedStartServiceNrl  ©rQ   rp  s   &€r3   r�  ÚeApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.privilegedStartServiceV  s   ø€ Ø—‘Ð6Ö7r6   c                ó*   <€ SP                  R 4       R# )ÚstartServiceNrl  r‘  s   &€r3   r”  Ú[ApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.startServiceY  s   ø€ Ø—‘˜nÖ-r6   c                ó   € R # r(   ra   rj   s   &r3   ÚstopServiceÚZApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.stopService\  r€  r6   ra   )rT   rU   rV   rW   r‰  Úrunningr.   ÚprocessNamerF   r0   r†  rŠ  r�  r�  r”  r—  rZ   r[   r�  s   @€r3   ÚFakeServicer„  D  sF   ù‡ € àˆFØˆGØˆDØˆKØˆCØˆCòòòõ8õ.÷ð r6   r›  rk  r�  rt  Fr”  r²   N)rŽ   r®   r   Ú_SomeApplicationRunnerr   r   r5  ÚIProcessr   rk   rc   rn   r…   )	rQ   ÚargvrF   r0   r‚  r›  rc   r<  rp  s	   &&&&    @r3   Ú"_applicationStartsWithConfiguredIDÚ9ApplicationRunnerTests._applicationStartsWithConfiguredID*  sÛ   ø€ ð 	�‰× Ñ  Ô&àˆ÷	¬×(EÑ(Eô 	ô 
”W×%Ñ%¤w×'7Ñ'7Ó	8÷	ó 	ó 
9ð	ñ4 "“mˆÜ”W×%Ñ% {Ô3Ü”W×%Ñ% {Ô3á*¨4¯;©;Ó7ˆØ×ÑÔØ(ÔØ×ÑÔ à×ÑØàØ(Ø˜u cÐ/ØØðö		
r6   ÚsetuidNz5Platform does not support --uid/--gid twistd options.c                ó^   € RpRpV P                  R\        V4      R\        V4      .W4       R# )zà
L{postApplication} should change the UID and GID to the values
specified as numeric strings by the configuration after running
L{service.IService.privilegedStartService} and before running
L{service.IService.startService}.
éÒ  éá  ú--uidú--gidN)rŸ  rÁ   )rQ   rF   r0   s   &  r3   Ú.test_applicationStartsWithConfiguredNumericIDsÚEApplicationRunnerTests.test_applicationStartsWithConfiguredNumericIDss  s2   € ð ˆØˆØ×/Ñ/Ø”c˜#“h ¬¨S«Ð2°Cö	
r6   c                óp   € RpRpRpRp\        V P                  WW44       V P                  RVRV.W$4       R# )zå
L{postApplication} should change the UID and GID to the values
specified as user and group names by the configuration after running
L{service.IService.privilegedStartService} and before running
L{service.IService.startService}.
Úfoor£  Úbarr¤  r¥  r¦  N)rI   rD   rŸ  )rQ   rE   rF   r2   r0   s   &    r3   Ú+test_applicationStartsWithConfiguredNameIDsÚBApplicationRunnerTests.test_applicationStartsWithConfiguredNameIDs„  sD   € ð ˆØˆØˆØˆÜ˜$Ÿ*™* d°Ô<Ø×/Ñ/Ø�d˜G UÐ+¨Sö	
r6   c                ó°   € \        4       p\        P                  ! RRRRRR/4      pVP                  VRR4       V P	                  VP
                  R4       R# )z'
L{startReactor} calls L{reactor.run}.
r#   FrÄ   ÚdebugNz'startReactor did not call reactor.run())ÚDummyReactorr	   rK  r{  r¸   Úcalled©rQ   r²   r<  s   &  r3   Útest_startReactorRunsTheReactorÚ6ApplicationRunnerTests.test_startReactorRunsTheReactor˜  sR   € ô “.ˆÜ×&Ò&Ø˜˜z¨9°g¸uÐEó
ˆð 	×Ñ˜G T¨4Ô0Ø�‰˜Ÿ™Ð(QÖRr6   c                óÜ   € \        4       pV P                  \        RV4       \        P                  ! RRRRRR/4      pVP                  RRR4       V P                  VP                  4       R# )z>
L{ApplicationRunner} chooses a reactor if none is specified.
r²   r#   FrÄ   r¯  N)r°  rD   r   r	   rK  r{  r¸   r±  r²  s   &  r3   Ú*test_applicationRunnerChoosesReactorIfNoneÚAApplicationRunnerTests.test_applicationRunnerChoosesReactorIfNone£  s_   € ô “.ˆØ�
‰
”8˜Y¨Ô0Ü×&Ò&Ø˜˜z¨9°g¸uÐEó
ˆð 	×Ñ˜D $¨Ô-Ø�‰˜Ÿ™Ö'r6   c                óÈ   €  ! R R\         4      pV! 4       p\        P                  ! RRRRRR/4      pVP                  VRR4       V P	                  ^VP
                  4       R# )zO
If the reactor exits with a signal, the application runner caches
the signal.
c                   ó0   a € ] tR tRt o RtR tR tRtV tR# )Ú[ApplicationRunnerTests.test_applicationRunnerCapturesSignal.<locals>.DummyReactorWithSignaliµ  úg
A dummy reactor, providing a C{run} method, and setting the
_exitSignal attribute to a nonzero value.
c                ó   € R# ©z
Dummy method, does nothing.
Nra   rj   s   &r3   ÚinstallWakerÚhApplicationRunnerTests.test_applicationRunnerCapturesSignal.<locals>.DummyReactorWithSignal.installWaker»  rG  r6   c                ó   € ^V n         R# )z:
A fake run method setting _exitSignal to a nonzero value
N©Ú_exitSignalrj   s   &r3   r_  Ú_ApplicationRunnerTests.test_applicationRunnerCapturesSignal.<locals>.DummyReactorWithSignal.runÀ  s   € ð $%�Ö r6   rÁ  N©	rT   rU   rV   rW   rX   r¾  r_  rZ   r[   r\   s   @r3   ÚDummyReactorWithSignalrº  µ  s   ø‡ € ñò
÷
%ð %r6   rÅ  r#   FrÄ   r¯  N)r   r	   rK  r{  ÚassertEqualsrÂ  )rQ   rÅ  r²   r<  s   &   r3   Ú$test_applicationRunnerCapturesSignalÚ;ApplicationRunnerTests.test_applicationRunnerCapturesSignal¯  sb   € ô	%¤[ô 	%ñ" )Ó*ˆÜ×&Ò&Ø˜˜z¨9°g¸uÐEó
ˆð 	×Ñ˜G T¨4Ô0Ø×Ñ˜!˜V×/Ñ/Ö0r6   c                ó¾   €  ! R R4      pV! 4       p\         P                  ! RRRRRR/4      pVP                  VRR4       V P                  RVP                  4       R# )z€
The runner sets its _exitSignal instance attribute to None if
the reactor does not implement L{_ISupportsExitSignalCapturing}.
c                   ó0   a € ] tR tRt o RtR tR tRtV tR# )ÚiApplicationRunnerTests.test_applicationRunnerIgnoresNoSignal.<locals>.DummyReactorWithExitSignalAttributeiÓ  r»  c                ó   € R# r½  ra   rj   s   &r3   r¾  ÚvApplicationRunnerTests.test_applicationRunnerIgnoresNoSignal.<locals>.DummyReactorWithExitSignalAttribute.installWakerÙ  rG  r6   c                ó   € ^V n         R# )zR
A fake run method setting _exitSignal to a nonzero value
that should be ignored.
NrÁ  rj   s   &r3   r_  ÚmApplicationRunnerTests.test_applicationRunnerIgnoresNoSignal.<locals>.DummyReactorWithExitSignalAttribute.runÞ  s   € ð
 $%�Ö r6   rÁ  NrÄ  r\   s   @r3   Ú#DummyReactorWithExitSignalAttributerË  Ó  s   ø‡ € ñò
÷
%ð %r6   rÐ  r#   FrÄ   r¯  N)r	   rK  r{  rÆ  rÂ  )rQ   rÐ  r²   r<  s   &   r3   Ú%test_applicationRunnerIgnoresNoSignalÚ<ApplicationRunnerTests.test_applicationRunnerIgnoresNoSignalÍ  s`   € ÷	%ñ 	%ñ$ 6Ó7ˆÜ×&Ò&Ø˜˜z¨9°g¸uÐEó
ˆð 	×Ñ˜G T¨4Ô0Ø×Ñ˜$ × 2Ñ 2Ö3r6   )rŽ   rY  )rT   rU   rV   rW   rX   r1  rb  re  rŸ  r   Úgetattrr:   r§  r¬  r³  r¶  rÇ  rÑ  rZ   r[   r\   s   @r3   rV  rV  ú  s�   ø‡ € ñòò
ò,
:òG
ñR Ù�B˜ $Ó'Ô'Ø?óñ
ó	ð
ñ Ù�B˜ $Ó'Ô'Ø?óñ
ó	ð
ò 	Sò
(ò1÷<4ð 4r6   rV  c                   óz   a € ] tR tRt o Rt]! 4       tR tR tR t	R t
R tR tR	 tR
 tR tR tR tR tRtV tR# )Ú*UnixApplicationRunnerSetupEnvironmentTestsií  a‚  
Tests for L{UnixApplicationRunner.setupEnvironment}.

@ivar root: The root of the filesystem, or C{unset} if none has been
    specified with a call to L{os.chroot} (patched for this TestCase with
    L{UnixApplicationRunnerSetupEnvironmentTests.chroot}).

@ivar cwd: The current working directory of the process, or C{unset} if
    none has been specified with a call to L{os.chdir} (patched for this
    TestCase with L{UnixApplicationRunnerSetupEnvironmentTests.chdir}).

@ivar mask: The current file creation mask of the process, or C{unset} if
    none has been specified with a call to L{os.umask} (patched for this
    TestCase with L{UnixApplicationRunnerSetupEnvironmentTests.umask}).

@ivar daemon: A boolean indicating whether daemonization has been performed
    by a call to L{_twistd_unix.daemonize} (patched for this TestCase with
    L{UnixApplicationRunnerSetupEnvironmentTests}.
c                óÎ  a € S P                   S n        S P                   S n        S P                   S n        R S n        \
        P                  ! 4       S n        S P                  \
        RV 3R l4       S P                  \
        RV 3R l4       S P                  \
        RV 3R l4       \        \        P                  ! 4       4      S n        S P                  S P                  n        R# )Frm  c                 ó   <€ \        SR V 4      # )Úroot©Úsetattr©rü   rQ   s   &€r3   rú   ÚBUnixApplicationRunnerSetupEnvironmentTests.setUp.<locals>.<lambda>  s   ø€ ¬g°d¸FÀDÔ.Ir6   Úchdirc                 ó   <€ \        SR V 4      # )ÚcwdrÙ  rÛ  s   &€r3   rú   rÜ    s   ø€ ¬W°T¸5À$Ô-Gr6   rÉ   c                 ó   <€ \        SR V 4      # )ÚmaskrÙ  )rá  rQ   s   &€r3   rú   rÜ    s   ø€ ¬W°T¸6À4Ô-Hr6   N)ÚunsetrØ  rß  rá  Údaemonr:   r  r  rD   r    r   r‰   r<  Ú	daemonizerj   s   fr3   r1  Ú0UnixApplicationRunnerSetupEnvironmentTests.setUp  s�   ø€ Ø—J‘JˆŒ	Ø—:‘:ˆŒØ—J‘JˆŒ	ØˆŒÜ—9’9“;ˆŒØ�
‰
”2�xÔ!IÔJØ�
‰
”2�wÔ GÔHØ�
‰
”2�wÔ HÔIÜ+¬F×,@Ò,@Ó,BÓCˆŒØ $§¡ˆ�‰Ör6   c                óL   a € RS n         S P                  \        RV 3R l4       R# )z�
Indicate that daemonization has happened and change the PID so that the
value written to the pidfile can be tested in the daemonization case.
Tr  c                  ó*   <€ S P                   ^,           # )é   )r  rj   s   €r3   rú   ÚFUnixApplicationRunnerSetupEnvironmentTests.daemonize.<locals>.<lambda>  s   ø€ ¨¯©°A®r6   N)rã  rD   r:   ©rQ   r²   s   f&r3   rä  Ú4UnixApplicationRunnerSetupEnvironmentTests.daemonize  s   ø€ ð
 ˆŒØ�
‰
”2�xÔ!5Ö6r6   c                ó|   € V P                   P                  RRRRR4       V P                  V P                  R4       R# )z‰
L{UnixApplicationRunner.setupEnvironment} changes the root of the
filesystem if passed a non-L{None} value for the C{chroot} parameter.
ú/foo/barÚ.TN)r<  rq  r…   rØ  rj   s   &r3   Útest_chrootÚ6UnixApplicationRunnerSetupEnvironmentTests.test_chroot  s2   € ð
 	�‰×$Ñ$ Z°°d¸DÀ$ÔGØ×Ñ˜Ÿ™ JÖ/r6   c                ó�   € V P                   P                  RRRRR4       V P                  V P                  V P                  4       R# )z…
L{UnixApplicationRunner.setupEnvironment} does not change the root of
the filesystem if passed L{None} for the C{chroot} parameter.
Nrî  T)r<  rq  rë   rØ  râ  rj   s   &r3   Útest_noChrootÚ8UnixApplicationRunnerSetupEnvironmentTests.test_noChroot!  s4   € ð
 	�‰×$Ñ$ T¨3°°d¸DÔAØ�‰�d—i‘i §¡Ö,r6   c                ó|   € V P                   P                  RRRRR4       V P                  V P                  R4       R# )z‡
L{UnixApplicationRunner.setupEnvironment} changes the working directory
of the process to the path given for the C{rundir} parameter.
Nrí  T)r<  rq  r…   rß  rj   s   &r3   Útest_changeWorkingDirectoryÚFUnixApplicationRunnerSetupEnvironmentTests.test_changeWorkingDirectory)  s2   € ð
 	�‰×$Ñ$ T¨:°t¸TÀ4ÔHØ×Ñ˜Ÿ™ :Ö.r6   c           	     óè   € \        \        4       4      ;_uu_ 4        V P                  P                  RRRRR4       RRR4       V P	                  V P
                  4       R#   + '       g   i     L-; i)zw
L{UnixApplicationRunner.setupEnvironment} daemonizes the process if
C{False} is passed for the C{nodaemon} parameter.
Nrî  F)r   ÚFakeDaemonizingReactorr<  rq  r¸   rã  rj   s   &r3   Útest_daemonizeÚ9UnixApplicationRunnerSetupEnvironmentTests.test_daemonize1  sK   € ô
 Ô4Ó6×7Õ7Ø�K‰K×(Ñ(¨¨s°E¸4ÀÔF÷ 8à�‰˜Ÿ™Ö$÷ 8×7ús   œ A!Á!A1	c                óz   € V P                   P                  RRRRR4       V P                  V P                  4       R# )z~
L{UnixApplicationRunner.setupEnvironment} does not daemonize the
process if C{True} is passed for the C{nodaemon} parameter.
Nrî  T)r<  rq  r½   rã  rj   s   &r3   Útest_noDaemonizeÚ;UnixApplicationRunnerSetupEnvironmentTests.test_noDaemonize:  s0   € ð
 	�‰×$Ñ$ T¨3°°d¸DÔAØ×Ñ˜Ÿ™Ö%r6   c                ó.  € V P                  4       pV P                  P                  RRRRV4       \        VR4      ;_uu_ 4       p\	        VP                  4       4      pRRR4       V P                  XV P                  4       R#   + '       g   i     L.; i)zw
L{UnixApplicationRunner.setupEnvironment} writes the process's PID to
the file specified by the C{pidfile} parameter.
Nrî  TÚrb)r  r<  rq  r  ÚintÚreadr…   r  ©rQ   r  r  r  s   &   r3   Útest_nonDaemonPIDFileÚ@UnixApplicationRunnerSetupEnvironmentTests.test_nonDaemonPIDFileB  si   € ð
 —+‘+“-ˆØ�‰×$Ñ$ T¨3°°d¸GÔDÜ�'˜4× Ô  AÜ�a—f‘f“h“-ˆC÷ !à×Ñ˜˜dŸh™hÖ'÷ !× ús   ÁBÂB	c           	     óª  € V P                  4       p\        \        4       4      ;_uu_ 4        V P                  P	                  RRRRV4       RRR4       \        VR4      ;_uu_ 4       p\        VP                  4       4      pRRR4       V P                  XV P                  ^,           4       R#   + '       g   i     Lk; i  + '       g   i     LH; i)z�
L{UnixApplicationRunner.setupEnvironment} writes the daemonized
process's PID to the file specified by the C{pidfile} parameter if
C{nodaemon} is C{False}.
Nrî  Frÿ  )
r  r   rø  r<  rq  r  r   r  r…   r  r  s   &   r3   Útest_daemonPIDFileÚ=UnixApplicationRunnerSetupEnvironmentTests.test_daemonPIDFileM  sˆ   € ð —+‘+“-ˆÜÔ4Ó6×7Õ7Ø�K‰K×(Ñ(¨¨s°E¸4ÀÔI÷ 8ä�'˜4× Ô  AÜ�a—f‘f“h“-ˆC÷ !à×Ñ˜˜dŸh™h¨�lÖ+÷	 8×7úç × ús   ¬ B/Á(CÂ/B?	ÃC	c           	     óê   € \        \        4       4      ;_uu_ 4        V P                  P                  RRR^{R4       RRR4       V P	                  V P
                  ^{4       R#   + '       g   i     L.; i)zw
L{UnixApplicationRunner.setupEnvironment} changes the process umask to
the value specified by the C{umask} parameter.
Nrî  F©r   rø  r<  rq  r…   rá  rj   s   &r3   rÐ   Ú5UnixApplicationRunnerSetupEnvironmentTests.test_umaskZ  sO   € ô
 Ô4Ó6×7Õ7Ø�K‰K×(Ñ(¨¨s°E¸3ÀÔE÷ 8à×Ñ˜Ÿ™ CÖ(÷ 8×7úó   œ A"Á"A2	c                ó�   € V P                   P                  RRRRR4       V P                  V P                  V P                  4       R# )z±
L{UnixApplicationRunner.setupEnvironment} doesn't change the process
umask if L{None} is passed for the C{umask} parameter and C{True} is
passed for the C{nodaemon} parameter.
Nrî  T)r<  rq  rë   rá  râ  rj   s   &r3   Útest_noDaemonizeNoUmaskÚBUnixApplicationRunnerSetupEnvironmentTests.test_noDaemonizeNoUmaskc  s4   € ð 	�‰×$Ñ$ T¨3°°d¸DÔAØ�‰�d—i‘i §¡Ö,r6   c           	     óê   € \        \        4       4      ;_uu_ 4        V P                  P                  RRRRR4       RRR4       V P	                  V P
                  ^?4       R#   + '       g   i     L.; i)z¶
L{UnixApplicationRunner.setupEnvironment} changes the process umask to
C{0077} if L{None} is passed for the C{umask} parameter and C{False} is
passed for the C{nodaemon} parameter.
Nrî  Fr	  rj   s   &r3   Útest_daemonizedNoUmaskÚAUnixApplicationRunnerSetupEnvironmentTests.test_daemonizedNoUmaskl  sO   € ô Ô4Ó6×7Õ7Ø�K‰K×(Ñ(¨¨s°E¸4ÀÔF÷ 8à×Ñ˜Ÿ™ EÖ*÷ 8×7úr  )rß  rã  rá  r  rØ  r<  N)rT   rU   rV   rW   rX   r[  râ  r1  rä  rï  rò  rõ  rù  rü  r  r  rÐ   r  r  rZ   r[   r\   s   @r3   rÕ  rÕ  í  sT   ø‡ € ññ( ‹H€Eò
/ò7ò0ò-ò/ò%ò&ò	(ò,ò)ò-÷+ð +r6   rÕ  c                   óH   a € ] tR tRt o RtR tR tR tR tR t	R t
R	tV tR
# )Ú*UnixApplicationRunnerStartApplicationTestsiw  z6
Tests for L{UnixApplicationRunner.startApplication}.
c                ó¬  a€ \         P                  ! 4       pVP                  . R
O4       \        P                  ! R4      p\        V4      V n        . oV3R lp\        P                  ! V P                  P                  4      P                  p\        P                  ! V4      P                  pVP                  4       pVP                  R4       V P                  WE4       V P                  \
        RV4       V P                  \
        RR 4       V P                  \        RR 4       V P                  P!                  V4       V P                  S. RO4       R	# )zË
L{UnixApplicationRunner.startApplication} calls
L{UnixApplicationRunner.setupEnvironment} with the chroot, rundir,
nodaemon, umask, and pidfile parameters from the configuration it is
constructed with.
Útest_setupEnvironmentc                 ó0   <€ SP                  WW4V34       R # r(   )Úextend)rQ   rm  rn  ro  rÉ   r  rÚ   s   &&&&&&€r3   ÚfakeSetupEnvironmentÚ^UnixApplicationRunnerStartApplicationTests.test_setupEnvironment.<locals>.fakeSetupEnvironment—  s   ø€ Ø�K‰K˜¨¸'ÐBÖCr6   rQ   rq  rv  c                  ó   € R # r(   ra   ©ÚaÚkws   *,r3   rú   ÚRUnixApplicationRunnerStartApplicationTests.test_setupEnvironment.<locals>.<lambda>«  s   € ÉTr6   ÚstartApplicationc                  ó   € R # r(   ra   r  s   *,r3   rú   r  ¬  s   € ¹Tr6   N)	ú
--nodaemonrÍ   Ú0070z--chrootú/foo/chrootz--rundirú/foo/rundirú	--pidfileú/foo/pidfile)r#  r$  Té8   r&  )r   r‰   r®   r   r0  r    r<  ÚinspectÚ	signaturerq  Ú
parametersÚcopyÚpopr…   rD   r	   r  )rQ   rN   rc   r  ÚsetupEnvironmentParametersÚfakeSetupEnvironmentParametersrÚ   s   &     @r3   r  Ú@UnixApplicationRunnerStartApplicationTests.test_setupEnvironment}  s  ø€ ô ×&Ò&Ó(ˆØ×Ñò
ô	
ô ×)Ò)Ð*AÓBˆÜ+¨GÓ4ˆŒàˆõ	Dô &-×%6Ò%6Ø�K‰K×(Ñ(ó&
ç
‰*ð 	#ô *1×):Ò):Ø ó*
ç
‰*ð 	'ð *H×)LÑ)LÓ)NÐ&Ø&×*Ñ*¨6Ô2à×ÑÐ3ÔTà�
‰
Ô(Ð*<Ð>RÔSØ�
‰
Ô(Ð*:Ñ<QÔRØ�
‰
”3Ð*Ñ,AÔBØ�‰×$Ñ$ [Ô1à×Ñ˜ÒWÖXr6   c                ó~   a € V 3R lpS P                  \        RV4       \        / 4      pVP                  ^#^È^64       R# )zN
L{UnixApplicationRunner.shedPrivileges} switches the user ID
of the process.
c                 ót   <€ SP                  V ^È4       SP                  V^64       SP                  V^#4       R# )éÈ   N©r…   )rF   r0   ru  rQ   s   &&&€r3   ÚswitchUIDPassÚUUnixApplicationRunnerStartApplicationTests.test_shedPrivileges.<locals>.switchUIDPass·  s3   ø€ Ø×Ñ˜S #Ô&Ø×Ñ˜S "Ô%Ø×Ñ˜T 2Ö&r6   Ú	switchUIDN)rD   ró   r    rv  )rQ   r4  r<  s   f  r3   Útest_shedPrivilegesÚ>UnixApplicationRunnerStartApplicationTests.test_shedPrivileges±  s6   ø€ õ	'ð
 	�
‰
”< ¨mÔ<Ü& rÓ*ˆØ×Ñ˜b # rÖ*r6   c                óÎ   € R p\        / 4      pV P                  \        RV4       V P                  \        VP
                  ^#^ÈR4      pV P                  VP                  ^4       R# )z€
An unexpected L{OSError} when calling
L{twisted.scripts._twistd_unix.shedPrivileges}
terminates the process via L{SystemExit}.
c                 ó6   € \        \        P                  R 4      hr  r"  )rF   r0   ru  s   &&&r3   ÚswitchUIDFailÚZUnixApplicationRunnerStartApplicationTests.test_shedPrivilegesError.<locals>.switchUIDFailÇ  r  r6   r6  N)r    rD   ró   r¬   r­   rv  r…   rì   )rQ   r;  r<  Úexcs   &   r3   Útest_shedPrivilegesErrorÚCUnixApplicationRunnerStartApplicationTests.test_shedPrivilegesErrorÀ  sU   € ò	/ô ' rÓ*ˆØ�
‰
”< ¨mÔ<Ø×Ñ¤
¨F×,AÑ,AÀ2ÀsÈDÓQˆØ×Ñ˜Ÿ™ 1Ö%r6   c                óà  a aa€ \        S P                  VSVS4       V VV3R lpV V3R lpV V3R lpS P                  \        RV4       S P                  \        RV4       S P                  \        RV4       \        P
                  ! 4       p	V	P                  RR\        S4      R	V.4       \        P                  ! R
4      p
\        V	4      S n        \        V	4      pVP                  V
4       R# )zR
Common code for tests which try to pass the the UID to
L{UnixApplicationRunner}.
c                 óP   <€ SP                  V S4       SP                  VS4       R # r(   r3  )rF   r0   rQ   Ú	wantedGidÚ	wantedUids   &&€€€r3   Ú
initgroupsÚFUnixApplicationRunnerStartApplicationTests._setUID.<locals>.initgroupsÖ  s#   ø€ Ø×Ñ˜S )Ô,Ø×Ñ˜S )Ö,r6   c                 ó,   <€ SP                  V S4       R # r(   r3  )rF   rQ   rC  s   &€€r3   r¡  ÚBUnixApplicationRunnerStartApplicationTests._setUID.<locals>.setuidÚ  ó   ø€ Ø×Ñ˜S )Ö,r6   c                 ó,   <€ SP                  V S4       R # r(   r3  )r0   rQ   rB  s   &€€r3   ÚsetgidÚBUnixApplicationRunnerStartApplicationTests._setUID.<locals>.setgidÝ  rH  r6   rD  r¡  rJ  r!  r¥  r%  r  N)rI   rD   r   r:   r   r‰   r®   rÁ   r   r0  r    r<  r  )rQ   Ú
wantedUserrC  ÚwantedGrouprB  ÚpidFilerD  r¡  rJ  rN   rc   r<  s   f&f&f&      r3   Ú_setUIDÚ2UnixApplicationRunnerStartApplicationTests._setUIDÏ  s¿   ú€ ô
 	˜$Ÿ*™* j°)¸[È)ÔT÷	-ö	-ö	-ð 	�
‰
”4˜ zÔ2Ø�
‰
”2�x Ô(Ø�
‰
”2�x Ô(ä×&Ò&Ó(ˆØ×ÑØ˜7¤C¨	£N°KÀÐIô	
ô ×)Ò)Ð*AÓBˆÜ+¨GÓ4ˆŒÜ& wÓ/ˆØ×Ñ Ö,r6   c                óZ   € V P                  RRRRV P                  4       R,           4       R# )z�
Starting an application with L{UnixApplicationRunner} configured
with a UID and no GUID will result in the GUID being
set to the default GUID for that UID.
rª  i  r«  i’  z_test_setUidWithoutGid.pidN)rO  r  rj   s   &r3   Útest_setUidWithoutGidÚ@UnixApplicationRunnerStartApplicationTests.test_setUidWithoutGidí  s'   € ð 	�‰Ø�4˜  d§k¡k£mÐ6RÕ&Rö	
r6   c                ó  € \         P                  ! 4       pV P                  RVRRR4       V P                  4       pRP	                  W4      pV P                  W2^ ,          R,          4       V P                  ^\        V4      V4       R# )zb
If the specified UID is the same as the current UID of the process,
then a warning is displayed.
ÚmorefooÚmorebari÷  ztest_setUidSameAsCurrentUid.pidz\tried to drop privileges and setuid {} but uid is already {}; should we be root? Continuing.ÚmessageN)r:   r;   rO  ÚflushWarningsr±   r…   Úlen)rQ   Ú
currentUidÚwarningsShownÚexpectedWarnings   &   r3   Útest_setUidSameAsCurrentUidÚFUnixApplicationRunnerStartApplicationTests.test_setUidSameAsCurrentUid÷  s|   € ô
 —Y’Y“[ˆ
Ø�‰Ø�z 9¨dÐ4Uô	
ð ×*Ñ*Ó,ˆð-ß-3©V°JÓ-Kð 	ð 	×Ñ˜¸Õ*:¸9Õ*EÔFØ×Ñ˜œC Ó.°Ö>r6   r;  N)rT   rU   rV   rW   rX   r  r7  r>  rO  rR  r]  rZ   r[   r\   s   @r3   r  r  w  s/   ø‡ € ñò2Yòh+ò&ò-ò<
÷?ð ?r6   r  c                   ó0   a € ] tR tRt o RtR tR tRtV tR# )Ú#UnixApplicationRunnerRemovePIDTestsi
  z/
Tests for L{UnixApplicationRunner.removePID}.
c                óZ  € \        / 4      pV P                  4       p\        P                  ! V4       \        P                  P                  VR4      p\        VR4      P                  4        VP                  V4       V P                  \        P                  P                  V4      4       R# )zX
L{UnixApplicationRunner.removePID} deletes the file the name of
which is passed to it.
zfoo.pidr   N)r    r  r:   Úmakedirsrü   Újoinr  Úcloser~  r½   r÷   )rQ   r<  rü   r  s   &   r3   Útest_removePIDÚ2UnixApplicationRunnerRemovePIDTests.test_removePID  su   € ô
 ' rÓ*ˆØ�{‰{‹}ˆÜ
�Š�DÔÜ—'‘'—,‘,˜t YÓ/ˆÜˆW�cÓ× Ñ Ô"Ø×Ñ˜Ô!Ø×ÑœŸ™Ÿ™¨Ó0Ö1r6   c                ó  € \        / 4      pVP                  R4       V P                  \        4      pV P	                  \        V4      ^4       V P	                  V^ ,          P                  P                  \        P                  4       R# )zZ
Calling L{UnixApplicationRunner.removePID} with a non-existent filename
logs an OSError.
ÚfakepidN)	r    r~  ÚflushLoggedErrorsr  r…   rY  Úvaluer  ÚENOENT)rQ   r<  Úerrorss   &  r3   Útest_removePIDErrorsÚ8UnixApplicationRunnerRemovePIDTests.test_removePIDErrors  sb   € ô
 ' rÓ*ˆØ×Ñ˜Ô#Ø×'Ñ'¬Ó0ˆØ×Ñœ˜V› aÔ(Ø×Ñ˜ �Ÿ™×.Ñ.´·±Ö=r6   ra   N)	rT   rU   rV   rW   rX   re  rm  rZ   r[   r\   s   @r3   r`  r`  
  s   ø‡ € ñò2÷	>ð 	>r6   r`  c                   ó<   a € ] tR tRt o RtR tR tR tR tRt	V t
R# )	ÚFakeNonDaemonizingReactori)  a{  
A dummy reactor, providing C{beforeDaemonize} and C{afterDaemonize}
methods, but not announcing this, and logging whether the methods have been
called.

@ivar _beforeDaemonizeCalled: if C{beforeDaemonize} has been called or not.
@type _beforeDaemonizeCalled: C{bool}
@ivar _afterDaemonizeCalled: if C{afterDaemonize} has been called or not.
@type _afterDaemonizeCalled: C{bool}
c                ó"   € R V n         R V n        R# )FN)Ú_beforeDaemonizeCalledÚ_afterDaemonizeCalledrj   s   &r3   r{   Ú"FakeNonDaemonizingReactor.__init__5  s   € Ø&+ˆÔ#Ø%*ˆÖ"r6   c                ó   € R V n         R# ©TN)rr  rj   s   &r3   ÚbeforeDaemonizeÚ)FakeNonDaemonizingReactor.beforeDaemonize9  s
   € Ø&*ˆÖ#r6   c                ó   € R V n         R# rv  )rs  rj   s   &r3   ÚafterDaemonizeÚ(FakeNonDaemonizingReactor.afterDaemonize<  s
   € Ø%)ˆÖ"r6   c                ó   € R# )z
Skip event registration.
Nra   )rQ   rÚ   r  s   &*,r3   ÚaddSystemEventTriggerÚ/FakeNonDaemonizingReactor.addSystemEventTrigger?  rG  r6   )rs  rr  N)rT   rU   rV   rW   rX   r{   rw  rz  r}  rZ   r[   r\   s   @r3   rp  rp  )  s#   ø‡ € ñ	ò+ò+ò*÷ð r6   rp  c                   ó   € ] tR tRtRtRtR# )rø  iE  z‘
A dummy reactor, providing C{beforeDaemonize} and C{afterDaemonize}
methods, announcing this, and logging whether the methods have been called.
ra   N)rT   rU   rV   rW   rX   rZ   ra   r6   r3   rø  rø  E  s   † õr6   rø  c                   ó.   a € ] tR tRt o RtRtR tRtV tR# )r°  iM  zž
A dummy reactor, only providing a C{run} method and checking that it
has been called.

@ivar called: if C{run} has been called or not.
@type called: C{bool}
Fc                óN   € V P                   '       d   \        R4      hRV n         R# )zF
A fake run method, checking that it's been called one and only time.
zAlready calledTN)r±  ÚRuntimeErrorrj   s   &r3   r_  ÚDummyReactor.runX  s    € ð �;�;ˆ;ÜÐ/Ó0Ð0ØˆŽr6   )r±  N)	rT   rU   rV   rW   rX   r±  r_  rZ   r[   r\   s   @r3   r°  r°  M  s   ø‡ € ñð €F÷ð r6   r°  c                   ó  a € ] tR tRt o Rt]! ]'       * R4      R 4       tR t]! ]'       * R4      R 4       t	R t
]! ]'       * R4      R 4       t]! ]'       * R	4      R
 4       t]! ]'       * R	4      R 4       tR tR tR tR tRtV tR# )ÚAppProfilingTestsia  z
Tests for L{app.AppProfiler}.
zprofile module not availablec                óÌ  € \         P                  ! 4       pV P                  4       VR&   RVR&   \        P                  ! V4      p\        4       pVP                  V4       V P                  VP                  4       \        VR,          4      ;_uu_ 4       pVP                  4       pRRR4       V P                  RX4       V P                  RV4       R#   + '       g   i     L6; i)zt
L{app.ProfileRunner.run} should call the C{run} method of the reactor
and save profile data in the specified file.
r#   rÄ   NzDummyReactor.runúfunction calls©r   r‰   r  r	   rÂ   r°  r_  r¸   r±  r  r  r£   ©rQ   rŽ   rÄ   r²   r  Údatas   &     r3   Útest_profileÚAppProfilingTests.test_profilef  s¦   € ô ×%Ò%Ó'ˆØ ŸK™K›MˆˆyÑØ&ˆˆzÑÜ—?’? 6Ó*ˆÜ“.ˆà�‰�WÔà�‰˜Ÿ™Ô'Ü�&˜Õ#×$Ô$¨Ø—6‘6“8ˆD÷ %à�‰Ð(¨$Ô/Ø�‰Ð&¨Ö-÷ %×$úó   ÂCÃC#	c                ó   € \        4       pV P                  \        R V4      pV! V4      pVP                  4        VP	                  4        VP                  4       pV P                  RV4       V P                  RV4       R# )rè   r‡  z(run)N)r   rD   ÚsysÚprint_statsÚrestorer¯   r£   )rQ   Ú
statsClassr#   Úoutrè   ÚstatsrŠ  s   &&&    r3   Ú
_testStatsÚAppProfilingTests._testStatsz  sg   € Ü‹jˆð —‘œC ¨3Ó/ˆñ ˜7Ó#ˆØ×ÑÔØ�‰Ôà�|‰|‹~ˆØ�‰Ð&¨Ô-Ø�‰�g˜tÖ$r6   c                óP  € \         P                  ! 4       pV P                  4       VR&   RVR&   RVR&   \        P                  ! V4      p\        4       pVP                  V4       V P                  VP                  4       V P                  \        P                  VR,          4       R# )z€
With the C{savestats} option specified, L{app.ProfileRunner.run}
should save the raw stats object instead of a summary output.
r#   rÄ   TÚ	savestatsN©r   r‰   r  r	   rÂ   r°  r_  r¸   r±  r•  r$   ÚStats©rQ   rŽ   rÄ   r²   s   &   r3   Útest_profileSaveStatsÚ'AppProfilingTests.test_profileSaveStats‹  s~   € ô ×%Ò%Ó'ˆØ ŸK™K›MˆˆyÑØ&ˆˆzÑØ"ˆˆ{ÑÜ—?’? 6Ó*ˆÜ“.ˆà�‰�WÔà�‰˜Ÿ™Ô'Ø�‰œŸ™ f¨YÕ&7Ö8r6   c                ó
  € \         P                  P                  4       p\        P                  ! 4       pRVR&   \
        P                  ! V4      pR\         P                  R&    V P                  \        VP                  R4       \         P                  P                  4        \         P                  P                  V4       R#   \         P                  P                  4        \         P                  P                  T4       i ; i)zn
When the C{profile} module is not present, L{app.ProfilerRunner.run}
should raise a C{SystemExit} exception.
r#   rÄ   N©r�  Úmodulesr+  r   r‰   r	   rÂ   r¬   r­   r_  ÚclearÚupdate©rQ   ÚsavedModulesrŽ   rÄ   s   &   r3   Útest_withoutProfileÚ%AppProfilingTests.test_withoutProfile�  s­   € ô
 —{‘{×'Ñ'Ó)ˆä×%Ò%Ó'ˆØ&ˆˆzÑÜ—?’? 6Ó*ˆà!%Œ�‰�IÑð	-Ø×Ñœj¨(¯,©,¸Ô=ä�K‰K×ÑÔÜ�K‰K×Ñ˜|Ö,øô �K‰K×ÑÔÜ�K‰K×Ñ˜|Õ,úó   Á#!C Ã?Dc                ó¢  €  ! R R\         P                  4      pV P                  \         RV4       \        P                  ! 4       pV P                  4       VR&   RVR&   \        P                  ! V4      p\        4       p\        P                  pV P                  \        VP                  V4       V P                  \        P                  V4       R# )zm
When an error happens during the print of the stats, C{sys.stdout}
should be restored to its initial value.
c                   ó&   a € ] tR tRt o R tRtV tR# )ÚGAppProfilingTests.test_profilePrintStatsError.<locals>.ErroneousProfilei¶  c                ó   € \        R 4      h)ÚBoom©r‚  rj   s   &r3   r�  ÚSAppProfilingTests.test_profilePrintStatsError.<locals>.ErroneousProfile.print_stats·  s   € Ü" 6Ó*Ð*r6   ra   N)rT   rU   rV   rW   r�  rZ   r[   r\   s   @r3   ÚErroneousProfilerª  ¶  s   ø‡ € ÷+ð +r6   r¯  ÚProfiler#   rÄ   N)r#   r°  rD   r   r‰   r  r	   rÂ   r°  r�  rè   r¬   r‚  r_  rë   )rQ   r¯  rŽ   rÄ   r²   Ú	oldStdouts   &     r3   Útest_profilePrintStatsErrorÚ-AppProfilingTests.test_profilePrintStatsError¯  s“   € ô	+œwŸ™ô 	+ð 	�
‰
”7˜IÐ'7Ô8ä×%Ò%Ó'ˆØ ŸK™K›MˆˆyÑØ&ˆˆzÑÜ—?’? 6Ó*ˆÜ“.ˆä—J‘Jˆ	Ø×Ñœ,¨¯©°gÔ>Ø�‰”c—j‘j )Ö,r6   zcProfile module not availablec                óÌ  € \         P                  ! 4       pV P                  4       VR&   RVR&   \        P                  ! V4      p\        4       pVP                  V4       V P                  VP                  4       \        VR,          4      ;_uu_ 4       pVP                  4       pRRR4       V P                  RX4       V P                  RV4       R#   + '       g   i     L6; i)zu
L{app.CProfileRunner.run} should call the C{run} method of the
reactor and save profile data in the specified file.
r#   r%   rÄ   Nr_  r‡  rˆ  r‰  s   &     r3   Útest_cProfileÚAppProfilingTests.test_cProfileÆ  s¥   € ô ×%Ò%Ó'ˆØ ŸK™K›MˆˆyÑØ'ˆˆzÑÜ—?’? 6Ó*ˆÜ“.ˆà�‰�WÔà�‰˜Ÿ™Ô'Ü�&˜Õ#×$Ô$¨Ø—6‘6“8ˆD÷ %à�‰�e˜TÔ"Ø�‰Ð&¨Ö-÷ %×$úr�  c                óP  € \         P                  ! 4       pV P                  4       VR&   RVR&   RVR&   \        P                  ! V4      p\        4       pVP                  V4       V P                  VP                  4       V P                  \        P                  VR,          4       R# )z�
With the C{savestats} option specified,
L{app.CProfileRunner.run} should save the raw stats object
instead of a summary output.
r#   r%   rÄ   Tr˜  Nr™  r›  s   &   r3   Útest_cProfileSaveStatsÚ(AppProfilingTests.test_cProfileSaveStatsÚ  s~   € ô ×%Ò%Ó'ˆØ ŸK™K›MˆˆyÑØ'ˆˆzÑØ"ˆˆ{ÑÜ—?’? 6Ó*ˆÜ“.ˆà�‰�WÔà�‰˜Ÿ™Ô'Ø�‰œŸ™ f¨YÕ&7Ö8r6   c                ó
  € \         P                  P                  4       pR\         P                  R&   \        P                  ! 4       pRVR&   \
        P                  ! V4      p V P                  \        VP                  R4       \         P                  P                  4        \         P                  P                  V4       R#   \         P                  P                  4        \         P                  P                  T4       i ; i)zŠ
When the C{cProfile} module is not present,
L{app.CProfileRunner.run} should raise a C{SystemExit}
exception and log the C{ImportError}.
Nr%   rÄ   rŸ  r£  s   &   r3   Útest_withoutCProfileÚ&AppProfilingTests.test_withoutCProfileí  s­   € ô —{‘{×'Ñ'Ó)ˆØ"&Œ�‰�JÑä×%Ò%Ó'ˆØ'ˆˆzÑÜ—?’? 6Ó*ˆð	-Ø×Ñœj¨(¯,©,¸Ô=ä�K‰K×ÑÔÜ�K‰K×Ñ˜|Ö,øô �K‰K×ÑÔÜ�K‰K×Ñ˜|Õ,úr§  c                óà   € \         P                  ! 4       pV P                  4       VR&   RVR&   V P                  \        \
        P                  V4      pV P                  \        V4      R4       R# )zY
Check that L{app.AppProfiler} raises L{SystemExit} when given an
unknown profiler name.
r#   ÚfoobarrÄ   z!Unsupported profiler name: foobarN)	r   r‰   r  r¬   r­   r	   rÂ   r…   rÁ   )rQ   rŽ   Úerrors   &  r3   Útest_unknownProfilerÚ&AppProfilingTests.test_unknownProfilerÿ  sY   € ô
 ×%Ò%Ó'ˆØ ŸK™K›MˆˆyÑØ%ˆˆzÑà×!Ñ!¤*¬c¯o©o¸vÓFˆØ×Ñœ˜U›Ð%HÖIr6   c                ój   € \         P                  ! / 4      pV P                  VP                  R4       R# )zE
L{app.Profiler} defaults to the cprofile profiler if not specified.
ÚcprofileN©r	   rÂ   r…   rÄ   ©rQ   rÄ   s   & r3   Útest_defaultProfilerÚ&AppProfilingTests.test_defaultProfiler  s(   € ô —?’? 2Ó&ˆØ×Ñ˜×*Ñ*¨JÖ7r6   c                ón   € \         P                  ! RR/4      pV P                  VP                  R4       R# )zM
The case of the profiler name passed to L{app.AppProfiler} is not
relevant.
rÄ   ÚCprOfilerÃ  NrÄ  rÅ  s   & r3   Útest_profilerNameCaseInsentiveÚ0AppProfilingTests.test_profilerNameCaseInsentive  s-   € ô
 —?’? J°
Ð#;Ó<ˆØ×Ñ˜×*Ñ*¨JÖ7r6   ra   N)rT   rU   rV   rW   rX   r   r#   r‹  r•  rœ  r¥  r²  r%   rµ  r¸  r»  rÀ  rÆ  rÊ  rZ   r[   r\   s   @r3   r…  r…  a  sÄ   ø‡ € ññ �ŒKÐ7Ó8ñ.ó 9ð.ò&%ñ" �ŒKÐ7Ó8ñ9ó 9ð9ò"-ñ$ �ŒKÐ7Ó8ñ-ó 9ð-ñ, �ŒLÐ9Ó:ñ.ó ;ð.ñ& �ŒLÐ9Ó:ñ9ó ;ð9ò$-ò$
Jò8÷8ð 8r6   r…  c                óX   aa€ . o\         P                  oVV3R lpV ! \         RV4       S# )zû
Patch L{logger.textFileLogObserver} to record every call and keep a
reference to the passed log file for tests.

@param patch: a callback for patching (usually L{TestCase.patch}).

@return: the list that keeps track of the log files.
@rtype: C{list}
c                 ó>   <€ SP                  V 4       S! V .VO5/ VB # r(   rl  )ÚlogFilerÚ   ÚkwargsÚlogFilesÚoldFileLogObservers   &*,€€r3   ÚobserverÚ+_patchTextFileLogObserver.<locals>.observer(  s$   ø€ Ø�‰˜Ô Ù! 'Ð;¨DÒ;°FÑ;Ð;r6   ÚtextFileLogObserver)r   rÔ  )rD   rÒ  rÐ  rÑ  s   & @@r3   Ú_patchTextFileLogObserverrÕ    s/   ù€ ð €HÜ×3Ñ3Ðö<ñ 
Œ&Ð'¨Ô2Ø€Or6   c                óT   a€ . o ! V3R lR4      pV P                  \        RV4       S# )zi
Make fake syslog, and return list to which prefix and then log
messages will be appended if it is used.
c                   ó:   <a € ] tR tRt o V3R ltV3R ltRtV tR# )Ú(_setupSyslog.<locals>.fakesyslogobserveri7  c                ó*   <€ SP                  V4       R # r(   rl  )rQ   ÚprefixÚlogMessagess   &&€r3   r{   Ú1_setupSyslog.<locals>.fakesyslogobserver.__init__8  s   ø€ Ø×Ñ˜vÖ&r6   c                ó*   <€ SP                  V4       R # r(   rl  )rQ   Ú	eventDictrÛ  s   &&€r3   ÚemitÚ-_setupSyslog.<locals>.fakesyslogobserver.emit;  s   ø€ Ø×Ñ˜yÖ)r6   ra   N)rT   rU   rV   rW   r{   rß  rZ   r[   )r]   rÛ  s   @€r3   ÚfakesyslogobserverrØ  7  s   ù‡ € õ	'÷	*ó 	*r6   rá  ÚSyslogObserver)rD   Úsyslog)ÚtestCaserá  rÛ  s   & @r3   Ú_setupSyslogrå  0  s.   ø€ ð
 €K÷*ô *ð ‡N�N”6Ð+Ð-?Ô@ØÐr6   c                   óð   a € ] tR tRt o RtR tR tR tR tR t	R t
/ ]P                  3R	 ltR
 tR tR tR t]! ]'       * R4      ]! ]'       * R4      R 4       4       tR tR tR tR tR tR tRtV tR# )ÚAppLoggerTestsiB  zv
Tests for L{app.AppLogger}.

@ivar observers: list of observers installed during the tests.
@type observers: C{list}
c                óP   a € . S n         V 3R lpS P                  \        RV4       R# )zp
Override L{globaLogBeginner.beginLoggingTo} so that we can trace the
observers installed in C{self.observers}.
c                 ó|   <€ V  F4  pSP                   P                  V4       \        P                  ! V4       K6  	  R # r(   )Ú	observersr¤   r   ÚaddObserver)rê  rÒ  rQ   s   & €r3   ÚbeginLoggingToÚ,AppLoggerTests.setUp.<locals>.beginLoggingToQ  s-   ø€ Û%�Ø—‘×%Ñ% hÔ/Ü"×.Ò.¨xÖ8ó &r6   rì  N)rê  rD   r   )rQ   rì  s   f r3   r1  ÚAppLoggerTests.setUpJ  s%   ø€ ð
 ˆŒõ	9ð
 	�
‰
Ô$Ð&6¸ÖGr6   c                óX   € V P                    F  p\        P                  ! V4       K  	  R# )z!
Remove all installed observers.
N)rê  r   ÚremoveObserver©rQ   rÒ  s   & r3   ÚtearDownÚAppLoggerTests.tearDownX  s    € ð ŸœˆHÜ×-Ò-¨hÖ7ó 'r6   c                óH   € \        \        4       ! R R4      4       pV! 4       # )z¢
Make a new observer which captures all logs sent to it.

@return: An observer that stores all logs sent to it.
@rtype: Callable that implements L{ILogObserver}.
c                   ó*   a € ] tR tRt o . tR tRtV tR# )Ú2AppLoggerTests._makeObserver.<locals>.TestObserverig  c                ó<   € V P                   P                  V4       R # r(   )Ú_logsr¤   )rQ   Úevents   &&r3   Ú__call__Ú;AppLoggerTests._makeObserver.<locals>.TestObserver.__call__k  s   € Ø—
‘
×!Ñ! %Ö(r6   ra   N)rT   rU   rV   rW   rø  rú  rZ   r[   r\   s   @r3   ÚTestObserverrö  g  s   ø‡ € àˆE÷)ð )r6   rü  )r   r   )rQ   rü  s   & r3   Ú_makeObserverÚAppLoggerTests._makeObserver_  s*   € ô 
”\Ó	"÷	)ð 	)ó 
#ð	)ñ ‹~Ðr6   c                óè   € V P                  V P                  V.4       V P                  RVP                  ^ ,          R,          4       V P                  RVP                  ^,          R,          4       R# )zw
Ensure that initial C{twistd} logs are written to logs.

@param observer: The observer made by L{self._makeObserver).
ústarting upÚ
log_formatzreactor classN)r…   rê  r£   rø  rñ  s   &&r3   Ú_checkObserverÚAppLoggerTests._checkObserverp  sR   € ð 	×Ñ˜Ÿ™¨(¨Ô4Ø�‰�m X§^¡^°AÕ%6°|Õ%DÔEØ�‰�o x§~¡~°aÕ'8¸Õ'FÖGr6   c                óÀ   a€ \         P                  ! / 4      pV P                  4       oV3R lVn        VP                  ! \        4       4       V P                  S4       R# )z|
L{app.AppLogger.start} calls L{globalLogBeginner.addObserver}, and then
writes some messages about twistd and the reactor.
c                  ó   <€ S # r(   ra   ©rÒ  s   €r3   rú   Ú+AppLoggerTests.test_start.<locals>.<lambda>�  s   ø€ ©r6   N)r	   Ú	AppLoggerrý  Ú_getLogObserverrd   r   r  )rQ   r   rÒ  s   & @r3   Ú
test_startÚAppLoggerTests.test_startz  sE   ø€ ô
 —’˜rÓ"ˆØ×%Ñ%Ó'ˆÜ!1ˆÔØ�Š”]“_Ô%Ø×Ñ˜HÖ%r6   c                óØ   € \        4       pV P                  4       pVP                  \        V4       \        P
                  ! / 4      pVP                  ! V4       V P                  V4       R# )z•
When the L{ILogObserver} component is available on the application,
that object will be used as the log observer instead of constructing a
new one.
N)r   rý  ÚsetComponentr   r	   r  rd   r  )rQ   rc   rÒ  r   s   &   r3   Ú$test_startUsesApplicationLogObserverÚ3AppLoggerTests.test_startUsesApplicationLogObserver…  sQ   € ô $“oˆØ×%Ñ%Ó'ˆØ× Ñ ¤¨xÔ8Ü—’˜rÓ"ˆØ�Š�[Ô!Ø×Ñ˜HÖ%r6   c                óŽ   a€ V P                  4       oRV3R l/pVP                  V4       V! V4      pVP                  ! V4       S# )aÄ  
Set up an AppLogger which exercises the C{logger} configuration option.

@type application: L{Componentized}
@param application: The L{Application} object to pass to
    L{app.AppLogger.start}.
@type extraLogArgs: C{dict}
@param extraLogArgs: extra values to pass to AppLogger.
@type appLogger: L{AppLogger} class, or a subclass
@param appLogger: factory for L{AppLogger} instances.

@rtype: C{list}
@return: The logs accumulated by the log observer.
r   c                  ó   <€ S # r(   ra   r  s   €r3   rú   Ú7AppLoggerTests._setupConfiguredLogger.<locals>.<lambda>¤  s   ø€ ¡Xr6   )rý  r¢  rd   )rQ   rc   ÚextraLogArgsÚ	appLoggerÚlogArgsr   rÒ  s   &&&&  @r3   Ú_setupConfiguredLoggerÚ%AppLoggerTests._setupConfiguredLogger’  sE   ø€ ð" ×%Ñ%Ó'ˆØÔ-Ð.ˆØ�‰�|Ô$Ù˜7Ó#ˆØ�Š�[Ô!Øˆr6   c                óZ   € \        4       pV P                  V P                  V4      4       R# )zè
When the C{logger} key is specified in the configuration dictionary
(i.e., when C{--logger} is passed to twistd), the initial log observer
will be the log observer returned from the callable which the value
refers to in FQPN form.
N)r   r  r  rb   s   & r3   Ú#test_startUsesConfiguredLogObserverÚ2AppLoggerTests.test_startUsesConfiguredLogObserverª  s$   € ô $“oˆØ×Ñ˜D×7Ñ7¸ÓDÖEr6   c                óÞ   € V P                  4       p\        4       pVP                  \        V4       V P	                  V P                  V4      4       V P                  VP                  . 4       R# )zS
C{--logger} takes precedence over a L{ILogObserver} component set on
Application.
N)rý  r   r  r   r  r  r…   rø  )rQ   rÒ  rc   s   &  r3   Ú(test_configuredLogObserverBeatsComponentÚ7AppLoggerTests.test_configuredLogObserverBeatsComponent´  sV   € ð
 ×%Ñ%Ó'ˆÜ#“oˆØ× Ñ ¤¨xÔ8Ø×Ñ˜D×7Ñ7¸ÓDÔEØ×Ñ˜Ÿ™¨Ö,r6   c                óÂ   € . p\        4       pVP                  \        VP                  4       V P	                  V P                  V4      4       V P                  V. 4       R# )zY
C{--logger} takes precedence over a L{LegacyILogObserver} component
set on Application.
N)r   r  ÚLegacyILogObserverr¤   r  r  r…   )rQ   Únonlogsrc   s   &  r3   Ú.test_configuredLogObserverBeatsLegacyComponentÚ=AppLoggerTests.test_configuredLogObserverBeatsLegacyComponent¿  sN   € ð
 ˆÜ#“oˆØ× Ñ Ô!3°W·^±^ÔDØ×Ñ˜D×7Ñ7¸ÓDÔEØ×Ñ˜ "Ö%r6   c                ó@  € . pV P                  4       p\        4       pVP                  \        V4       VP                  \        VP
                  4       \        P                  ! / 4      pVP                  ! V4       V P                  V4       V P                  V. 4       R# )z_
A L{ILogObserver} takes precedence over a L{LegacyILogObserver}
component set on Application.
N)rý  r   r  r   r  r¤   r	   r  rd   r  r…   )rQ   r   rÒ  rc   r   s   &    r3   Ú.test_loggerComponentBeatsLegacyLoggerComponentÚ=AppLoggerTests.test_loggerComponentBeatsLegacyLoggerComponentÊ  s{   € ð
 ˆØ×%Ñ%Ó'ˆÜ#“oˆØ× Ñ ¤¨xÔ8Ø× Ñ Ô!3°W·^±^ÔDä—’˜rÓ"ˆØ�Š�[Ô!à×Ñ˜HÔ%Ø×Ñ˜ "Ö%r6   rÇ   zsyslog not availablec                ó¤   € \        V 4      p\        4       pV P                  V P                  VRR/\        4      4       V P                  V. 4       R# )zH
C{--logger} takes precedence over a C{--syslog} command line
argument.
rã  TN)rå  r   r  r  r!   r…   )rQ   Úlogsrc   s   &  r3   Ú%test_configuredLogObserverBeatsSyslogÚ4AppLoggerTests.test_configuredLogObserverBeatsSyslogÛ  sL   € ô ˜DÓ!ˆÜ#“oˆØ×ÑØ×'Ñ'¨°hÀÐ5EÄ}ÓUô	
ð 	×Ñ˜˜rÖ"r6   c                óÜ   € \        4       pV P                  4       pV P                  V P                  VRR/4      4       V P	                  \
        P                  P                  V4      4       R# )zI
C{--logger} takes precedence over a C{--logfile} command line
argument.
Úlogfilerü   N)r   r  r  r  r½   r:   rü   r÷   )rQ   rc   rü   s   &  r3   Ú&test_configuredLogObserverBeatsLogfileÚ5AppLoggerTests.test_configuredLogObserverBeatsLogfileé  sV   € ô
 $“oˆØ�{‰{‹}ˆØ×ÑØ×'Ñ'¨°iÀÐ5HÓIô	
ð 	×ÑœŸ™Ÿ™¨Ó-Ö.r6   c                óÜ  € \         P                  ! RR/4      p\        V P                  4      pVP                  ! 4        V P                  \        V4      ^4       V P                  V^ ,          \        P                  4       \         P                  ! RR/4      pVP                  ! 4        V P                  \        V4      ^4       V P                  V^,          \        P                  4       R# )zz
When logfile is empty or set to C{-}, L{app.AppLogger._getLogObserver}
returns a log observer pointing at C{sys.stdout}.
r+  Ú-Ú N)
r	   r  rÕ  rD   r	  r…   rY  rë   r�  rè   )rQ   r   rÐ  s   &  r3   Útest_getLogObserverStdoutÚ(AppLoggerTests.test_getLogObserverStdoutõ  s£   € ô
 —’ 	¨3Ð/Ó0ˆÜ,¨T¯Z©ZÓ8ˆà×ÒÔ à×Ñœ˜X›¨Ô*Ø�‰�h˜q•k¤3§:¡:Ô.ä—’ 	¨2˜Ó/ˆØ×ÒÔ à×Ñœ˜X›¨Ô*Ø�‰�h˜q•k¤3§:¡:Ö.r6   c                ó   € \        V P                  4      pV P                  4       p\        P                  ! RV/4      pVP                  4       pV P                  VP                  P                  4       V P                  \        V4      ^4       V P                  V^ ,          P                  \        P                  P                  V4      4       R# )z}
When passing the C{logfile} option, L{app.AppLogger._getLogObserver}
returns a log observer pointing at the specified path.
r+  N)rÕ  rD   r  r	   r  r	  Ú
addCleanupÚ_outFilerd  r…   rY  rü   r:   Úabspath)rQ   rÐ  ÚfilenameÚsutrÒ  s   &    r3   Útest_getLogObserverFileÚ&AppLoggerTests.test_getLogObserverFile  s‘   € ô
 -¨T¯Z©ZÓ8ˆØ—;‘;“=ˆÜ�mŠm˜Y¨Ð1Ó2ˆà×&Ñ&Ó(ˆØ�‰˜×)Ñ)×/Ñ/Ô0à×Ñœ˜X›¨Ô*Ø×Ñ˜ !�×)Ñ)¬2¯7©7¯?©?¸8Ó+DÖEr6   c                óX  a€ . o\        4       pV3R lpV P                  \        RV4       \        P                  ! / 4      pWn        VP                  ! 4        V P                  SV.4       VP                  ! 4        V P                  SV.4       V P                  VP
                  4       R# )z 
L{app.AppLogger.stop} removes the observer created in C{start}, and
reinitialize its C{_observer} so that if C{stop} is called several
times it doesn't break.
c                 ó*   <€ SP                  V 4       R # r(   rl  )rÒ  Úremoveds   &€r3   ÚremoveÚ(AppLoggerTests.test_stop.<locals>.remove   s   ø€ Ø�N‰N˜8Ö$r6   rð  N)	r[  rD   r   r	   r  Ú	_observerrE  r…   r�   )rQ   rÒ  r>  r   r=  s   &   @r3   Ú	test_stopÚAppLoggerTests.test_stop  sˆ   ø€ ð ˆÜ“8ˆõ	%ð 	�
‰
Ô%Ð'7¸Ô@Ü—’˜rÓ"ˆØ#ÔØ�ŠŒØ×Ñ˜ 8 *Ô-Ø�ŠŒØ×Ñ˜ 8 *Ô-Ø×Ñ˜&×*Ñ*Ö+r6   c                óv  aa€ . o\         P                  ! / 4      p\        \        4       ! V3R lR4      4       oV3R lVn        VP
                  ! \        4       4       V P                  R\        S^ ,          4      4       V P                  V P                  .4      pV P                  \        V4      ^ V4       R# )z\
L{app.AppLogger} using a legacy logger observer still works, wrapping
it in a compat shim.
c                   ó2   <a € ] tR tRt o RtV3R ltRtV tR# )Ú;AppLoggerTests.test_legacyObservers.<locals>.LoggerObserveri4  z@
An observer which implements the legacy L{LegacyILogObserver}.
c                ó*   <€ SP                  V4       R# )z
Add C{x} to the logs list.
Nrl  )rQ   Úxr'  s   &&€r3   rú  ÚDAppLoggerTests.test_legacyObservers.<locals>.LoggerObserver.__call__:  s   ø€ ð —‘˜A–r6   ra   N)rT   rU   rV   rW   rX   rú  rZ   r[   )r]   r'  s   @€r3   ÚLoggerObserverrE  4  s   ù‡ € ñ÷ó r6   rI  c                  ó   <€ S ! 4       # r(   ra   )rI  s   €r3   rú   Ú5AppLoggerTests.test_legacyObservers.<locals>.<lambda>@  s   ø€ ©.Ô*:r6   r   N)r	   r  r   r  Ú_observerFactoryrd   r   r£   r   rX  Útest_legacyObserversr…   rY  )rQ   r   ÚwarningsrI  r'  s   &  @@r3   rM  Ú#AppLoggerTests.test_legacyObservers,  s”   ù€ ð
 ˆÜ—’˜rÓ"ˆä	Ô'Ó	(÷		ó 		ó 
)ð		ô #;ˆÔØ�Š”]“_Ô%à�‰�mÔ%6°t¸AµwÓ%?Ô@Ø×%Ñ% t×'@Ñ'@Ð&AÓBˆØ×Ñœ˜X›¨¨8Ö4r6   c                óv  a€ . o\         P                  ! / 4      pV3R lVn        VP                  ! \	        4       4       V P                  R\        S^ ,          4      4       V P                  V P                  .4      pV P                  V^ ,          R,          R4       V P                  \        V4      ^V4       R# )z°
L{app.AppLogger} using a logger observer which does not implement
L{ILogObserver} or L{LegacyILogObserver} will be wrapped in a compat
shim and raise a L{DeprecationWarning}.
c                  ó   <€ S P                   # r(   rl  )r'  s   €r3   rú   ÚAAppLoggerTests.test_unmarkedObserversDeprecated.<locals>.<lambda>O  s	   ø€ ¨¯ªr6   r   rW  aZ  Passing a logger factory which makes log observers which do not implement twisted.logger.ILogObserver or twisted.python.log.ILogObserver to twisted.application.app.AppLogger was deprecated in Twisted 16.2. Please use a factory that produces twisted.logger.ILogObserver (or the legacy twisted.python.log.ILogObserver) implementing objects instead.N)r	   r  r	  rd   r   r£   r   rX  Ú test_unmarkedObserversDeprecatedr…   rY  )rQ   r   rN  r'  s   &  @r3   rS  Ú/AppLoggerTests.test_unmarkedObserversDeprecatedG  s–   ø€ ð ˆÜ—’˜rÓ"ˆÜ!4ˆÔØ�Š”]“_Ô%à�‰�mÔ%6°t¸AµwÓ%?Ô@à×%Ñ% t×'LÑ'LÐ&MÓNˆØ×ÑØ�Q�K˜	Õ"ð0ô	
ð 	×Ñœ˜X›¨¨8Ö4r6   )rê  N)rT   rU   rV   rW   rX   r1  rò  rý  r  r
  r  r	   r  r  r  r  r!  r$  r   ró   rã  r(  r,  r1  r9  rA  rM  rS  rZ   r[   r\   s   @r3   rç  rç  B  s¤   ø‡ € ñòHò8òò"Hò	&ò&ð )+°c·m±môò0Fò	-ò	&ò&ñ" �ÔÐ9Ó:Ù�ŒJÐ.Ó/ñ
#ó 0ó ;ð
#ò
/ò/ò&Fò,ò*5÷65ð 5r6   rç  c                   óp   a € ] tR tRt o RtR tR tR tR tR t	R t
]! ]'       * R	4      R
 4       tRtV tR# )ÚUnixAppLoggerTestsie  zg
Tests for L{UnixAppLogger}.

@ivar signals: list of signal handlers installed.
@type signals: C{list}
c                óP   a € . S n         V 3R lpS P                  \        RV4       R# )z[
Fake C{signal.signal} for not installing the handlers but saving them
in C{self.signals}.
c                 ó@   <€ SP                   P                  W34       R # r(   )Úsignalsr¤   )r  r  rQ   s   &&€r3   Ú
fakeSignalÚ,UnixAppLoggerTests.setUp.<locals>.fakeSignalu  s   ø€ Ø�L‰L×Ñ  Ö)r6   ÚsignalN)rY  rD   r\  )rQ   rZ  s   f r3   r1  ÚUnixAppLoggerTests.setUpn  s#   ø€ ð
 ˆŒõ	*ð 	�
‰
”6˜8 ZÖ0r6   c                ó¸  € \        V P                  4      p\        RRRR/4      pVP                  ! 4        V P	                  \        V4      ^4       V P                  V^ ,          \        P                  4       \        RRRR/4      pVP                  ! 4        V P	                  \        V4      ^4       V P                  V^,          \        P                  4       R# )z�
When non-daemonized and C{logfile} is empty or set to C{-},
L{UnixAppLogger._getLogObserver} returns a log observer pointing at
C{sys.stdout}.
r+  r/  ro  Tr0  N)	rÕ  rD   r!   r	  r…   rY  rë   r�  rè   )rQ   rÐ  r   s   &  r3   r1  Ú,UnixAppLoggerTests.test_getLogObserverStdoutz  s¤   € ô -¨T¯Z©ZÓ8ˆä 	¨3°
¸DÐAÓBˆØ×ÒÔ Ø×Ñœ˜X›¨Ô*Ø�‰�h˜q•k¤3§:¡:Ô.ä 	¨2¨z¸4Ð@ÓAˆØ×ÒÔ Ø×Ñœ˜X›¨Ô*Ø�‰�h˜q•k¤3§:¡:Ö.r6   c                óš   € \        RRRR/4      pV P                  \        VP                  4      pV P	                  \        V4      R4       R# )zg
When daemonized and C{logfile} is set to C{-},
L{UnixAppLogger._getLogObserver} raises C{SystemExit}.
r+  r/  ro  Fz&Daemons cannot log to stdout, exiting!N)r!   r¬   r­   r	  r…   rÁ   )rQ   r   r¿  s   &  r3   Útest_getLogObserverStdoutDaemonÚ2UnixAppLoggerTests.test_getLogObserverStdoutDaemonŒ  sD   € ô
  	¨3°
¸EÐBÓCˆØ×!Ñ!¤*¨f×.DÑ.DÓEˆØ×Ñœ˜U›Ð%MÖNr6   c                óÆ  a€ \        V P                  4      pV P                  4       p\        RV/4      pVP	                  4       pV P                  VP                  P                  4       V P                  \        V4      ^4       V P                  V^ ,          P                  \        P                  P                  V4      4       V P                  \        V P                  4      ^4       V P                  V P                  ^ ,          ^ ,          \        P                  4       \!        4       oV3R lpWQ^ ,          n        V P                  ^ ,          ^,          pV! RR4       S# )z³
When C{logfile} contains a file name, L{app.AppLogger._getLogObserver}
returns a log observer pointing at the specified path, and a signal
handler rotating the log is installed.
r+  c                  ó*   <€ S P                  R 4       R # r(   )Úcallback)Úds   €r3   ÚrotateÚ:UnixAppLoggerTests.test_getLogObserverFile.<locals>.rotateª  s   ø€ Ø�J‰J�tÖr6   N)rÕ  rD   r  r!   r	  r4  r5  rd  r…   rY  rü   r:   r6  rY  r\  ÚSIGUSR1r   rg  )rQ   rÐ  r7  r8  rÒ  rg  Ú	rotateLogrf  s   &      @r3   r9  Ú*UnixAppLoggerTests.test_getLogObserverFile•  s  ø€ ô -¨T¯Z©ZÓ8ˆØ—;‘;“=ˆÜ˜Y¨Ð1Ó2ˆà×&Ñ&Ó(ˆØ�‰˜×)Ñ)×/Ñ/Ô0à×Ñœ˜X›¨Ô*Ø×Ñ˜ !�×)Ñ)¬2¯7©7¯?©?¸8Ó+DÔEà×Ñœ˜TŸ\™\Ó*¨AÔ.Ø×Ñ˜Ÿ™ a�¨Õ+¬V¯^©^Ô<ä‹Jˆõ	ð $��Ôà—L‘L •O AÕ&ˆ	Ù�$˜ÔØˆr6   c                ó  a € V 3R lpS P                  \        RV4       S P                  4       p\        RV/4      pVP	                  4       pS P                  VP                  P                  4       S P                  S P                  . 4       R# )za
If a signal handler is already installed,
L{UnixAppLogger._getLogObserver} doesn't override it.
c                 óX   <€ SP                  V \        P                  4       \        4       # r(   )r…   r\  ri  r[  )r  rQ   s   &€r3   ÚfakeGetSignalÚVUnixAppLoggerTests.test_getLogObserverDontOverrideSignalHandler.<locals>.fakeGetSignal¹  s   ø€ Ø×Ñ˜S¤&§.¡.Ô1Ü“8ˆOr6   Ú	getsignalr+  N)
rD   r\  r  r!   r	  r4  r5  rd  r…   rY  )rQ   rn  r7  r8  rÒ  s   f    r3   Ú,test_getLogObserverDontOverrideSignalHandlerÚ?UnixAppLoggerTests.test_getLogObserverDontOverrideSignalHandler³  sn   ø€ õ	ð 	�
‰
”6˜;¨Ô6Ø—;‘;“=ˆÜ˜Y¨Ð1Ó2ˆà×&Ñ&Ó(ˆØ�‰˜×)Ñ)×/Ñ/Ô0à×Ñ˜Ÿ™ rÖ*r6   c                óp  € \        V P                  4      p\        RRRR/4      pVP                  ! 4       pV P	                  VP
                  P                  4       V P                  \        V4      ^4       V P                  V^ ,          P                  \        P                  P                  R4      4       R# )z–
When daemonized and C{logfile} is empty, the observer returned by
L{UnixAppLogger._getLogObserver} points at C{twistd.log} in the current
directory.
r+  r0  ro  Fz
twistd.logN)rÕ  rD   r!   r	  r4  r5  rd  r…   rY  rü   r:   r6  )rQ   rÐ  r   rÒ  s   &   r3   Útest_getLogObserverDefaultFileÚ1UnixAppLoggerTests.test_getLogObserverDefaultFileÆ  s†   € ô -¨T¯Z©ZÓ8ˆÜ 	¨2¨z¸5ÐAÓBˆØ×)Ò)Ó+ˆØ�‰˜×)Ñ)×/Ñ/Ô0à×Ñœ˜X›¨Ô*Ø×Ñ˜ !�×)Ñ)¬2¯7©7¯?©?¸<Ó+HÖIr6   rÇ   c                óÂ   € \        V 4      p\        RRRR/4      pVP                  ! 4       pV P                  VR.4       V! RR/4       V P                  VRRR/.4       R# )zz
If C{syslog} is set to C{True}, L{UnixAppLogger._getLogObserver} starts
a L{syslog.SyslogObserver} with given C{prefix}.
rã  TrÚ  ztest-prefixr  ÚbN)rå  r!   r	  r…   )rQ   r'  r   rÒ  s   &   r3   Útest_getLogObserverSyslogÚ,UnixAppLoggerTests.test_getLogObserverSyslogÔ  sf   € ô ˜DÓ!ˆÜ ¨$°¸-ÐHÓIˆØ×)Ò)Ó+ˆØ×Ñ˜ ˜Ô/Ù�#�s�ÔØ×Ñ˜ °°S¨zÐ:Ö;r6   )rY  N)rT   rU   rV   rW   rX   r1  r1  ra  r9  rq  rt  r   ró   rx  rZ   r[   r\   s   @r3   rV  rV  e  sI   ø‡ € ñò
1ò/ò$Oòò<+ò&Jñ �ÔÐ9Ó:ñ
<ó ;ö
<r6   rV  z!twistd unix support not availablec                   ó„   a € ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tRtV tR# )ÚDaemonizeTestsiâ  z@
Tests for L{_twistd_unix.UnixApplicationRunner} daemonization.
c                óÌ  € \        4       V n        \        P                  ! 4       V n        V P                  \        R V P                  4       \        P                  V P                  4      V n        \        P                  ! R4      V P                  n        \        P                  V P                  n        \        P                  V P                  n        R V P                  n        R# )r:   r,  c                  ó   € R # r(   ra   )rÚ   s   *r3   rú   Ú&DaemonizeTests.setUp.<locals>.<lambda>ð  s   € ±r6   N)r   Úmockosr   r‰   rŽ   rD   ró   r    r<  r   r0  rc   r�  rè   ry  Ústderrrz  r{  rj   s   &r3   r1  ÚDaemonizeTests.setUpè  sˆ   € Ü“hˆŒÜ×*Ò*Ó,ˆŒØ�
‰
”<  t§{¡{Ô3Ü"×8Ñ8¸¿¹ÓEˆŒÜ")×"5Ò"5°eÓ"<ˆ�‰ÔÜ #§
¡
ˆ�‰ÔÜ #§
¡
ˆ�‰ÔÙ#5ˆ�‰Ö r6   c                óH  € \        \        4       4      ;_uu_ 4        V P                  P                  4        RRR4       V P	                  V P
                  P                  . RO4       V P	                  V P
                  P                  RR.4       R#   + '       g   i     Lb; i)z_
When double fork succeeded in C{daemonize}, the child process writes
B{0} to the status pipe.
Néþÿÿÿ)©rÝ  rî  ©rÉ   é?   ©ÚforkTÚsetsidr‡  )r  rƒ  ó   0©Úunlinkz
twistd.pidéýÿÿÿ)r   rø  r<  rn   r…   r  ÚactionsÚclosedrj   s   &r3   Útest_successÚDaemonizeTests.test_successò  sq   € ô
 Ô4Ó6×7Õ7Ø�K‰K×'Ñ'Ô)÷ 8à×ÑØ�K‰K×Ñòô	
ð 	×Ñ˜Ÿ™×+Ñ+¨b°"¨XÖ6÷ 8×7ús   œBÂB!	c                óª  € RV P                   n        RV P                   n        \        \	        4       4      ;_uu_ 4        V P                  \        V P                  P                  4       RRR4       V P                  V P                   P                  . RO4       V P                  V P                   P                  R.4       R#   + '       g   i     La; i)zp
The parent process initiating the C{daemonize} call reads data from the
status pipe and then exit the process.
FrŠ  Néÿÿÿÿ)r„  r…  r‡  ©r  r“  éd   ©Úexité    r‹  )r  ÚchildÚreadDatar   rø  r¬   ÚSystemErrorr<  rn   r…   rŽ  r�  rj   s   &r3   Útest_successInParentÚ#DaemonizeTests.test_successInParent  s‘   € ð
 "ˆ�‰ÔØ#ˆ�‰ÔÜÔ4Ó6×7Õ7Ø×Ñœk¨4¯;©;×+FÑ+FÔG÷ 8à×ÑØ�K‰K×Ñòô
	
ð 	×Ñ˜Ÿ™×+Ñ+¨b¨TÖ2÷ 8×7ús   ¾+CÃC	c                ó¢  a€ . oV3R lpWP                   n        \        \        4       4      ;_uu_ 4        V P                  P                  4        RRR4       V P                  V P                   P                  . RO4       V P                  V P                   P                  RR.4       V P                  RR.S4       R#   + '       g   i     Lv; i)zj
If the C{os.write} call to the status pipe raises an B{EINTR} error,
the process child retries to write.
c                 ó~   <€ SP                  W34       \        S4      ^8X  d   \        \        P                  4      hR# )rè  N©r¤   rY  r  r  ÚEINTR)ÚfdrŠ  Úwrittens   &&€r3   ÚraisingWriteÚ6DaemonizeTests.test_successEINTR.<locals>.raisingWrite$  s1   ø€ Ø�N‰N˜B˜:Ô&Ü�7‹|˜qÔ ÜœeŸk™kÓ*Ð*ñ !r6   N)r„  r…  r‡  r‰  r‡  r‹  r�  rƒ  )rƒ  rŠ  )	r  r  r   rø  r<  rn   r…   rŽ  r�  )rQ   r¤  r£  s   & @r3   Útest_successEINTRÚ DaemonizeTests.test_successEINTR  s�   ø€ ð
 ˆõ	+ð
 )�‰ÔÜÔ4Ó6×7Õ7Ø�K‰K×'Ñ'Ô)÷ 8à×ÑØ�K‰K×Ñòô
	
ð 	×Ñ˜Ÿ™×+Ñ+¨b°"¨XÔ6Ø×Ñ˜* jÐ1°7Ö;÷ 8×7ús   µB>Â>C	c                óâ  a€ . oV3R lpWP                   n        RV P                   n        \        \	        4       4      ;_uu_ 4        V P                  \        V P                  P                  4       RRR4       V P                  V P                   P                  . RO4       V P                  V P                   P                  R.4       V P                  RR.S4       R#   + '       g   i     Lu; i)zg
If the C{os.read} call on the status pipe raises an B{EINTR} error, the
parent child retries to read.
c                 ó~   <€ SP                  W34       \        S4      ^8X  d   \        \        P                  4      hR# )rè  rŠ  r   )r¢  Úsizer  s   &&€r3   ÚraisingReadÚ=DaemonizeTests.test_successInParentEINTR.<locals>.raisingReadA  s.   ø€ Ø�K‰K˜˜
Ô#Ü�4‹y˜AŒ~ÜœeŸk™kÓ*Ð*Ùr6   FN)r„  r…  r‡  r–  r‹  r“  )r“  r•  )r  r  r™  r   rø  r¬   r›  r<  rn   r…   rŽ  r�  )rQ   r«  r  s   & @r3   Útest_successInParentEINTRÚ(DaemonizeTests.test_successInParentEINTR:  s±   ø€ ð
 ˆõ	ð '�‰ÔØ!ˆ�‰ÔÜÔ4Ó6×7Õ7Ø×Ñœk¨4¯;©;×+FÑ+FÔG÷ 8à×ÑØ�K‰K×Ñòô		
ð 	×Ñ˜Ÿ™×+Ñ+¨b¨TÔ2Ø×Ñ˜) YÐ/°Ö6÷ 8×7ús   Á+CÃC.	c                ó
  a€  ! V3R lR\         P                  4      pV! 4       pVP                  V P                  P                  4       \        \        4       4      ;_uu_ 4        V P                  \        V P                  P                  4       RRR4       V P                  V P                  P                  RRRRRRR	V3R
.4       V P                  V P                  P                  RR	.4       R#   + '       g   i     Lj; i)z–
Assert L{UnixApplicationRunner.postApplication} writes
C{reported} to its status pipe if the service raises an
exception whose message is C{raised}.
c                   ó.   <a € ] tR tRt o V3R ltRtV tR# )Ú6DaemonizeTests.assertErrorWritten.<locals>.FakeServicei_  c                ó   <€ \        S4      hr(   r­  )rQ   Úraiseds   &€r3   r”  ÚCDaemonizeTests.assertErrorWritten.<locals>.FakeService.startService`  s   ø€ Ü" 6Ó*Ð*r6   ra   N)rT   rU   rV   rW   r”  rZ   r[   )r]   r³  s   @€r3   r›  r±  _  s   ù‡ € ÷+ó +r6   r›  Nr‰  r  r„  r…  r‡  rƒ  r‹  r�  )r   rO   rŠ  r<  rc   r   rø  r¬   r‚  rn   r…   r  rŽ  r�  )rQ   r³  Úreportedr›  ÚerrorServices   &f&  r3   ÚassertErrorWrittenÚ!DaemonizeTests.assertErrorWrittenX  sÇ   ø€ ÷	+œ'Ÿ/™/ô 	+ñ #“}ˆØ×%Ñ% d§k¡k×&=Ñ&=Ô>äÔ4Ó6×7Õ7Ø×Ñœl¨D¯K©K×,GÑ,GÔH÷ 8à×ÑØ�K‰K×ÑàØ ØØØØ˜"˜hÐ'Ø(ðô	
ð 	×Ñ˜Ÿ™×+Ñ+¨b°"¨XÖ6÷ 8×7ús   Á%+C2Ã2D	c                ó,   € V P                  RRR7       R# )zl
If an error happens during daemonization, the child process writes the
exception error to the status pipe.
zSomething is wrongs"   1 RuntimeError: Something is wrong©r³  rµ  N©r·  rj   s   &r3   Ú
test_errorÚDaemonizeTests.test_errorv  s   € ð
 	×ÑØ'Ð2Wð 	 ö 	
r6   c                ó,   € V P                  RRR7       R# )z›
If an error happens during daemonization, and that error's
message is Unicode, the child encodes the message as ascii
with backslash Unicode code points.
u   â€¢s   1 RuntimeError: \u2022rº  Nr»  rj   s   &r3   Útest_unicodeErrorÚ DaemonizeTests.test_unicodeError  s   € ð 	×Ñ xÐ:TÐÖUr6   c                ó&  € RV P                   n        WP                   n        \        4       pV P	                  \
        RV4       \        \        4       4      ;_uu_ 4        V P                  \        V P                  P                  4       RRR4       V P                  VP                  4       V4       V P                  V P                   P                  V4       V P                  V P                   P                  R.4       R#   + '       g   i     L; i)zß
Make L{os.read} appear to return C{readData}, and assert that
L{UnixApplicationRunner.postApplication} writes
C{errorMessage} to standard error and executes the calls
against L{os} functions specified in C{mockOSActions}.
FÚ
__stderr__Nr“  )r  r™  rš  r   rD   r�  r   rø  r¬   r›  r<  rn   r…   r¯   rŽ  r�  )rQ   rš  ÚerrorMessageÚmockOSActionsÚerrorIOs   &&&& r3   ÚassertErrorInParentBehaviorÚ*DaemonizeTests.assertErrorInParentBehavior‡  s·   € ð "ˆ�‰ÔØ'�‰ÔÜ“*ˆØ�
‰
”3˜ gÔ.ÜÔ4Ó6×7Õ7Ø×Ñœk¨4¯;©;×+FÑ+FÔG÷ 8à×Ñ˜×)Ñ)Ó+¨\Ô:Ø×Ñ˜Ÿ™×,Ñ,¨mÔ<Ø×Ñ˜Ÿ™×+Ñ+¨b¨TÖ2÷	 8×7ús   Á+D Ä D	c                ó2   € V P                  RR. ROR7       R# )z­
When the child writes an error message to the status pipe
during daemonization, the parent writes the repr of the
message to C{stderr} and exits with non-zero status code.
s    1 Exception: An identified errorzgAn error has occurred: b'Exception: An identified error'
Please look at log file for more information.
©rš  rÃ  rÄ  N©r„  r…  r‡  r”  )r—  rè  r‹  ©rÆ  rj   s   &r3   Útest_errorInParentÚ!DaemonizeTests.test_errorInParent˜  s%   € ð 	×(Ñ(Ø8ðBòð 	)ö 	
r6   c                ó2   € V P                  RR. ROR7       R# )z¸
When the child writes a non-ASCII error message to the status
pipe during daemonization, the parent writes the repr of the
message to C{stderr} and exits with a non-zero status code.
s   1 Exception: ÿzXAn error has occurred: b'Exception: \xff'
Please look at log file for more information.
rÉ  NrÊ  rË  rj   s   &r3   Útest_nonASCIIErrorInParentÚ)DaemonizeTests.test_nonASCIIErrorInParent®  s%   € ð 	×(Ñ(Ø)ðBòð 	)ö 	
r6   c                óv   € RpRP                  R4      pV P                  VRP                  V4      . ROR7       R# )zâ
When the child writes a non-ASCII error message to the status
pipe during daemonization, and that message is too longer, the
parent writes the repr of the truncated message to C{stderr}
and exits with a non-zero status code.
zb'RuntimeError: {}'zHAn error has occurred: {}
Please look at log file for more information.
rÉ  Nód   1 RuntimeError: \u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022zb\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022rÊ  )r±   rÆ  )rQ   ÚtruncatedMessageÚreportedMessages   &  r3   Ú&test_errorInParentWithTruncatedUnicodeÚ5DaemonizeTests.test_errorInParentWithTruncatedUnicodeÄ  sL   € ð AÐð 0×6Ñ6°ÓGˆØ×(Ñ(Ø%ðBßBHÁ&Ø#óCòð 	)ö 	
r6   c                ó,   € V P                  RRR7       R# )zc
If an error occurs during daemonization and its message is too
long, it's truncated by the child.
rº  NÚÈxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxsd   1 RuntimeError: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxr»  rj   s   &r3   Útest_errorMessageTruncatedÚ)DaemonizeTests.test_errorMessageTruncatedá  s   € ð
 	×ÑØÐ'Fð 	 ö 	
r6   c                ó,   € V P                  RRR7       R# )zž
If an error occurs during daemonization and its message is
unicode and too long, it's truncated by the child, even if
this splits a unicode escape sequence.
rº  NuZ   â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢rÒ  r»  rj   s   &r3   Ú!test_unicodeErrorMessageTruncatedÚ0DaemonizeTests.test_unicodeErrorMessageTruncatedê  s   € ð 	×ÑØ Ø:ð 	 ö 	
r6   c                ó¼   € \        4       pV P                  P                  V4       V P                  VP                  4       V P                  VP
                  4       R# )z˜
C{daemonize} indeed calls L{IReactorDaemonize.beforeDaemonize} and
L{IReactorDaemonize.afterDaemonize} if the reactor implements
L{IReactorDaemonize}.
N)rø  r<  rä  r¸   rr  rs  rê  s   & r3   Útest_hooksCalledÚDaemonizeTests.test_hooksCalledõ  sB   € ô )Ó*ˆØ�‰×Ñ˜gÔ&Ø�‰˜×6Ñ6Ô7Ø�‰˜×5Ñ5Ö6r6   c                ó¼   € \        4       pV P                  P                  V4       V P                  VP                  4       V P                  VP
                  4       R# )z 
C{daemonize} does NOT call L{IReactorDaemonize.beforeDaemonize} or
L{IReactorDaemonize.afterDaemonize} if the reactor does NOT implement
L{IReactorDaemonize}.
N)rp  r<  rä  r½   rr  rs  rê  s   & r3   Útest_hooksNotCalledÚ"DaemonizeTests.test_hooksNotCalled   sF   € ô ,Ó-ˆØ�‰×Ñ˜gÔ&Ø×Ñ˜×7Ñ7Ô8Ø×Ñ˜×6Ñ6Ö7r6   )rŽ   r  r<  N)rT   rU   rV   rW   rX   r1  r�  rœ  r¦  r­  r·  r¼  r¿  rÆ  rÌ  rÏ  rÕ  rÙ  rÜ  rß  râ  rZ   r[   r\   s   @r3   r{  r{  â  s`   ø‡ € ñò6ò7ò*3ò,<ò:7ò<7ò<
òVò3ò"
ò,
ò,
ò:
ò	
ò	7÷	8ð 	8r6   r{  c                   óX   a € ] tR tRt o Rt]R 4       t]P                  R 4       tRtV t	R# )ÚSignalCapturingMemoryReactori  z}
MemoryReactor that implements the _ISupportsExitSignalCapturing interface,
all other operations identical to MemoryReactor.
c                ó   € V P                   # r(   ©Ú_valrj   s   &r3   rÂ  Ú(SignalCapturingMemoryReactor._exitSignal  s   € à�y‰yÐr6   c                ó   € Wn         R # r(   rç  )rQ   Úvals   &&r3   rÂ  ré    s   € àŽ	r6   rç  N)
rT   rU   rV   rW   rX   ÚpropertyrÂ  ÚsetterrZ   r[   r\   s   @r3   rå  rå    s8   ø‡ € ñð
 ñó ðð ×Ññó ör6   rå  c                   óF   a a€ ] tR tRt oRt]tV 3R ltR tR t	Rt
VtV ;t# )ÚStubApplicationRunnerWithSignali  zÛ
An application runner that uses a SignalCapturingMemoryReactor and
has a _signalValue attribute that it will set in the reactor.

@ivar _signalValue: The signal value to set on the reactor's _exitSignal
    attribute.
c                ó4   <€ \         SV `  V4       R V n        R # r(   )Úsuperr{   Ú_signalValue)rQ   rŽ   Ú	__class__s   &&€r3   r{   Ú(StubApplicationRunnerWithSignal.__init__'  s   ø€ Ü‰Ñ˜Ô Ø ˆÖr6   c                ó   € R# )z
Does nothing.
Nra   rj   s   &r3   rk   Ú.StubApplicationRunnerWithSignal.preApplication+  rG  r6   c                óš   € \        4       pV P                  Vn        V P                  V\        P
                  \        P                  4       R# )zH
Instantiate a SignalCapturingMemoryReactor and start it
in the runner.
N)rå  rò  rÂ  r{  r�  rè   r€  rê  s   & r3   rn   Ú/StubApplicationRunnerWithSignal.postApplication0  s4   € ô
 /Ó0ˆØ"×/Ñ/ˆÔØ×Ñ˜'¤3§:¡:¬s¯z©zÖ:r6   )rò  )rT   rU   rV   rW   rX   r_   rp   r{   rk   rn   rZ   r[   Ú__classcell__)ró  r]   s   @@r3   rï  rï    s%   ù‡ € ñð &€Mõ!ò÷
;ò ;r6   rï  c                ó   a € V 3R lpV# )a)  
Create a factory function to instantiate a
StubApplicationRunnerWithSignal that will report signum as the captured
signal..

@param signum: The integer signal number or None
@type signum: C{int} or C{None}

@return: A factory function to create stub runners.
@rtype: stubApplicationRunnerFactory
c                ó,   <€ \        V 4      pSVn        V# )aw  
Create a StubApplicationRunnerWithSignal using a reactor that
implements _ISupportsExitSignalCapturing and whose _exitSignal
attribute is set to signum.

@param config: The runner configuration, platform dependent.
@type config: L{twisted.scripts.twistd.ServerOptions}

@return: A runner to use for the test.
@rtype: twisted.test.test_twistd.StubApplicationRunnerWithSignal
)rï  rò  )rŽ   r<  Úsignums   & €r3   ÚstubApplicationRunnerFactoryÚIstubApplicationRunnerFactoryCreator.<locals>.stubApplicationRunnerFactoryG  s   ø€ ô 1°Ó8ˆØ$ˆÔØˆr6   ra   )rü  rý  s   f r3   Ú#stubApplicationRunnerFactoryCreatorrÿ  :  s   ø€ õð  (Ð'r6   c                   ó<   a € ] tR tRt o RtR tR tR tR tRt	V t
R# )	ÚExitWithSignalTestsiZ  z7
Tests for L{twisted.application.app._exitWithSignal}.
c                ó  a € \         P                  ! 4       S n        R\        4       /S P                  n        \        4       S P                  n        RS P                  n        RR.S n        V 3R lpS P                  \        RV4       R# )z=
Set up the server options and a fake for use by test cases.
rX  Nc                óD   <€ V SP                   ^ &   VSP                   ^&   R# )z”
Fake method to capture arguments passed to os.kill.

@param pid: The pid of the process being killed.

@param sig: The signal sent to the process.
N)ÚfakeKillArgs)r  r  rQ   s   &&€r3   ÚfakeKillÚ+ExitWithSignalTests.setUp.<locals>.fakeKillj  s%   ø€ ð $'ˆD×Ñ˜aÑ Ø#&ˆD×Ñ˜aÓ r6   r  )r   r‰   rŽ   rK   rZ  r[  r\  r�   r  rD   r:   )rQ   r  s   f r3   r1  ÚExitWithSignalTests.setUp`  sg   ø€ ô ×*Ò*Ó,ˆŒØ%3Ô5EÓ5GÐ$Hˆ�‰Ô!Ü!'£ˆ�‰ÔØ!/ˆ�‰ÔØ! 4˜LˆÔõ		'ð 	�
‰
”2�v˜xÖ(r6   c                óü  a€ RR.oV3R lpV P                  \        RV4       \        P                  ! \        P                  4       V P                  S^ ,          \        P                  4       V P                  S^,          \        P                  4       V P                  V P                  ^ ,          \        P                  ! 4       4       V P                  V P                  ^,          \        P                  4       R# )z„
exitWithSignal replaces the existing signal handler with the default
handler and sends the replaced signal to the current process.
Nc                 ó   <€ V S^ &   VS^&   R# )r˜  Nra   )r  ÚhandlerÚfakeSignalArgss   &&€r3   Úfake_signalÚ<ExitWithSignalTests.test_exitWithSignal.<locals>.fake_signal  s   ø€ Ø #ˆN˜1ÑØ 'ˆN˜1Ór6   r\  )
rD   r\  r	   Ú_exitWithSignalÚSIGINTrÆ  ÚSIG_DFLr  r:   r  )rQ   r  r  s   & @r3   Útest_exitWithSignalÚ'ExitWithSignalTests.test_exitWithSignalw  s©   ø€ ð  ˜ˆõ	(ð 	�
‰
”6˜8 [Ô1Ü×ÒœFŸM™MÔ*à×Ñ˜.¨Õ+¬V¯]©]Ô;Ø×Ñ˜.¨Õ+¬V¯^©^Ô<Ø×Ñ˜$×+Ñ+¨AÕ.´·	²	³Ô<Ø×Ñ˜$×+Ñ+¨AÕ.´·±Ö>r6   c                ó  € V P                  \        R\        R4      4       \        P                  ! V P                  4       V P                  V P                  ^ ,          4       V P                  V P                  ^,          4       R# )zJ
_exitWithSignal is not called if the runner does not exit with a
signal.
rœ  N)rD   r   rÿ  ÚrunApprŽ   r�   r  rj   s   &r3   Útest_normalExitÚ#ExitWithSignalTests.test_normalExit‹  sc   € ð
 	�
‰
ÜÐ,Ô.QÐRVÓ.Wô	
ô 	�Š�d—k‘kÔ"Ø×Ñ˜$×+Ñ+¨AÕ.Ô/Ø×Ñ˜$×+Ñ+¨AÕ.Ö/r6   c                óp  € V P                  \        R\        \        P                  4      4       \        P
                  ! V P                  4       V P                  V P                  ^ ,          \        P                  ! 4       4       V P                  V P                  ^,          \        P                  4       R# )z@
_exitWithSignal is called when the runner exits with a signal.
rœ  N)rD   r   rÿ  r\  r  r  rŽ   rÆ  r  r:   r  rj   s   &r3   Útest_runnerExitsWithSignalÚ.ExitWithSignalTests.test_runnerExitsWithSignal—  st   € ð 	�
‰
ÜØ$Ü/´·±Ó>ô	
ô
 	�Š�d—k‘kÔ"Ø×Ñ˜$×+Ñ+¨AÕ.´·	²	³Ô<Ø×Ñ˜$×+Ñ+¨AÕ.´·±Ö>r6   )rŽ   r  N)rT   rU   rV   rW   rX   r1  r  r  r  rZ   r[   r\   s   @r3   r  r  Z  s#   ø‡ € ñò)ò.?ò(
0÷?ð ?r6   r  )hrX   r  r(  r:   r.  r\  r�  r<   Ú_grpr9   Ú_pwdÚImportErrorÚior   Úunittestr   Úzope.interfacer   Úzope.interface.verifyr   ré   r   r   r   Útwisted.applicationr	   r
   r   Útwisted.application.servicer   Útwisted.internet.baser   Útwisted.internet.deferr   Útwisted.internet.interfacesr   r   Ú#twisted.internet.test.modulehelpersr   Útwisted.internet.testingr   Útwisted.loggerr   r   r   Útwisted.pythonr   Útwisted.python.componentsr   Útwisted.python.fakepwdr   Útwisted.python.logr  r   Útwisted.python.reflectr   Útwisted.python.runtimer   Útwisted.python.usager   Útwisted.scriptsr   Útwisted.test.test_processr   Útwisted.trial.unittestr   ró   Útwisted.scripts._twistd_unixr    r!   r"   rã  r#   r$   r%   rI   rK   r  r_   rœ  rh   rr   rõ   r)  r9  rK  rI  rV  rÕ  r  r`  rp  rø  r°  r…  rÕ  rå  rç  rV  r{  rå  rï  rÿ  r  ra   r6   r3   Ú<module>r4     s  ðñó
 Û Û 	Û Û Û 
ðÛÛð
 €CØ
€Cå Ý å &Ý .ç ,Ñ ,ß 6Ñ 6Ý 5Ý -Ý +ß XÝ @Ý 2ß NÑ NÝ Ý 3Ý /ß TÝ 0Ý /Ý +Ý "Ý ,Ý +áÐ;Ó<€ß÷ñ ñ 
Ð.Ó	/€Ù
˜	Ó
"€Ù	�xÓ	 €Ù˜Ó$€ò*.÷Zñ ô"˜Ÿ™ô ô × =Ñ =ô ô UJ˜ô UJñp ˆLÔÐ5Ó6ôCK�Hó CKó 7ðCKôLD�8ô D÷0ñ ô*J˜C×1Ñ1ô Jô(p4˜Xô p4ñf ˆLÔÐ5Ó6ôF+°ó F+ó 7ðF+ñR ˆLÔÐ5Ó6ôO?°ó O?ó 7ðO?ñd ˆLÔÐ5Ó6ô>¨(ó >ó 7ð>÷<ñ ñ8 ÐÓôÐ6ó ó  ð÷ñ ô(w8˜ô w8òtò*ô$`5�Xô `5ñF	 ˆLÔÐ5Ó6ôy<˜ó y<ó 7ðy<ñx ˆLÔÐ=Ó>ôf8�Xó f8ó ?ðf8ñR	 Ð*Ó+ô =ó ó ,ðô; f×&CÑ&Cô ;ò<(ô@H?˜(ö H?øðOB ô Ø
€CØ
ƒCðús   œJ ÊJ+Ê*J+