§
    Ètºf$! ã                   óö  — d Z ddlZddlZddlZddlZddlZddlZ	 ddlZddl	Z
e
Z	eZn# e$ r dZ	dZY nw xY wddlmZ ddlmZ ddlmZ ddlmZ ddlmZmZmZ ddlmZmZmZ dd	lmZ dd
lmZ ddl m!Z! ddl"m#Z#m$Z$ ddl%m&Z& ddl'm(Z( ddl)m*Z*m+Z+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m*Z4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZA  e7d¦  «        ZBeBr
ddlCmDZDmEZEmFZF  e7d¦  «        ZG e7d¦  «        ZH e7d¦  «        ZI e7d¦  «        ZJd „ ZK G d!„ d"¦  «        ZL G d#„ d$ejM        ¦  «        ZN G d%„ d&e=jO        ¦  «        ZP G d'„ d(eA¦  «        ZQ eeB d)¦  «         G d*„ d+eA¦  «        ¦   «         ZR G d,„ d-eA¦  «        ZS G d.„ d/¦  «        ZT G d0„ d1ejU        ¦  «        ZV G d2„ d3eA¦  «        ZW eeB d)¦  «         G d4„ d5eA¦  «        ¦   «         ZX eeB d)¦  «         G d6„ d7eA¦  «        ¦   «         ZY eeB d)¦  «         G d8„ d9eA¦  «        ¦   «         ZZ G d:„ d;¦  «        Z[ ee#¦  «         G d<„ d=e[¦  «        ¦   «         Z\ G d>„ d?¦  «        Z] G d@„ dAeA¦  «        Z^dB„ Z_dC„ Z` G dD„ dEeA¦  «        Za eeB d)¦  «         G dF„ dGeA¦  «        ¦   «         Zb eeB dH¦  «         G dI„ dJeA¦  «        ¦   «         Zc ee$¦  «         G dK„ dLe(¦  «        ¦   «         Zd G dM„ dNe=jO        ¦  «        ZedO„ Zf G dP„ dQeA¦  «        ZgdS )RzE
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           	      óÀ  ‡‡‡— t                                t          j        ¦   «         ¦  «        }t                               t          j        ¦   «         ¦  «        Št          ¦   «         }|                     ||j	        |‰|j
        |j        |j        ¦  «         ˆˆˆfd„} | t           d|j        ¦  «          | t          d|¦  «          | t           d|j        ¦  «         dS )au  
    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                 óÈ   •— t          ‰¦  «        }‰||                     ‰j        ¦  «        <   ‰||                     ‰j        ¦  «        <   t	          |¦  «        }‰|i|          S ©N)ÚlistÚindexÚgr_nameÚgr_gidÚtuple)ÚnameÚresultÚgidÚgrentÚgroups     €€€úW/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/test/test_twistd.pyÚgetgrnamz#patchUserDatabase.<locals>.getgrnamd   sX   ø€ Ý�e‘”ˆØ.3ˆˆv�|Š|˜EœMÑ*Ô*Ñ+Ø-0ˆˆv�|Š|˜EœLÑ)Ô)Ñ*Ý�v‘”ˆØ�vˆ˜tÔ$Ð$ó    Úgetpwnamr5   ÚgetpwuidN)Úpwdr8   ÚosÚgetuidÚgrpÚgetgrgidÚgetgidr   ÚaddUserÚ	pw_passwdÚpw_gecosÚpw_dirÚpw_shellr7   )	ÚpatchÚuserÚuidr3   r1   ÚpwentÚdatabaser5   r2   s	      ``   @r4   ÚpatchUserDatabaserI   C   sÚ   øøø€ õ2 �LŠL�œ™œÑ%Ô%€EÝ�LŠL�œ™œÑ%Ô%€Eå‰~Œ~€HØ×ÒØˆeŒo˜s C¨¬¸¼ÀuÄ~ñô ð ð%ð %ð %ð %ð %ð %ð %ð 
€E�#ˆz˜8Ô,Ñ-Ô-Ð-Ø	€E�#ˆz˜8Ñ$Ô$Ð$Ø	€E�#ˆz˜8Ô,Ñ-Ô-Ð-Ð-Ð-r6   c                   ó   — e Zd ZdZdZd„ ZdS )ÚMockServiceMakerzO
    A non-implementation of L{twisted.application.service.IServiceMaker}.
    Úueoac                 óN   — || _         t          j        ¦   «         | _        | j        S )ze
        Take a L{usage.Options} instance and return a
        L{service.IService} provider.
        )Úoptionsr   ÚService©ÚselfrN   s     r4   ÚmakeServicezMockServiceMaker.makeServicew   s"   € ð
 ˆŒÝ”Ñ(Ô(ˆŒØŒ|Ðr6   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚtapnamerR   © r6   r4   rK   rK   p   s4   € € € € € ðð ð €Gðð ð ð ð r6   rK   c                   ó   — e Zd ZdZd„ ZdS )ÚCrippledAppLoggerz*
    @see: CrippledApplicationRunner.
    c                 ó   — d S r)   rX   ©rQ   Úapplications     r4   ÚstartzCrippledAppLogger.start†   ó   € Øˆr6   N)rS   rT   rU   rV   r^   rX   r6   r4   rZ   rZ   �   s-   € € € € € ðð ðð ð ð ð r6   rZ   c                   ó"   — e Zd ZdZeZd„ Zd„ ZdS )Ú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                 ó   — d S r)   rX   ©rQ   s    r4   ÚpreApplicationz(CrippledApplicationRunner.preApplication“   r_   r6   c                 ó   — d S r)   rX   rc   s    r4   ÚpostApplicationz)CrippledApplicationRunner.postApplication–   r_   r6   N)rS   rT   rU   rV   rZ   ÚloggerFactoryrd   rf   rX   r6   r4   ra   ra   Š   sC   € € € € € ðð ð &€Mðð ð ðð ð ð ð r6   ra   c                   óÌ   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Z e	e
 d¦  «        d„ ¦   «         Z e	e
 d¦  «        d	„ ¦   «         Z e	e
 d¦  «        d
„ ¦   «         Zd„ Zd„ Zd„ Zd„ ZdS )ÚServerOptionsTestszT
    Non-platform-specific tests for the platform-specific ServerOptions class.
    c                 óD  ‡ ‡‡‡‡—  G d„ d¦  «        } |d¦  «        Š |d¦  «        Š |d¦  «        Š |d¦  «        Šˆˆˆˆˆ fd„}t          j        ¦   «         }‰                      |j        t          j        ¦  «         ||_        |j        }‰‰‰‰g}t          ||¦  «        D ]{\  }}|\  }}	}
}‰                      ||j        ¦  «         ‰  	                    |	¦  «         ‰                       |
¦   «         |j
        ¦  «        f ‰                      ||j        ¦  «         Œ|dS )	zh
        subCommands is built from IServiceMaker plugins, and is sorted
        alphabetically.
        c                   ó   — e Zd Zd„ Zd„ ZdS )ú7ServerOptionsTests.test_subCommands.<locals>.FakePluginc                 ó<   — || _         d|z   | _        d|z   | _        d S )Nzoptions for údescription of )rW   Ú_optionsÚdescription©rQ   r/   s     r4   Ú__init__z@ServerOptionsTests.test_subCommands.<locals>.FakePlugin.__init__¦   s(   € Ø#�”Ø .°Ñ 5�”Ø#4°tÑ#;�Ô Ð Ð r6   c                 ó   — | j         S r)   )ro   rc   s    r4   rN   z?ServerOptionsTests.test_subCommands.<locals>.FakePlugin.options«   s
   € Ø”}Ð$r6   N)rS   rT   rU   rr   rN   rX   r6   r4   Ú
FakePluginrl   ¥   s2   € € € € € ð<ð <ð <ð
%ð %ð %ð %ð %r6   rt   ÚappleÚbananaÚcoconutÚdonutc              3   ób   •K  — ‰                      | t          ¦  «         ‰V — ‰V — ‰V — ‰V — d S r)   )ÚassertEqualr   )Ú	interfaceru   rv   rw   rx   rQ   s    €€€€€r4   Ú
getPluginsz7ServerOptionsTests.test_subCommands.<locals>.getPlugins³   sE   øè è € Ø×Ò˜Y­Ñ6Ô6Ð6ØˆMˆMˆMØˆLˆLˆLØˆKˆKˆKØˆKˆKˆKˆKˆKr6   N)r   ÚServerOptionsrz   Ú_getPluginsr	   r|   ÚsubCommandsÚziprW   ÚassertIsNonero   rp   )rQ   rt   r|   Úconfigr   ÚexpectedOrderÚ
subCommandÚexpectedCommandr/   ÚshortcutÚparserClassÚdocumentationru   rv   rw   rx   s   `           @@@@r4   Útest_subCommandsz#ServerOptionsTests.test_subCommandsŸ   s‹  øøøøø€ ð	%ð 	%ð 	%ð 	%ð 	%ñ 	%ô 	%ð 	%ð �
˜7Ñ#Ô#ˆØ�˜HÑ%Ô%ˆØ�*˜YÑ'Ô'ˆØ�
˜7Ñ#Ô#ˆð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	õ Ô%Ñ'Ô'ˆØ×Ò˜Ô+­VÔ->Ñ?Ô?Ð?Ø'ˆÔð Ô(ˆØ ¨°Ð7ˆå+.¨{¸MÑ+JÔ+Jð 	Ið 	IÑ'ˆJ˜Ø9CÑ6ˆD�(˜K¨Ø×Ò˜T ?Ô#:Ñ;Ô;Ð;Ø×Ò˜hÑ'Ô'Ð'Ø×Ò˜[˜[™]œ]¨OÔ,DÑEÔEÐFÐFØ×Ò˜]¨OÔ,GÑHÔHÐHÐHð	Ið 	Ir6   c                 ó‚  ‡ ‡‡‡‡	‡
‡—  G d„ d¦  «        } |d¦  «        Š |d¦  «        Š |d¦  «        Š |d¦  «        Š	ˆˆˆˆ	fd„}t          j        ¦   «         }‰                      |j        t          j        ¦  «         ||_        t          ¦   «         |_        ‰                      t          |j
        dg¦  «         |j                             ¦   «         Š
g Š‰‰‰‰	fD ])}ˆ
ˆˆ fd	„} ||j        ¦  «          ||j        ¦  «         Œ*‰                      ‰t          ‰¦  «        d
                     ‰
¦  «        ¦  «         dS )zP
        Reactor names are listed alphabetically by I{--help-reactors}.
        c                   ó   — e Zd Zd„ ZdS )úGServerOptionsTests.test_sortedReactorHelp.<locals>.FakeReactorInstallerc                 ó<   — d|z   | _         d|z   | _        d| _        d S )Nzname of rn   ztwisted.internet.default)Ú	shortNamerp   Ú
moduleNamerq   s     r4   rr   zPServerOptionsTests.test_sortedReactorHelp.<locals>.FakeReactorInstaller.__init__Ð   s&   € Ø!+¨dÑ!2�”Ø#4°tÑ#;�Ô Ø"<�”��r6   N)rS   rT   rU   rr   rX   r6   r4   ÚFakeReactorInstallerrŒ   Ï   s#   € € € € € ð=ð =ð =ð =ð =r6   r�   ru   rv   rw   rx   c               3   ó,   •K  — ‰V — ‰V — ‰V — ‰ V — d S r)   rX   )ru   rv   rw   rx   s   €€€€r4   ÚgetReactorTypeszBServerOptionsTests.test_sortedReactorHelp.<locals>.getReactorTypesÚ   s/   øè è € ØˆMˆMˆMØˆLˆLˆLØˆKˆKˆKØˆKˆKˆKˆKˆKr6   z--help-reactorsc                 ó„   •— ‰                      | ‰¦  «         ‰                     ‰                     | ¦  «        ¦  «         d S r)   )ÚassertInÚappendr+   )ÚsÚ
helpOutputÚindexesrQ   s    €€€r4   ÚgetIndexz;ServerOptionsTests.test_sortedReactorHelp.<locals>.getIndexê   s=   ø€ Ø—’˜a Ñ,Ô,Ð,Ø—’˜z×/Ò/°Ñ2Ô2Ñ3Ô3Ð3Ð3Ð3r6   z9reactor descriptions were not in alphabetical order: {!r}N)r   r}   rz   Ú_getReactorTypesr   r’   r   ÚmessageOutputÚassertRaisesÚ
SystemExitÚparseOptionsÚgetvaluerŽ   rp   ÚsortedÚformat)rQ   r�   r’   r‚   Úreactorr™   ru   rv   rw   rx   r—   r˜   s   `     @@@@@@r4   Útest_sortedReactorHelpz)ServerOptionsTests.test_sortedReactorHelpÊ   s½  øøøøøøø€ ð
	=ð 	=ð 	=ð 	=ð 	=ñ 	=ô 	=ð 	=ð %Ð$ WÑ-Ô-ˆØ%Ð% hÑ/Ô/ˆØ&Ð& yÑ1Ô1ˆØ$Ð$ WÑ-Ô-ˆð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	õ Ô%Ñ'Ô'ˆØ×Ò˜Ô0µ(Ô2JÑKÔKÐKØ"1ˆÔÝ'™zœzˆÔà×Ò�* fÔ&9Ð<MÐ;NÑOÔOÐOØÔ)×2Ò2Ñ4Ô4ˆ
ØˆØ˜f g¨uÐ4ð 	*ð 	*ˆGð4ð 4ð 4ð 4ð 4ð 4ð 4ð ˆH�WÔ&Ñ'Ô'Ð'ØˆH�WÔ(Ñ)Ô)Ð)Ð)à×ÒØÝ�7‰OŒOØG×NÒNØñô ñ	
ô 	
ð 	
ð 	
ð 	
r6   c                 ó˜   — t          j        ¦   «         }d|_        |                     ¦   «          |                      |d         ¦  «         dS )zS
        postOptions should set no_save to True when a subcommand is used.
        rL   Úno_saveN)r   r}   r„   ÚpostOptionsÚ
assertTrue©rQ   r‚   s     r4   Ú&test_postOptionsSubCommandCausesNoSavez9ServerOptionsTests.test_postOptionsSubCommandCausesNoSaveù   sI   € õ Ô%Ñ'Ô'ˆØ"ˆÔØ×ÒÑÔÐØ�Š˜˜yÔ)Ñ*Ô*Ð*Ð*Ð*r6   c                 óŠ   — t          j        ¦   «         }|                     ¦   «          |                      |d         ¦  «         dS )zR
        If no sub command is used, postOptions should not touch no_save.
        r¥   N)r   r}   r¦   ÚassertFalser¨   s     r4   Ú(test_postOptionsNoSubCommandSavesAsUsualz;ServerOptionsTests.test_postOptionsNoSubCommandSavesAsUsual  sC   € õ Ô%Ñ'Ô'ˆØ×ÒÑÔÐØ×Ò˜ 	Ô*Ñ+Ô+Ð+Ð+Ð+r6   c                 óž   — t          j        ¦   «         }t          |¦  «        }t          j        j        D ]}|                      ||¦  «         ŒdS )zq
        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       r4   Útest_listAllProfilersz(ServerOptionsTests.test_listAllProfilers
  sR   € õ
 Ô%Ñ'Ô'ˆÝ˜‘[”[ˆ
ÝœÔ1ð 	0ð 	0ˆHØ�MŠM˜( JÑ/Ô/Ð/Ð/ð	0ð 	0r6   útwistd unix not availablec                 ób   — t          j        ¦   «         }|                      |d         ¦  «         dS )zG
        The default value for the C{umask} option is L{None}.
        ÚumaskN)r   r}   r�   r¨   s     r4   Útest_defaultUmaskz$ServerOptionsTests.test_defaultUmask  s0   € õ
 Ô%Ñ'Ô'ˆØ×Ò˜& œ/Ñ*Ô*Ð*Ð*Ð*r6   c                 óø   — t          j        ¦   «         }|                     ddg¦  «         |                      |d         d¦  «         |                     ddg¦  «         |                      |d         d¦  «         dS )zh
        The value given for the C{umask} option is parsed as an octal integer
        literal.
        ú--umaskÚ123rµ   éS   Ú0123N)r   r}   rž   rz   r¨   s     r4   Ú
test_umaskzServerOptionsTests.test_umask  s~   € õ Ô%Ñ'Ô'ˆØ×Ò˜Y¨Ð.Ñ/Ô/Ð/Ø×Ò˜ œ¨"Ñ-Ô-Ð-Ø×Ò˜Y¨Ð/Ñ0Ô0Ð0Ø×Ò˜ œ¨"Ñ-Ô-Ð-Ð-Ð-r6   c                 ór   — t          j        ¦   «         }|                      t          |j        ddg¦  «         dS )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     r4   Útest_invalidUmaskz$ServerOptionsTests.test_invalidUmask(  s8   € õ Ô%Ñ'Ô'ˆØ×Ò�* fÔ&9¸IÀxÐ;PÑQÔQÐQÐQÐQr6   c                 ó  — t          j        ¦   «         }|                      t          |j        ddg¦  «        }|                      |j        d                              d¦  «        ¦  «         |                      d|j        d         ¦  «         dS )zQ
        C{--logger} with an unimportable module raises a L{UsageError}.
        ú--loggerzno.such.module.I.hoper   zeLogger '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      r4   Ú&test_unimportableConfiguredLogObserverz9ServerOptionsTests.test_unimportableConfiguredLogObserver1  s’   € õ Ô%Ñ'Ô'ˆØ×ÒÝ˜Ô+¨jÐ:QÐ-Rñ
ô 
ˆð 	�ŠØŒF�1ŒI× Ò ðBñô ñ	
ô 	
ð 	
ð 	×Ò˜˜qœv aœyÑ)Ô)Ð)Ð)Ð)r6   c                 ó  — t          j        ¦   «         }|                      t          |j        ddg¦  «        }|                      |j        d                              d¦  «        ¦  «         |                      d|j        d         ¦  «         dS )zP
        C{--logger} with a non-existent object raises a L{UsageError}.
        rÁ   ztwisted.test.test_twistd.FOOBARr   z{Logger 'twisted.test.test_twistd.FOOBAR' could not be imported: module 'twisted.test.test_twistd' has no attribute 'FOOBAR'rÂ   NrÃ   rÇ   s      r4   Ú*test_badAttributeWithConfiguredLogObserverz=ServerOptionsTests.test_badAttributeWithConfiguredLogObserverA  s“   € õ Ô%Ñ'Ô'ˆØ×ÒÝØÔØÐ:Ð;ñ
ô 
ˆð
 	�ŠØŒF�1ŒI× Ò ð,ñô ñ	
ô 	
ð 	
ð 	×Ò˜˜qœv aœyÑ)Ô)Ð)Ð)Ð)r6   c                 ó„  — ddl m} t          dk    rd}nd}d                     ||j        |j        ¦  «        }t          ¦   «         }t          j        |¬¦  «        }|                      t          |j
        dg¦  «        }|                      |j        d	¦  «         |                      |                     ¦   «         |¦  «         d	S )
z2
        C{--version} prints the version.
        r   )Ú	copyrightÚwin32z(the Twisted Windows runner)z(the Twisted daemon)ztwistd {} {}
{}
©Ústdoutz	--versionN)ÚtwistedrÍ   r   r¡   Úversionr   r   r}   rœ   r�   rž   ÚassertIsÚcoderz   rŸ   )rQ   rÍ   r/   ÚexpectedOutputrÐ   r‚   rÈ   s          r4   Útest_versionzServerOptionsTests.test_versionT  sÅ   € ð 	&Ð%Ð%Ð%Ð%Ð%å˜7Ò"Ð"Ø1ˆDˆDà)ˆDØ-×4Ò4Ø�)Ô# YÔ%8ñ
ô 
ˆõ ‘”ˆÝÔ%¨VÐ4Ñ4Ô4ˆØ×Ò�j¨&Ô*=À¸}ÑMÔMˆØ�Š�a”f˜dÑ#Ô#Ð#Ø×Ò˜ŸšÑ*Ô*¨NÑ;Ô;Ð;Ð;Ð;r6   c                 ó�   — t          ¦   «         }t          j        |¬¦  «        }|                      t          |j        dg¦  «         dS )zI
        Command is printed when an invalid option is requested.
        rÏ   z	web --fooN)r   r   r}   rœ   r   rž   )rQ   rÐ   r‚   s      r4   Ú!test_printSubCommandForUsageErrorz4ServerOptionsTests.test_printSubCommandForUsageErrorh  sC   € õ ‘”ˆÝÔ%¨VÐ4Ñ4Ô4ˆà×Ò�* fÔ&9¸K¸=ÑIÔIÐIÐIÐIr6   N)rS   rT   rU   rV   r‰   r£   r©   r¬   r²   r   Ú_twistd_unixr¶   r¼   r¿   rÉ   rË   rÖ   rØ   rX   r6   r4   ri   ri   š   s6  € € € € € ðð ð)Ið )Ið )IðV-
ð -
ð -
ð^+ð +ð +ð,ð ,ð ,ð0ð 0ð 0ð €V�ÐÐ9Ñ:Ô:ð+ð +ñ ;Ô:ð+ð €V�ÐÐ9Ñ:Ô:ð	.ð 	.ñ ;Ô:ð	.ð €V�ÐÐ9Ñ:Ô:ðRð Rñ ;Ô:ðRð*ð *ð *ð *ð *ð *ð&<ð <ð <ð(Jð Jð Jð Jð Jr6   ri   r³   c                   ó0   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚCheckPIDTestsz 
    Tests for L{checkPID}.
    c                 óh   — |                       t          j        dd„ ¦  «         t          d¦  «         dS )z7
        Nonexistent PID file is not an error.
        Úexistsc                 ó   — dS ©NFrX   )Ú_s    r4   ú<lambda>z.CheckPIDTests.test_notExists.<locals>.<lambda>|  s   € °€ r6   znon-existent PID fileN)rD   r:   Úpathr#   rc   s    r4   Útest_notExistszCheckPIDTests.test_notExistsx  s3   € ð 	�
Š
•2”7˜H o oÑ6Ô6Ð6ÝÐ(Ñ)Ô)Ð)Ð)Ð)r6   c                 ó   — |                       ¦   «         }t          |d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   |                      t          t
          |¦  «        }|                      d|j        ¦  «         dS )zI
        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       r4   Útest_nonNumericzCheckPIDTests.test_nonNumeric  s¹   € ð —+’+‘-”-ˆÝ�'˜3ÑÔð 	# 1Ø�GŠG�MÑ"Ô"Ð"ð	#ð 	#ð 	#ñ 	#ô 	#ð 	#ð 	#ð 	#ð 	#ð 	#ð 	#øøøð 	#ð 	#ð 	#ð 	#à×Ò�j­(°GÑ<Ô<ˆØ�ŠÐ)¨1¬6Ñ2Ô2Ð2Ð2Ð2ó   ¥AÁAÁAc                 ó^  — |                       ¦   «         }t          |d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   d„ }|                      t          d|¦  «         |                      t          t          |¦  «        }|                      d|j	        ¦  «         dS )zE
        Another running twistd server causes a system exit.
        rå   Ú42Nc                 ó   — d S r)   rX   ©ÚpidÚsigs     r4   Úkillz/CheckPIDTests.test_anotherRunning.<locals>.kill‘  s   € ØˆDr6   ró   zAnother twistd server)
ræ   rç   rè   rD   r:   rœ   r�   r#   r”   rÔ   ©rQ   ré   rê   ró   rÈ   s        r4   Útest_anotherRunningz!CheckPIDTests.test_anotherRunning‰  sÝ   € ð —+’+‘-”-ˆÝ�'˜3ÑÔð 	 1Ø�GŠG�D‰MŒMˆMð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð	ð 	ð 	ð 	�
Š
•2�v˜tÑ$Ô$Ð$Ø×Ò�j­(°GÑ<Ô<ˆØ�ŠÐ-¨q¬vÑ6Ô6Ð6Ð6Ð6rì   c                 óª  — |                       ¦   «         }t          |d¦  «        5 }|                     t          t	          j        ¦   «         dz   ¦  «        ¦  «         ddd¦  «         n# 1 swxY w Y   d„ }|                      t          d|¦  «         t          |¦  «         |                      t          j	         
                    |¦  «        ¦  «         dS )zJ
        Stale PID file is removed without causing a system exit.
        rå   é   Nc                 ó6   — t          t          j        d¦  «        ‚©NÚfake)ÚOSErrorÚerrnoÚESRCHrð   s     r4   ró   z&CheckPIDTests.test_stale.<locals>.kill   ó   € Ý�%œ+ vÑ.Ô.Ð.r6   ró   )ræ   rç   rè   r®   r:   ÚgetpidrD   r#   r«   râ   rÝ   )rQ   ré   rê   ró   s       r4   Ú
test_stalezCheckPIDTests.test_stale˜  sô   € ð —+’+‘-”-ˆÝ�'˜3ÑÔð 	* 1Ø�GŠG•C�œ	™œ a™Ñ(Ô(Ñ)Ô)Ð)ð	*ð 	*ð 	*ñ 	*ô 	*ð 	*ð 	*ð 	*ð 	*ð 	*ð 	*øøøð 	*ð 	*ð 	*ð 	*ð	/ð 	/ð 	/ð 	�
Š
•2�v˜tÑ$Ô$Ð$Ý�ÑÔÐØ×Ò�œŸš¨Ñ0Ô0Ñ1Ô1Ð1Ð1Ð1s   ¥7A(Á(A,Á/A,c                 óÄ  — |                       ¦   «         }t          |d¦  «        5 }|                     d¦  «         ddd¦  «         n# 1 swxY w Y   d„ }|                      t          d|¦  «         |                      t          t          |¦  «        }|                      |j	        d¦  «         |  
                    |j        d                              d¦  «        ¦  «         dS )z�
        An unexpected L{OSError} when checking the validity of a
        PID in a C{pidfile} terminates the process via L{SystemExit}.
        rå   Ú3581Nc                 ó6   — t          t          j        d¦  «        ‚rù   ©rû   rü   ÚEBADFrð   s     r4   ró   z2CheckPIDTests.test_unexpectedOSError.<locals>.kill°  rþ   r6   ró   r   zCan't check status of PID)ræ   rç   rè   rD   r:   rœ   r�   r#   ÚassertIsNotrÔ   r§   rÄ   rÅ   rô   s        r4   Útest_unexpectedOSErrorz$CheckPIDTests.test_unexpectedOSError§  s  € ð
 —+’+‘-”-ˆÝ�'˜3ÑÔð 	 1Ø�GŠG�F‰OŒOˆOð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð	/ð 	/ð 	/ð 	�
Š
•2�v˜tÑ$Ô$Ð$Ø×Ò�j­(°GÑ<Ô<ˆØ×Ò˜œ Ñ&Ô&Ð&Ø�Š˜œ˜qœ	×,Ò,Ð-HÑIÔIÑJÔJÐJÐJÐJrì   N)	rS   rT   rU   rV   rã   rë   rõ   r   r  rX   r6   r4   rÛ   rÛ   r  sn   € € € € € ðð ð*ð *ð *ð3ð 3ð 3ð7ð 7ð 7ð2ð 2ð 2ðKð Kð Kð Kð Kr6   rÛ   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚTapFileTestszM
    Test twistd-related functionality that requires a tap file on disk.
    c                 óâ   — |                       ¦   «         | _        t          | j        d¦  «        5 }t          j        t          j        d¦  «        |¦  «         ddd¦  «         dS # 1 swxY w Y   dS )zP
        Create a trivial Application and put it in a tap file on disk.
        ÚwbúHi!N)ræ   Útapfilerç   ÚpickleÚdumpr   ÚApplication)rQ   rê   s     r4   ÚsetUpzTapFileTests.setUp¾  s£   € ð —{’{‘}”}ˆŒÝ�$”, Ñ%Ô%ð 	7¨ÝŒK�Ô+¨EÑ2Ô2°AÑ6Ô6Ð6ð	7ð 	7ð 	7ñ 	7ô 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7øøøð 	7ð 	7ð 	7ð 	7ð 	7ð 	7s   ¯(A$Á$A(Á+A(c                 ó   — t          j        ¦   «         }|                     d| j        g¦  «         t	          |¦  «                             ¦   «         }|                      t          j        |¦  «        j	        d¦  «         dS )zŽ
        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  ra   ÚcreateOrGetApplicationrz   r   ÚIServicer/   )rQ   r‚   r]   s      r4   Ú&test_createOrGetApplicationWithTapFilez3TapFileTests.test_createOrGetApplicationWithTapFileÆ  sp   € õ
 Ô%Ñ'Ô'ˆØ×Ò˜T 4¤<Ð0Ñ1Ô1Ð1Ý/°Ñ7Ô7×NÒNÑPÔPˆØ×Ò�Ô)¨+Ñ6Ô6Ô;¸UÑCÔCÐCÐCÐCr6   N)rS   rT   rU   rV   r  r  rX   r6   r4   r	  r	  ¹  sA   € € € € € ðð ð7ð 7ð 7ðDð Dð Dð Dð Dr6   r	  c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚTestLoggerFactoryz8
    A logger factory for L{TestApplicationRunner}.
    c                 ó   — || _         d S r)   )Úrunner)rQ   r  s     r4   rr   zTestLoggerFactory.__init__Ö  s   € ØˆŒˆˆr6   c                 ó‚   — | j         j                             d¦  «         t          | j         d¦  «        | j         _        dS )zC
        Save the logging start on the C{runner} instance.
        Úlogr]   N)r  Úorderr•   ÚhasattrÚhadApplicationLogObserverr\   s     r4   r^   zTestLoggerFactory.startÙ  s9   € ð 	ŒÔ× Ò  Ñ'Ô'Ð'Ý07¸¼À]Ñ0SÔ0SˆŒÔ-Ð-Ð-r6   c                 ó   — dS )z%
        Don't log anything.
        NrX   rc   s    r4   ÚstopzTestLoggerFactory.stopà  ó   € € € r6   N)rS   rT   rU   rV   rr   r^   r   rX   r6   r4   r  r  Ñ  sN   € € € € € ðð ðð ð ðTð Tð Tðð ð ð ð r6   r  c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚTestApplicationRunnerz`
    An ApplicationRunner which tracks the environment in which its methods are
    called.
    c                 ó|   — t           j                             | |¦  «         g | _        t	          | ¦  «        | _        d S r)   )r
   ÚApplicationRunnerrr   r  r  r   rP   s     r4   rr   zTestApplicationRunner.__init__ì  s5   € ÝÔ×&Ò& t¨WÑ5Ô5Ð5ØˆŒ
Ý'¨Ñ-Ô-ˆŒˆˆr6   c                 ód   — | j                              d¦  «         t          | d¦  «        | _        d S )NÚprer]   )r  r•   r  ÚhadApplicationPreApplicationrc   s    r4   rd   z$TestApplicationRunner.preApplicationñ  s0   € ØŒ
×Ò˜%Ñ Ô Ð Ý,3°D¸-Ñ,HÔ,HˆÔ)Ð)Ð)r6   c                 ód   — | j                              d¦  «         t          | d¦  «        | _        d S )NÚpostr]   )r  r•   r  ÚhadApplicationPostApplicationrc   s    r4   rf   z%TestApplicationRunner.postApplicationõ  s0   € ØŒ
×Ò˜&Ñ!Ô!Ð!Ý-4°T¸=Ñ-IÔ-IˆÔ*Ð*Ð*r6   N)rS   rT   rU   rV   rr   rd   rf   rX   r6   r4   r#  r#  æ  sS   € € € € € ðð ð
.ð .ð .ð
Ið Ið IðJð Jð Jð Jð Jr6   r#  c                   óÆ   — e Zd ZdZd„ Zd„ Zd„ Zd„ Z e e	e
dd¦  «         d¦  «        d	„ ¦   «         Z e e	e
dd¦  «         d¦  «        d
„ ¦   «         Zd„ Zd„ Zd„ Zd„ ZdS )ÚApplicationRunnerTestszR
    Non-platform-specific tests for the platform-specific ApplicationRunner.
    c                 ó°   — t          j        ¦   «         }t          ¦   «         | _        d| j        i|_        t          ¦   «         |_        d|_        || _        d S )NÚtest_command)	r   r}   rK   ÚserviceMakerÚloadedPluginsÚobjectÚ
subOptionsr„   r‚   r¨   s     r4   r  zApplicationRunnerTests.setUpÿ  sM   € ÝÔ%Ñ'Ô'ˆÝ,Ñ.Ô.ˆÔà .°Ô0AÐBˆÔÝ"™HœHˆÔØ*ˆÔØˆŒˆˆr6   c                 ó2  — t          | j        ¦  «        }|                     ¦   «          |                      | j        j        | j        j        d¦  «         |                      | j        j        t          j        |j	        ¦  «        j
        d         d¦  «         dS )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.r   zPServiceMaker.makeService's result needs to be set as a child of the Application.N)ra   r‚   ÚrunrÓ   r0  rN   r3  r   r  r]   Úservices)rQ   Úarunners     r4   Ú,test_applicationRunnerGetsCorrectApplicationzCApplicationRunnerTests.test_applicationRunnerGetsCorrectApplication  s•   € õ ,¨D¬KÑ8Ô8ˆØ�Š‰Œˆà�ŠØÔÔ%ØŒKÔ"ð"ñ	
ô 	
ð 	
ð 	�ŠØÔÔ%ÝÔ˜WÔ0Ñ1Ô1Ô:¸1Ô=ð"ñ	
ô 	
ð 	
ð 	
ð 	
r6   c                 ó,  — t          | j        ¦  «        }|                     ¦   «          |                      |j        ¦  «         |                      |j        ¦  «         |                      |j        ¦  «         |                      |j	        g d¢¦  «         dS )z†
        Test thet preApplication and postApplication methods are
        called by ApplicationRunner.run() when appropriate.
        )r'  r  r*  N)
r#  r‚   r5  r«   r(  r§   r+  r  rz   r  )rQ   r–   s     r4   Útest_preAndPostApplicationz1ApplicationRunnerTests.test_preAndPostApplication  s†   € õ
 " $¤+Ñ.Ô.ˆØ	�Š‰ŒˆØ×Ò˜Ô7Ñ8Ô8Ð8Ø�Š˜Ô7Ñ8Ô8Ð8Ø�Š˜Ô3Ñ4Ô4Ð4Ø×Ò˜œÐ"8Ð"8Ð"8Ñ9Ô9Ð9Ð9Ð9r6   c           	      ó  ‡— | j                              |¦  «         g Š G ˆfd„dt          j        ¦  «        }t	          t
          j        t
          j        ¦  «         G ˆfd„d¦  «        ¦   «         } |¦   «         }t          t
          j        |¦  «         t          t
          j        |¦  «          || j         ¦  «        }| 	                    ¦   «          ||_
        |                     ¦   «          |                      ‰dddd||fd	d
g¦  «         dS )a.  
        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                   ó4   •— e Zd Zˆ fd„Zˆ fd„Zˆ fd„Zd„ ZdS )ú\ApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunnerc                 ó2   •— ‰                      d¦  «         d S )NÚenvironment©r•   )rQ   ÚchrootÚrundirÚnodaemonrµ   ré   Úeventss         €r4   ÚsetupEnvironmentzmApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunner.setupEnvironment8  s   ø€ Ø—’˜mÑ,Ô,Ð,Ð,Ð,r6   c                 ó:   •— ‰                      d|||f¦  «         d S )NÚ
privilegesr@  )rQ   ÚeuidrF   r1   rD  s       €r4   ÚshedPrivilegeszkApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunner.shedPrivileges;  s$   ø€ Ø—’˜|¨T°3¸Ð<Ñ=Ô=Ð=Ð=Ð=r6   c                 ó2   •— ‰                      d¦  «         d S )Nr¢   r@  )rQ   r¢   Ú	oldstdoutÚ	oldstderrrD  s       €r4   ÚstartReactorziApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunner.startReactor>  s   ø€ Ø—’˜iÑ(Ô(Ð(Ð(Ð(r6   c                 ó   — d S r)   rX   )rQ   ré   s     r4   Ú	removePIDzfApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeUnixApplicationRunner.removePIDA  ó   € Ø�r6   N)rS   rT   rU   rE  rI  rM  rO  ©rD  s   €r4   ÚFakeUnixApplicationRunnerr=  7  so   ø€ € € € € ð-ð -ð -ð -ð -ð>ð >ð >ð >ð >ð)ð )ð )ð )ð )ðð ð ð ð r6   rR  c                   óT   •— e Zd ZdZdZdZdZdZdZd„ Z	d„ Z
d„ Zˆ fd„Zˆ fd„Zd„ ZdS )úNApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeServiceNc                 ó   — d S r)   rX   rq   s     r4   ÚsetNamezVApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.setNameM  rP  r6   c                 ó   — d S r)   rX   )rQ   Úparents     r4   ÚsetServiceParentz_ApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.setServiceParentP  rP  r6   c                 ó   — d S r)   rX   rc   s    r4   ÚdisownServiceParentzbApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.disownServiceParentS  rP  r6   c                 ó2   •— ‰                      d¦  «         d S )NÚprivilegedStartServicer@  ©rQ   rD  s    €r4   r]  zeApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.privilegedStartServiceV  s   ø€ Ø—’Ð6Ñ7Ô7Ð7Ð7Ð7r6   c                 ó2   •— ‰                      d¦  «         d S )NÚstartServicer@  r^  s    €r4   r`  z[ApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.startServiceY  s   ø€ Ø—’˜nÑ-Ô-Ð-Ð-Ð-r6   c                 ó   — d S r)   rX   rc   s    r4   ÚstopServicezZApplicationRunnerTests._applicationStartsWithConfiguredID.<locals>.FakeService.stopService\  rP  r6   )rS   rT   rU   rX  Úrunningr/   ÚprocessNamerF   r1   rV  rY  r[  r]  r`  rb  rQ  s   €r4   ÚFakeServicerT  D  s¡   ø€ € € € € àˆFØˆGØˆDØˆKØˆCØˆCðð ð ðð ð ðð ð ð8ð 8ð 8ð 8ð 8ð.ð .ð .ð .ð .ðð ð ð ð r6   re  r?  r]  rG  Fr`  r¢   N)r‚   rž   r   Ú_SomeApplicationRunnerr   r   r  ÚIProcessr   rd   r]   rf   rz   )	rQ   ÚargvrF   r1   rR  re  r]   r  rD  s	           @r4   Ú"_applicationStartsWithConfiguredIDz9ApplicationRunnerTests._applicationStartsWithConfiguredID*  sY  ø€ ð 	Œ× Ò  Ñ&Ô&Ð&àˆð	ð 	ð 	ð 	ð 	ð 	ð 	­Ô(Eñ 	ô 	ð 	õ 
•WÔ%¥wÔ'7Ñ	8Ô	8ð	ð 	ð 	ð 	ð 	ð 	ð 	ñ 	ô 	ñ 
9Ô	8ð	ð4 "�k‘m”mˆÝ•WÔ% {Ñ3Ô3Ð3Ý•WÔ% {Ñ3Ô3Ð3à*Ð*¨4¬;Ñ7Ô7ˆØ×ÒÑÔÐØ(ˆÔØ×ÒÑ Ô Ð à×ÒØàØ(Ø˜u c¨3Ð/ØØðñ		
ô 		
ð 		
ð 		
ð 		
r6   ÚsetuidNz5Platform does not support --uid/--gid twistd options.c                 óx   — d}d}|                       dt          |¦  «        dt          |¦  «        g||¦  «         dS )a  
        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)ri  r®   )rQ   rF   r1   s      r4   Ú.test_applicationStartsWithConfiguredNumericIDszEApplicationRunnerTests.test_applicationStartsWithConfiguredNumericIDss  sL   € ð ˆØˆØ×/Ò/Ø•c˜#‘h”h ­¨S©¬Ð2°C¸ñ	
ô 	
ð 	
ð 	
ð 	
r6   c                 ó|   — d}d}d}d}t          | j        ||||¦  «         |                      d|d|g||¦  «         dS )a  
        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}.
        Úfoorl  Úbarrm  rn  ro  N)rI   rD   ri  )rQ   rE   rF   r3   r1   s        r4   Ú+test_applicationStartsWithConfiguredNameIDszBApplicationRunnerTests.test_applicationStartsWithConfiguredNameIDs„  sb   € ð ˆØˆØˆØˆÝ˜$œ* d¨C°¸Ñ<Ô<Ð<Ø×/Ò/Ø�d˜G UÐ+¨S°#ñ	
ô 	
ð 	
ð 	
ð 	
r6   c                 ó¶   — t          ¦   «         }t          j        ddddœ¦  «        }|                     |dd¦  «         |                      |j        d¦  «         dS )z7
        L{startReactor} calls L{reactor.run}.
        Fr$   ©r$   r±   ÚdebugNz'startReactor did not call reactor.run())ÚDummyReactorr
   r%  rM  r§   Úcalled©rQ   r¢   r  s      r4   Útest_startReactorRunsTheReactorz6ApplicationRunnerTests.test_startReactorRunsTheReactor˜  sc   € õ ‘.”.ˆÝÔ&Ø¨9¸uÐEÐEñ
ô 
ˆð 	×Ò˜G T¨4Ñ0Ô0Ð0Ø�Š˜œÐ(QÑRÔRÐRÐRÐRr6   c                 óì   — t          ¦   «         }|                      t          d|¦  «         t          j        ddddœ¦  «        }|                     ddd¦  «         |                      |j        ¦  «         dS )zN
        L{ApplicationRunner} chooses a reactor if none is specified.
        r¢   Fr$   rv  N)rx  rD   r   r
   r%  rM  r§   ry  rz  s      r4   Ú*test_applicationRunnerChoosesReactorIfNonezAApplicationRunnerTests.test_applicationRunnerChoosesReactorIfNone£  sv   € õ ‘.”.ˆØ�
Š
•8˜Y¨Ñ0Ô0Ð0ÝÔ&Ø¨9¸uÐEÐEñ
ô 
ˆð 	×Ò˜D $¨Ñ-Ô-Ð-Ø�Š˜œÑ'Ô'Ð'Ð'Ð'r6   c                 óÔ   —  G d„ dt           ¦  «        } |¦   «         }t          j        ddddœ¦  «        }|                     |dd¦  «         |                      d|j        ¦  «         dS )zg
        If the reactor exits with a signal, the application runner caches
        the signal.
        c                   ó   — e Zd ZdZd„ Zd„ ZdS )ú[ApplicationRunnerTests.test_applicationRunnerCapturesSignal.<locals>.DummyReactorWithSignalú‹
            A dummy reactor, providing a C{run} method, and setting the
            _exitSignal attribute to a nonzero value.
            c                 ó   — dS ©z=
                Dummy method, does nothing.
                NrX   rc   s    r4   ÚinstallWakerzhApplicationRunnerTests.test_applicationRunnerCapturesSignal.<locals>.DummyReactorWithSignal.installWaker»  r!  r6   c                 ó   — d| _         dS )zZ
                A fake run method setting _exitSignal to a nonzero value
                é   N©Ú_exitSignalrc   s    r4   r5  z_ApplicationRunnerTests.test_applicationRunnerCapturesSignal.<locals>.DummyReactorWithSignal.runÀ  s   € ð $%�Ô Ð Ð r6   N©rS   rT   rU   rV   r„  r5  rX   r6   r4   ÚDummyReactorWithSignalr€  µ  s<   € € € € € ðð ð
ð ð ð
%ð %ð %ð %ð %r6   rŠ  Fr$   rv  Nr†  )r   r
   r%  rM  ÚassertEqualsrˆ  )rQ   rŠ  r¢   r  s       r4   Ú$test_applicationRunnerCapturesSignalz;ApplicationRunnerTests.test_applicationRunnerCapturesSignal¯  s”   € ð	%ð 	%ð 	%ð 	%ð 	%¥[ñ 	%ô 	%ð 	%ð" )Ð(Ñ*Ô*ˆÝÔ&Ø¨9¸uÐEÐEñ
ô 
ˆð 	×Ò˜G T¨4Ñ0Ô0Ð0Ø×Ò˜!˜VÔ/Ñ0Ô0Ð0Ð0Ð0r6   c                 óÈ   —  G d„ d¦  «        } |¦   «         }t          j        ddddœ¦  «        }|                     |dd¦  «         |                      d|j        ¦  «         dS )z˜
        The runner sets its _exitSignal instance attribute to None if
        the reactor does not implement L{_ISupportsExitSignalCapturing}.
        c                   ó   — e Zd ZdZd„ Zd„ ZdS )úiApplicationRunnerTests.test_applicationRunnerIgnoresNoSignal.<locals>.DummyReactorWithExitSignalAttributer�  c                 ó   — dS rƒ  rX   rc   s    r4   r„  zvApplicationRunnerTests.test_applicationRunnerIgnoresNoSignal.<locals>.DummyReactorWithExitSignalAttribute.installWakerÙ  r!  r6   c                 ó   — d| _         dS )z‚
                A fake run method setting _exitSignal to a nonzero value
                that should be ignored.
                r†  Nr‡  rc   s    r4   r5  zmApplicationRunnerTests.test_applicationRunnerIgnoresNoSignal.<locals>.DummyReactorWithExitSignalAttribute.runÞ  s   € ð
 $%�Ô Ð Ð r6   Nr‰  rX   r6   r4   Ú#DummyReactorWithExitSignalAttributer�  Ó  s<   € € € € € ðð ð
ð ð ð
%ð %ð %ð %ð %r6   r’  Fr$   rv  N)r
   r%  rM  r‹  rˆ  )rQ   r’  r¢   r  s       r4   Ú%test_applicationRunnerIgnoresNoSignalz<ApplicationRunnerTests.test_applicationRunnerIgnoresNoSignalÍ  s’   € ð	%ð 	%ð 	%ð 	%ð 	%ñ 	%ô 	%ð 	%ð$ 6Ð5Ñ7Ô7ˆÝÔ&Ø¨9¸uÐEÐEñ
ô 
ˆð 	×Ò˜G T¨4Ñ0Ô0Ð0Ø×Ò˜$ Ô 2Ñ3Ô3Ð3Ð3Ð3r6   )rS   rT   rU   rV   r  r8  r:  ri  r   Úgetattrr:   rp  rt  r{  r}  rŒ  r“  rX   r6   r4   r-  r-  ú  s  € € € € € ðð ðð ð ð
ð 
ð 
ð,
:ð 
:ð 
:ðG
ð G
ð G
ðR €VØˆG�B˜ $Ñ'Ô'Ð'Ø?ñô ð
ð 
ñ	ô ð
ð €VØˆG�B˜ $Ñ'Ô'Ð'Ø?ñô ð
ð 
ñ	ô ð
ð 	Sð 	Sð 	Sð
(ð 
(ð 
(ð1ð 1ð 1ð<4ð 4ð 4ð 4ð 4r6   r-  c                   ón   — e Zd ZdZ e¦   «         Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ ZdS )Ú*UnixApplicationRunnerSetupEnvironmentTestsaº  
    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                 ó´  ‡ — ‰ j         ‰ _        ‰ j         ‰ _        ‰ j         ‰ _        d‰ _        t          j        ¦   «         ‰ _        ‰                      t
          dˆ fd„¦  «         ‰                      t
          dˆ fd„¦  «         ‰                      t
          dˆ fd„¦  «         t          t          j        ¦   «         ¦  «        ‰ _        ‰ j        ‰ j        _        d S )NFrA  c                 ó&   •— t          ‰d| ¦  «        S )NÚroot©Úsetattr©râ   rQ   s    €r4   rá   zBUnixApplicationRunnerSetupEnvironmentTests.setUp.<locals>.<lambda>  s   ø€ ­g°d¸FÀDÑ.IÔ.I€ r6   Úchdirc                 ó&   •— t          ‰d| ¦  «        S )NÚcwdrš  rœ  s    €r4   rá   zBUnixApplicationRunnerSetupEnvironmentTests.setUp.<locals>.<lambda>  s   ø€ ­W°T¸5À$Ñ-GÔ-G€ r6   rµ   c                 ó&   •— t          ‰d| ¦  «        S )NÚmaskrš  )r¡  rQ   s    €r4   rá   zBUnixApplicationRunnerSetupEnvironmentTests.setUp.<locals>.<lambda>  s   ø€ ­W°T¸6À4Ñ-HÔ-H€ r6   )Úunsetr™  rŸ  r¡  Údaemonr:   rÿ   rñ   rD   r!   r   r}   r  Ú	daemonizerc   s   `r4   r  z0UnixApplicationRunnerSetupEnvironmentTests.setUp  s¼   ø€ Ø”JˆŒ	Ø”:ˆŒØ”JˆŒ	ØˆŒÝ”9‘;”;ˆŒØ�
Š
•2�xÐ!IÐ!IÐ!IÐ!IÑJÔJÐJØ�
Š
•2�wÐ GÐ GÐ GÐ GÑHÔHÐHØ�
Š
•2�wÐ HÐ HÐ HÐ HÑIÔIÐIÝ+­FÔ,@Ñ,BÔ,BÑCÔCˆŒØ $¤ˆŒÔÐÐr6   c                 óT   ‡ — d‰ _         ‰                      t          dˆ fd„¦  «         dS )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                  ó   •— ‰ j         dz   S ©Nr÷   )rñ   rc   s   €r4   rá   zFUnixApplicationRunnerSetupEnvironmentTests.daemonize.<locals>.<lambda>  s   ø€ ¨¬°A©€ r6   N)r£  rD   r:   ©rQ   r¢   s   ` r4   r¤  z4UnixApplicationRunnerSetupEnvironmentTests.daemonize  s2   ø€ ð
 ˆŒØ�
Š
•2�xÐ!5Ð!5Ð!5Ð!5Ñ6Ô6Ð6Ð6Ð6r6   c                 óx   — | j                              ddddd¦  «         |                      | j        d¦  «         dS )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  rE  rz   r™  rc   s    r4   Útest_chrootz6UnixApplicationRunnerSetupEnvironmentTests.test_chroot  s@   € ð
 	Œ×$Ò$ Z°°d¸DÀ$ÑGÔGÐGØ×Ò˜œ JÑ/Ô/Ð/Ð/Ð/r6   c                 ó‚   — | j                              ddddd¦  «         |                      | j        | j        ¦  «         dS )z�
        L{UnixApplicationRunner.setupEnvironment} does not change the root of
        the filesystem if passed L{None} for the C{chroot} parameter.
        Nr«  T)r  rE  rÓ   r™  r¢  rc   s    r4   Útest_noChrootz8UnixApplicationRunnerSetupEnvironmentTests.test_noChroot!  s@   € ð
 	Œ×$Ò$ T¨3°°d¸DÑAÔAÐAØ�Š�d”i ¤Ñ,Ô,Ð,Ð,Ð,r6   c                 óx   — | j                              ddddd¦  «         |                      | j        d¦  «         dS )zŸ
        L{UnixApplicationRunner.setupEnvironment} changes the working directory
        of the process to the path given for the C{rundir} parameter.
        Nrª  T)r  rE  rz   rŸ  rc   s    r4   Útest_changeWorkingDirectoryzFUnixApplicationRunnerSetupEnvironmentTests.test_changeWorkingDirectory)  s@   € ð
 	Œ×$Ò$ T¨:°t¸TÀ4ÑHÔHÐHØ×Ò˜œ :Ñ.Ô.Ð.Ð.Ð.r6   c                 óÜ   — t          t          ¦   «         ¦  «        5  | j                             ddddd¦  «         ddd¦  «         n# 1 swxY w Y   |                      | j        ¦  «         dS )z�
        L{UnixApplicationRunner.setupEnvironment} daemonizes the process if
        C{False} is passed for the C{nodaemon} parameter.
        Nr«  F)r   ÚFakeDaemonizingReactorr  rE  r§   r£  rc   s    r4   Útest_daemonizez9UnixApplicationRunnerSetupEnvironmentTests.test_daemonize1  s·   € õ
 Õ4Ñ6Ô6Ñ7Ô7ð 	Gð 	GØŒK×(Ò(¨¨s°E¸4ÀÑFÔFÐFð	Gð 	Gð 	Gñ 	Gô 	Gð 	Gð 	Gð 	Gð 	Gð 	Gð 	Gøøøð 	Gð 	Gð 	Gð 	Gà�Š˜œÑ$Ô$Ð$Ð$Ð$ó   œAÁAÁAc                 óv   — | j                              ddddd¦  «         |                      | j        ¦  «         dS )z–
        L{UnixApplicationRunner.setupEnvironment} does not daemonize the
        process if C{True} is passed for the C{nodaemon} parameter.
        Nr«  T)r  rE  r«   r£  rc   s    r4   Útest_noDaemonizez;UnixApplicationRunnerSetupEnvironmentTests.test_noDaemonize:  s>   € ð
 	Œ×$Ò$ T¨3°°d¸DÑAÔAÐAØ×Ò˜œÑ%Ô%Ð%Ð%Ð%r6   c                 ó2  — |                       ¦   «         }| j                             dddd|¦  «         t          |d¦  «        5 }t	          |                     ¦   «         ¦  «        }ddd¦  «         n# 1 swxY w Y   |                      || j        ¦  «         dS )z�
        L{UnixApplicationRunner.setupEnvironment} writes the process's PID to
        the file specified by the C{pidfile} parameter.
        Nr«  TÚrb)ræ   r  rE  rç   ÚintÚreadrz   rñ   ©rQ   ré   rê   rñ   s       r4   Útest_nonDaemonPIDFilez@UnixApplicationRunnerSetupEnvironmentTests.test_nonDaemonPIDFileB  sÂ   € ð
 —+’+‘-”-ˆØŒ×$Ò$ T¨3°°d¸GÑDÔDÐDÝ�'˜4Ñ Ô ð 	  AÝ�a—f’f‘h”h‘-”-ˆCð	 ð 	 ð 	 ñ 	 ô 	 ð 	 ð 	 ð 	 ð 	 ð 	 ð 	 øøøð 	 ð 	 ð 	 ð 	 à×Ò˜˜dœhÑ'Ô'Ð'Ð'Ð's   Á"A1Á1A5Á8A5c                 óž  — |                       ¦   «         }t          t          ¦   «         ¦  «        5  | j                             dddd|¦  «         ddd¦  «         n# 1 swxY w Y   t          |d¦  «        5 }t          |                     ¦   «         ¦  «        }ddd¦  «         n# 1 swxY w Y   |                      || j	        dz   ¦  «         dS )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²  r  rE  rç   r¹  rº  rz   rñ   r»  s       r4   Útest_daemonPIDFilez=UnixApplicationRunnerSetupEnvironmentTests.test_daemonPIDFileM  sA  € ð —+’+‘-”-ˆÝÕ4Ñ6Ô6Ñ7Ô7ð 	Jð 	JØŒK×(Ò(¨¨s°E¸4ÀÑIÔIÐIð	Jð 	Jð 	Jñ 	Jô 	Jð 	Jð 	Jð 	Jð 	Jð 	Jð 	Jøøøð 	Jð 	Jð 	Jð 	Jå�'˜4Ñ Ô ð 	  AÝ�a—f’f‘h”h‘-”-ˆCð	 ð 	 ð 	 ñ 	 ô 	 ð 	 ð 	 ð 	 ð 	 ð 	 ð 	 øøøð 	 ð 	 ð 	 ð 	 à×Ò˜˜dœh¨™lÑ+Ô+Ð+Ð+Ð+s#   °AÁAÁ"AÁ6"B$Â$B(Â+B(c                 óÞ   — t          t          ¦   «         ¦  «        5  | j                             ddddd¦  «         ddd¦  «         n# 1 swxY w Y   |                      | j        d¦  «         dS )z�
        L{UnixApplicationRunner.setupEnvironment} changes the process umask to
        the value specified by the C{umask} parameter.
        Nr«  Fé{   ©r   r²  r  rE  rz   r¡  rc   s    r4   r¼   z5UnixApplicationRunnerSetupEnvironmentTests.test_umaskZ  s»   € õ
 Õ4Ñ6Ô6Ñ7Ô7ð 	Fð 	FØŒK×(Ò(¨¨s°E¸3ÀÑEÔEÐEð	Fð 	Fð 	Fñ 	Fô 	Fð 	Fð 	Fð 	Fð 	Fð 	Fð 	Føøøð 	Fð 	Fð 	Fð 	Fà×Ò˜œ CÑ(Ô(Ð(Ð(Ð(r´  c                 ó‚   — | j                              ddddd¦  «         |                      | j        | j        ¦  «         dS )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  rE  rÓ   r¡  r¢  rc   s    r4   Útest_noDaemonizeNoUmaskzBUnixApplicationRunnerSetupEnvironmentTests.test_noDaemonizeNoUmaskc  s@   € ð 	Œ×$Ò$ T¨3°°d¸DÑAÔAÐAØ�Š�d”i ¤Ñ,Ô,Ð,Ð,Ð,r6   c                 óÞ   — t          t          ¦   «         ¦  «        5  | j                             ddddd¦  «         ddd¦  «         n# 1 swxY w Y   |                      | j        d¦  «         dS )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«  Fé?   rÁ  rc   s    r4   Útest_daemonizedNoUmaskzAUnixApplicationRunnerSetupEnvironmentTests.test_daemonizedNoUmaskl  s»   € õ Õ4Ñ6Ô6Ñ7Ô7ð 	Gð 	GØŒK×(Ò(¨¨s°E¸4ÀÑFÔFÐFð	Gð 	Gð 	Gñ 	Gô 	Gð 	Gð 	Gð 	Gð 	Gð 	Gð 	Gøøøð 	Gð 	Gð 	Gð 	Gà×Ò˜œ EÑ*Ô*Ð*Ð*Ð*r´  N)rS   rT   rU   rV   r2  r¢  r  r¤  r¬  r®  r°  r³  r¶  r¼  r¾  r¼   rÃ  rÆ  rX   r6   r4   r–  r–  í  sß   € € € € € ðð ð( ˆF‰HŒH€Eð
/ð 
/ð 
/ð7ð 7ð 7ð0ð 0ð 0ð-ð -ð -ð/ð /ð /ð%ð %ð %ð&ð &ð &ð	(ð 	(ð 	(ð,ð ,ð ,ð)ð )ð )ð-ð -ð -ð+ð +ð +ð +ð +r6   r–  c                   ó6   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	dS )	Ú*UnixApplicationRunnerStartApplicationTestsz>
    Tests for L{UnixApplicationRunner.startApplication}.
    c                 óÀ  ‡— t          j        ¦   «         }|                     g d¢¦  «         t          j        d¦  «        }t          |¦  «        | _        g Šˆfd„}t          j        | j        j	        ¦  «        j
        }t          j        |¦  «        j
        }|                     ¦   «         }|                     d¦  «         |                      ||¦  «         |                      t
          d|¦  «         |                      t
          dd„ ¦  «         |                      t          dd	„ ¦  «         | j                             |¦  «         |                      ‰g d
¢¦  «         dS )zó
        L{UnixApplicationRunner.startApplication} calls
        L{UnixApplicationRunner.setupEnvironment} with the chroot, rundir,
        nodaemon, umask, and pidfile parameters from the configuration it is
        constructed with.
        )	ú
--nodaemonr¸   Ú0070z--chrootú/foo/chrootz--rundirú/foo/rundirú	--pidfileú/foo/pidfileÚtest_setupEnvironmentc                 ó<   •— ‰                      |||||f¦  «         d S r)   )Úextend)rQ   rA  rB  rC  rµ   ré   rÄ   s         €r4   ÚfakeSetupEnvironmentz^UnixApplicationRunnerStartApplicationTests.test_setupEnvironment.<locals>.fakeSetupEnvironment—  s&   ø€ Ø�KŠK˜ ¨°5¸'ÐBÑCÔCÐCÐCÐCr6   rQ   rE  rI  c                  ó   — d S r)   rX   ©ÚaÚkws     r4   rá   zRUnixApplicationRunnerStartApplicationTests.test_setupEnvironment.<locals>.<lambda>«  s   € ÈT€ r6   ÚstartApplicationc                  ó   — d S r)   rX   rÕ  s     r4   rá   zRUnixApplicationRunnerStartApplicationTests.test_setupEnvironment.<locals>.<lambda>¬  s   € ¸T€ r6   )rÌ  rÍ  Té8   rÏ  N)r   r}   rž   r   r  r!   r  ÚinspectÚ	signaturerE  Ú
parametersÚcopyÚpoprz   rD   r
   rØ  )rQ   rN   r]   rÓ  ÚsetupEnvironmentParametersÚfakeSetupEnvironmentParametersrÄ   s         @r4   rÐ  z@UnixApplicationRunnerStartApplicationTests.test_setupEnvironment}  sˆ  ø€ õ Ô&Ñ(Ô(ˆØ×Òð
ð 
ð 
ñ	
ô 	
ð 	
õ Ô)Ð*AÑBÔBˆÝ+¨GÑ4Ô4ˆŒàˆð	Dð 	Dð 	Dð 	Dð 	Dõ &-Ô%6ØŒKÔ(ñ&
ô &
ä
ð 	#õ *1Ô):Ø ñ*
ô *
ä
ð 	'ð *H×)LÒ)LÑ)NÔ)NÐ&Ø&×*Ò*¨6Ñ2Ô2Ð2à×ÒÐ3Ð5SÑTÔTÐTà�
Š
Õ(Ð*<Ð>RÑSÔSÐSØ�
Š
Õ(Ð*:Ð<QÐ<QÑRÔRÐRØ�
Š
•3Ð*Ð,AÐ,AÑBÔBÐBØŒ×$Ò$ [Ñ1Ô1Ð1à×Ò˜ÐWÐWÐWÑXÔXÐXÐXÐXr6   c                 ó–   ‡ — ˆ fd„}‰                       t          d|¦  «         t          i ¦  «        }|                     ddd¦  «         dS )zf
        L{UnixApplicationRunner.shedPrivileges} switches the user ID
        of the process.
        c                 óŒ   •— ‰                      | d¦  «         ‰                      |d¦  «         ‰                      |d¦  «         d S )NéÈ   é6   é#   ©rz   )rF   r1   rH  rQ   s      €r4   ÚswitchUIDPasszUUnixApplicationRunnerStartApplicationTests.test_shedPrivileges.<locals>.switchUIDPass·  sK   ø€ Ø×Ò˜S #Ñ&Ô&Ð&Ø×Ò˜S "Ñ%Ô%Ð%Ø×Ò˜T 2Ñ&Ô&Ð&Ð&Ð&r6   Ú	switchUIDræ  rä  rå  N)rD   rÙ   r!   rI  )rQ   rè  r  s   `  r4   Útest_shedPrivilegesz>UnixApplicationRunnerStartApplicationTests.test_shedPrivileges±  s_   ø€ ð	'ð 	'ð 	'ð 	'ð 	'ð
 	�
Š
•< ¨mÑ<Ô<Ð<Ý& rÑ*Ô*ˆØ×Ò˜b # rÑ*Ô*Ð*Ð*Ð*r6   c                 óÞ   — d„ }t          i ¦  «        }|                      t          d|¦  «         |                      t          |j        ddd¦  «        }|                      |j        d¦  «         dS )z 
        An unexpected L{OSError} when calling
        L{twisted.scripts._twistd_unix.shedPrivileges}
        terminates the process via L{SystemExit}.
        c                 ó6   — t          t          j        d¦  «        ‚rù   r  )rF   r1   rH  s      r4   ÚswitchUIDFailzZUnixApplicationRunnerStartApplicationTests.test_shedPrivilegesError.<locals>.switchUIDFailÇ  rþ   r6   ré  ræ  rä  Nr÷   )r!   rD   rÙ   rœ   r�   rI  rz   rÔ   )rQ   rí  r  Úexcs       r4   Útest_shedPrivilegesErrorzCUnixApplicationRunnerStartApplicationTests.test_shedPrivilegesErrorÀ  sr   € ð	/ð 	/ð 	/õ ' rÑ*Ô*ˆØ�
Š
•< ¨mÑ<Ô<Ð<Ø×Ò¥
¨FÔ,AÀ2ÀsÈDÑQÔQˆØ×Ò˜œ 1Ñ%Ô%Ð%Ð%Ð%r6   c                 ó  ‡ ‡‡— t          ‰ j        |‰|‰¦  «         ˆ ˆˆfd„}ˆ ˆfd„}ˆ ˆfd„}‰                      t          d|¦  «         ‰                      t          d|¦  «         ‰                      t          d|¦  «         t	          j        ¦   «         }	|	                     ddt          ‰¦  «        d	|g¦  «         t          j	        d
¦  «        }
t          |	¦  «        ‰ _        t          |	¦  «        }|                     |
¦  «         dS )zj
        Common code for tests which try to pass the the UID to
        L{UnixApplicationRunner}.
        c                 ó`   •— ‰                      | ‰¦  «         ‰                      |‰¦  «         d S r)   rç  )rF   r1   rQ   Ú	wantedGidÚ	wantedUids     €€€r4   Ú
initgroupszFUnixApplicationRunnerStartApplicationTests._setUID.<locals>.initgroupsÖ  s5   ø€ Ø×Ò˜S )Ñ,Ô,Ð,Ø×Ò˜S )Ñ,Ô,Ð,Ð,Ð,r6   c                 ó4   •— ‰                      | ‰¦  «         d S r)   rç  )rF   rQ   ró  s    €€r4   rj  zBUnixApplicationRunnerStartApplicationTests._setUID.<locals>.setuidÚ  ó   ø€ Ø×Ò˜S )Ñ,Ô,Ð,Ð,Ð,r6   c                 ó4   •— ‰                      | ‰¦  «         d S r)   rç  )r1   rQ   rò  s    €€r4   ÚsetgidzBUnixApplicationRunnerStartApplicationTests._setUID.<locals>.setgidÝ  rö  r6   rô  rj  rø  rÊ  rn  rÎ  rÐ  N)rI   rD   r   r:   r   r}   rž   r®   r   r  r!   r  rØ  )rQ   Ú
wantedUserró  ÚwantedGrouprò  ÚpidFilerô  rj  rø  rN   r]   r  s   ` ` `       r4   Ú_setUIDz2UnixApplicationRunnerStartApplicationTests._setUIDÏ  sE  øøø€ õ
 	˜$œ* j°)¸[È)ÑTÔTÐTð	-ð 	-ð 	-ð 	-ð 	-ð 	-ð 	-ð	-ð 	-ð 	-ð 	-ð 	-ð 	-ð	-ð 	-ð 	-ð 	-ð 	-ð 	-ð 	�
Š
•4˜ zÑ2Ô2Ð2Ø�
Š
•2�x Ñ(Ô(Ð(Ø�
Š
•2�x Ñ(Ô(Ð(åÔ&Ñ(Ô(ˆØ×ÒØ˜7¥C¨	¡N¤N°KÀÐIñ	
ô 	
ð 	
õ Ô)Ð*AÑBÔBˆÝ+¨GÑ4Ô4ˆŒÝ& wÑ/Ô/ˆØ×Ò Ñ,Ô,Ð,Ð,Ð,r6   c                 ób   — |                       dddd|                      ¦   «         dz   ¦  «         dS )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.
        rr  i  rs  i’  z_test_setUidWithoutGid.pidN)rü  ræ   rc   s    r4   Útest_setUidWithoutGidz@UnixApplicationRunnerStartApplicationTests.test_setUidWithoutGidí  s=   € ð 	�ŠØ�4˜  d§k¢k¡m¤mÐ6RÑ&Rñ	
ô 	
ð 	
ð 	
ð 	
r6   c                 ó>  — t          j        ¦   «         }|                      d|ddd¦  «         |                      ¦   «         }d                     ||¦  «        }|                      ||d         d         ¦  «         |                      dt          |¦  «        |¦  «         d	S )
zz
        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.r   Úmessager÷   N)r:   r;   rü  ÚflushWarningsr¡   rz   Úlen)rQ   Ú
currentUidÚwarningsShownÚexpectedWarnings       r4   Útest_setUidSameAsCurrentUidzFUnixApplicationRunnerStartApplicationTests.test_setUidSameAsCurrentUid÷  s¥   € õ
 ”Y‘[”[ˆ
Ø�ŠØ�z 9¨dÐ4Uñ	
ô 	
ð 	
ð ×*Ò*Ñ,Ô,ˆð-ß-3ªV°JÀ
Ñ-KÔ-Kð 	ð 	×Ò˜¨-¸Ô*:¸9Ô*EÑFÔFÐFØ×Ò˜�C Ñ.Ô.°Ñ>Ô>Ð>Ð>Ð>r6   N)
rS   rT   rU   rV   rÐ  rê  rï  rü  rþ  r  rX   r6   r4   rÈ  rÈ  w  s|   € € € € € ðð ð2Yð 2Yð 2Yðh+ð +ð +ð&ð &ð &ð-ð -ð -ð<
ð 
ð 
ð?ð ?ð ?ð ?ð ?r6   rÈ  c                   ó   — e Zd ZdZd„ Zd„ ZdS )Ú#UnixApplicationRunnerRemovePIDTestsz7
    Tests for L{UnixApplicationRunner.removePID}.
    c                 ó†  — t          i ¦  «        }|                      ¦   «         }t          j        |¦  «         t          j                             |d¦  «        }t          |d¦  «                             ¦   «          |                     |¦  «         |  	                    t          j         
                    |¦  «        ¦  «         dS )zp
        L{UnixApplicationRunner.removePID} deletes the file the name of
        which is passed to it.
        zfoo.pidrå   N)r!   ræ   r:   Úmakedirsrâ   Újoinrç   ÚcloserO  r«   rÝ   )rQ   r  râ   ré   s       r4   Útest_removePIDz2UnixApplicationRunnerRemovePIDTests.test_removePID  s›   € õ
 ' rÑ*Ô*ˆØ�{Š{‰}Œ}ˆÝ
Œ�DÑÔÐÝ”'—,’,˜t YÑ/Ô/ˆÝˆW�cÑÔ× Ò Ñ"Ô"Ð"Ø×Ò˜Ñ!Ô!Ð!Ø×Ò�œŸš¨Ñ0Ô0Ñ1Ô1Ð1Ð1Ð1r6   c                 ó(  — t          i ¦  «        }|                     d¦  «         |                      t          ¦  «        }|                      t          |¦  «        d¦  «         |                      |d         j        j        t          j        ¦  «         dS )zr
        Calling L{UnixApplicationRunner.removePID} with a non-existent filename
        logs an OSError.
        Úfakepidr÷   r   N)	r!   rO  ÚflushLoggedErrorsrû   rz   r  Úvaluerü   ÚENOENT)rQ   r  Úerrorss      r4   Útest_removePIDErrorsz8UnixApplicationRunnerRemovePIDTests.test_removePIDErrors  s{   € õ
 ' rÑ*Ô*ˆØ×Ò˜Ñ#Ô#Ð#Ø×'Ò'­Ñ0Ô0ˆØ×Ò�˜V™œ aÑ(Ô(Ð(Ø×Ò˜ œœÔ.µ´Ñ=Ô=Ð=Ð=Ð=r6   N)rS   rT   rU   rV   r  r  rX   r6   r4   r
  r
  
  s<   € € € € € ðð ð2ð 2ð 2ð	>ð 	>ð 	>ð 	>ð 	>r6   r
  c                   ó*   — e Zd ZdZd„ Zd„ Zd„ Zd„ ZdS )ÚFakeNonDaemonizingReactora›  
    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                 ó"   — d| _         d| _        d S rß   )Ú_beforeDaemonizeCalledÚ_afterDaemonizeCalledrc   s    r4   rr   z"FakeNonDaemonizingReactor.__init__5  s   € Ø&+ˆÔ#Ø%*ˆÔ"Ð"Ð"r6   c                 ó   — d| _         d S ©NT)r  rc   s    r4   ÚbeforeDaemonizez)FakeNonDaemonizingReactor.beforeDaemonize9  s   € Ø&*ˆÔ#Ð#Ð#r6   c                 ó   — d| _         d S r  )r  rc   s    r4   ÚafterDaemonizez(FakeNonDaemonizingReactor.afterDaemonize<  s   € Ø%)ˆÔ"Ð"Ð"r6   c                 ó   — dS )z*
        Skip event registration.
        NrX   )rQ   rÄ   r×  s      r4   ÚaddSystemEventTriggerz/FakeNonDaemonizingReactor.addSystemEventTrigger?  r!  r6   N)rS   rT   rU   rV   rr   r  r   r"  rX   r6   r4   r  r  )  sZ   € € € € € ð	ð 	ð+ð +ð +ð+ð +ð +ð*ð *ð *ðð ð ð ð r6   r  c                   ó   — e Zd ZdZdS )r²  z�
    A dummy reactor, providing C{beforeDaemonize} and C{afterDaemonize}
    methods, announcing this, and logging whether the methods have been called.
    N)rS   rT   rU   rV   rX   r6   r4   r²  r²  E  s   € € € € € ðð ð ð r6   r²  c                   ó   — e Zd ZdZdZd„ ZdS )rx  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                 ó@   — | j         rt          d¦  «        ‚d| _         dS )zV
        A fake run method, checking that it's been called one and only time.
        zAlready calledTN)ry  ÚRuntimeErrorrc   s    r4   r5  zDummyReactor.runX  s(   € ð Œ;ð 	1ÝÐ/Ñ0Ô0Ð0ØˆŒˆˆr6   N)rS   rT   rU   rV   ry  r5  rX   r6   r4   rx  rx  M  s4   € € € € € ðð ð €Fðð ð ð ð r6   rx  c                   ó  — e Zd ZdZ ee d¦  «        d„ ¦   «         Zd„ Z ee d¦  «        d„ ¦   «         Zd„ Z	 ee d¦  «        d„ ¦   «         Z
 ee d¦  «        d	„ ¦   «         Z ee d¦  «        d
„ ¦   «         Zd„ Zd„ Zd„ Zd„ ZdS )ÚAppProfilingTestsz'
    Tests for L{app.AppProfiler}.
    zprofile module not availablec                 óà  — t          j        ¦   «         }|                      ¦   «         |d<   d|d<   t          j        |¦  «        }t          ¦   «         }|                     |¦  «         |                      |j        ¦  «         t          |d         ¦  «        5 }| 
                    ¦   «         }ddd¦  «         n# 1 swxY w Y   |                      d|¦  «         |                      d|¦  «         dS )zŒ
        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¯   rx  r5  r§   ry  rç   rº  r”   ©rQ   r‚   r±   r¢   rê   Údatas         r4   Útest_profilezAppProfilingTests.test_profilef  s  € õ Ô%Ñ'Ô'ˆØ ŸKšK™MœMˆˆyÑØ&ˆˆzÑÝ”? 6Ñ*Ô*ˆÝ‘.”.ˆà�Š�WÑÔÐà�Š˜œÑ'Ô'Ð'Ý�&˜Ô#Ñ$Ô$ð 	¨Ø—6’6‘8”8ˆDð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	à�ŠÐ(¨$Ñ/Ô/Ð/Ø�ŠÐ&¨Ñ-Ô-Ð-Ð-Ð-ó   ÂB7Â7B;Â>B;c                 ó@  — t          ¦   «         }|                      t          d|¦  «        } ||¦  «        }|                     ¦   «          |                     ¦   «          |                     ¦   «         }|                      d|¦  «         |                      d|¦  «         d S )NrÐ   r*  z(run))r   rD   ÚsysÚprint_statsÚrestorerŸ   r”   )rQ   Ú
statsClassr$   ÚoutrÐ   Ústatsr-  s          r4   Ú
_testStatszAppProfilingTests._testStatsz  s‘   € Ý‰jŒjˆð —’�C ¨3Ñ/Ô/ˆð �
˜7Ñ#Ô#ˆØ×ÒÑÔÐØ�ŠÑÔÐà�|Š|‰~Œ~ˆØ�ŠÐ&¨Ñ-Ô-Ð-Ø�Š�g˜tÑ$Ô$Ð$Ð$Ð$r6   c                 ó\  — t          j        ¦   «         }|                      ¦   «         |d<   d|d<   d|d<   t          j        |¦  «        }t          ¦   «         }|                     |¦  «         |                      |j        ¦  «         |  	                    t          j        |d         ¦  «         dS )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¯   rx  r5  r§   ry  r7  r%   ÚStats©rQ   r‚   r±   r¢   s       r4   Útest_profileSaveStatsz'AppProfilingTests.test_profileSaveStats‹  s—   € õ Ô%Ñ'Ô'ˆØ ŸKšK™MœMˆˆyÑØ&ˆˆzÑØ"ˆˆ{ÑÝ”? 6Ñ*Ô*ˆÝ‘.”.ˆà�Š�WÑÔÐà�Š˜œÑ'Ô'Ð'Ø�Š�œ f¨YÔ&7Ñ8Ô8Ð8Ð8Ð8r6   c                 óú  — t           j                             ¦   «         }t          j        ¦   «         }d|d<   t          j        |¦  «        }dt           j        d<   	 |                      t          |j	        d¦  «         t           j         
                    ¦   «          t           j                             |¦  «         dS # t           j         
                    ¦   «          t           j                             |¦  «         w xY w)z†
        When the C{profile} module is not present, L{app.ProfilerRunner.run}
        should raise a C{SystemExit} exception.
        r$   r±   N©r1  ÚmodulesrÞ  r   r}   r
   r¯   rœ   r�   r5  ÚclearÚupdate©rQ   ÚsavedModulesr‚   r±   s       r4   Útest_withoutProfilez%AppProfilingTests.test_withoutProfile�  sÌ   € õ
 ”{×'Ò'Ñ)Ô)ˆåÔ%Ñ'Ô'ˆØ&ˆˆzÑÝ”? 6Ñ*Ô*ˆà!%�Œ�IÑð	-Ø×Ò�j¨(¬,¸Ñ=Ô=Ð=åŒK×ÒÑÔÐÝŒK×Ò˜|Ñ,Ô,Ð,Ð,Ð,øõ ŒK×ÒÑÔÐÝŒK×Ò˜|Ñ,Ô,Ð,Ð,øøøó   Á!B; Â;?C:c                 óª  —  G d„ dt           j        ¦  «        }|                      t           d|¦  «         t          j        ¦   «         }|                      ¦   «         |d<   d|d<   t          j        |¦  «        }t          ¦   «         }t          j
        }|                      t          |j        |¦  «         |                      t          j
        |¦  «         dS )z…
        When an error happens during the print of the stats, C{sys.stdout}
        should be restored to its initial value.
        c                   ó   — e Zd Zd„ ZdS )úGAppProfilingTests.test_profilePrintStatsError.<locals>.ErroneousProfilec                 ó    — t          d¦  «        ‚)NÚBoom©r&  rc   s    r4   r2  zSAppProfilingTests.test_profilePrintStatsError.<locals>.ErroneousProfile.print_stats·  s   € Ý" 6Ñ*Ô*Ð*r6   N)rS   rT   rU   r2  rX   r6   r4   ÚErroneousProfilerI  ¶  s#   € € € € € ð+ð +ð +ð +ð +r6   rM  ÚProfiler$   r±   N)r$   rN  rD   r   r}   ræ   r
   r¯   rx  r1  rÐ   rœ   r&  r5  rÓ   )rQ   rM  r‚   r±   r¢   Ú	oldStdouts         r4   Útest_profilePrintStatsErrorz-AppProfilingTests.test_profilePrintStatsError¯  sÆ   € ð	+ð 	+ð 	+ð 	+ð 	+�wœñ 	+ô 	+ð 	+ð 	�
Š
•7˜IÐ'7Ñ8Ô8Ð8åÔ%Ñ'Ô'ˆØ ŸKšK™MœMˆˆyÑØ&ˆˆzÑÝ”? 6Ñ*Ô*ˆÝ‘.”.ˆå”Jˆ	Ø×Ò�,¨¬°gÑ>Ô>Ð>Ø�Š•c”j )Ñ,Ô,Ð,Ð,Ð,r6   zcProfile module not availablec                 óà  — t          j        ¦   «         }|                      ¦   «         |d<   d|d<   t          j        |¦  «        }t          ¦   «         }|                     |¦  «         |                      |j        ¦  «         t          |d         ¦  «        5 }| 
                    ¦   «         }ddd¦  «         n# 1 swxY w Y   |                      d|¦  «         |                      d|¦  «         dS )z�
        L{app.CProfileRunner.run} should call the C{run} method of the
        reactor and save profile data in the specified file.
        r$   r&   r±   Nr5  r*  r+  r,  s         r4   Útest_cProfilezAppProfilingTests.test_cProfileÆ  s  € õ Ô%Ñ'Ô'ˆØ ŸKšK™MœMˆˆyÑØ'ˆˆzÑÝ”? 6Ñ*Ô*ˆÝ‘.”.ˆà�Š�WÑÔÐà�Š˜œÑ'Ô'Ð'Ý�&˜Ô#Ñ$Ô$ð 	¨Ø—6’6‘8”8ˆDð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	à�Š�e˜TÑ"Ô"Ð"Ø�ŠÐ&¨Ñ-Ô-Ð-Ð-Ð-r/  c                 ó\  — t          j        ¦   «         }|                      ¦   «         |d<   d|d<   d|d<   t          j        |¦  «        }t          ¦   «         }|                     |¦  «         |                      |j        ¦  «         |  	                    t          j        |d         ¦  «         dS )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±   Tr9  Nr:  r<  s       r4   Útest_cProfileSaveStatsz(AppProfilingTests.test_cProfileSaveStatsÚ  s—   € õ Ô%Ñ'Ô'ˆØ ŸKšK™MœMˆˆyÑØ'ˆˆzÑØ"ˆˆ{ÑÝ”? 6Ñ*Ô*ˆÝ‘.”.ˆà�Š�WÑÔÐà�Š˜œÑ'Ô'Ð'Ø�Š�œ f¨YÔ&7Ñ8Ô8Ð8Ð8Ð8r6   c                 óú  — t           j                             ¦   «         }dt           j        d<   t          j        ¦   «         }d|d<   t          j        |¦  «        }	 |                      t          |j	        d¦  «         t           j         
                    ¦   «          t           j                             |¦  «         dS # t           j         
                    ¦   «          t           j                             |¦  «         w xY w)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?  rC  s       r4   Útest_withoutCProfilez&AppProfilingTests.test_withoutCProfileí  sÌ   € õ ”{×'Ò'Ñ)Ô)ˆØ"&�Œ�JÑåÔ%Ñ'Ô'ˆØ'ˆˆzÑÝ”? 6Ñ*Ô*ˆð	-Ø×Ò�j¨(¬,¸Ñ=Ô=Ð=åŒK×ÒÑÔÐÝŒK×Ò˜|Ñ,Ô,Ð,Ð,Ð,øõ ŒK×ÒÑÔÐÝŒK×Ò˜|Ñ,Ô,Ð,Ð,øøørF  c                 óö   — t          j        ¦   «         }|                      ¦   «         |d<   d|d<   |                      t          t
          j        |¦  «        }|                      t          |¦  «        d¦  «         dS )zq
        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¯   rz   r®   )rQ   r‚   Úerrors      r4   Útest_unknownProfilerz&AppProfilingTests.test_unknownProfilerÿ  sj   € õ
 Ô%Ñ'Ô'ˆØ ŸKšK™MœMˆˆyÑØ%ˆˆzÑà×!Ò!¥*­c¬o¸vÑFÔFˆØ×Ò�˜U™œÐ%HÑIÔIÐIÐIÐIr6   c                 ód   — t          j        i ¦  «        }|                      |j        d¦  «         dS )zU
        L{app.Profiler} defaults to the cprofile profiler if not specified.
        ÚcprofileN©r
   r¯   rz   r±   ©rQ   r±   s     r4   Útest_defaultProfilerz&AppProfilingTests.test_defaultProfiler  s2   € õ ”? 2Ñ&Ô&ˆØ×Ò˜Ô*¨JÑ7Ô7Ð7Ð7Ð7r6   c                 óh   — t          j        ddi¦  «        }|                      |j        d¦  «         dS )ze
        The case of the profiler name passed to L{app.AppProfiler} is not
        relevant.
        r±   ÚCprOfiler\  Nr]  r^  s     r4   Útest_profilerNameCaseInsentivez0AppProfilingTests.test_profilerNameCaseInsentive  s7   € õ
 ”? J°
Ð#;Ñ<Ô<ˆØ×Ò˜Ô*¨JÑ7Ô7Ð7Ð7Ð7r6   N)rS   rT   rU   rV   r   r$   r.  r7  r=  rE  rP  r&   rR  rT  rV  rZ  r_  rb  rX   r6   r4   r(  r(  a  sR  € € € € € ðð ð €V�ˆKÐ7Ñ8Ô8ð.ð .ñ 9Ô8ð.ð&%ð %ð %ð" €V�ˆKÐ7Ñ8Ô8ð9ð 9ñ 9Ô8ð9ð"-ð -ð -ð$ €V�ˆKÐ7Ñ8Ô8ð-ð -ñ 9Ô8ð-ð, €V�ˆLÐ9Ñ:Ô:ð.ð .ñ ;Ô:ð.ð& €V�ˆLÐ9Ñ:Ô:ð9ð 9ñ ;Ô:ð9ð$-ð -ð -ð$
Jð 
Jð 
Jð8ð 8ð 8ð8ð 8ð 8ð 8ð 8r6   r(  c                 óV   ‡‡— g Št           j        Šˆˆfd„} | t           d|¦  «         ‰S )a  
    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                 óF   •— ‰                      | ¦  «          ‰| g|¢R i |¤ŽS r)   r@  )ÚlogFilerÄ   ÚkwargsÚlogFilesÚoldFileLogObservers      €€r4   Úobserverz+_patchTextFileLogObserver.<locals>.observer(  s6   ø€ Ø�Š˜Ñ Ô Ð Ø!Ð! 'Ð;¨DÐ;Ð;Ð;°FÐ;Ð;Ð;r6   ÚtextFileLogObserver)r   rj  )rD   ri  rg  rh  s     @@r4   Ú_patchTextFileLogObserverrk    sN   øø€ ð €HÝÔ3Ðð<ð <ð <ð <ð <ð <ð 
€E�&Ð'¨Ñ2Ô2Ð2Ø€Or6   c                 ób   ‡— g Š G ˆfd„d¦  «        }|                       t          d|¦  «         ‰S )zu
    Make fake syslog, and return list to which prefix and then log
    messages will be appended if it is used.
    c                   ó$   •— e Zd Zˆ fd„Zˆ fd„ZdS )ú(_setupSyslog.<locals>.fakesyslogobserverc                 ó2   •— ‰                      |¦  «         d S r)   r@  )rQ   ÚprefixÚlogMessagess     €r4   rr   z1_setupSyslog.<locals>.fakesyslogobserver.__init__8  s   ø€ Ø×Ò˜vÑ&Ô&Ð&Ð&Ð&r6   c                 ó2   •— ‰                      |¦  «         d S r)   r@  )rQ   Ú	eventDictrq  s     €r4   Úemitz-_setupSyslog.<locals>.fakesyslogobserver.emit;  s   ø€ Ø×Ò˜yÑ)Ô)Ð)Ð)Ð)r6   N)rS   rT   rU   rr   rt  )rq  s   €r4   Úfakesyslogobserverrn  7  sG   ø€ € € € € ð	'ð 	'ð 	'ð 	'ð 	'ð	*ð 	*ð 	*ð 	*ð 	*ð 	*ð 	*r6   ru  ÚSyslogObserver)rD   Úsyslog)ÚtestCaseru  rq  s     @r4   Ú_setupSyslogry  0  s\   ø€ ð
 €Kð*ð *ð *ð *ð *ð *ð *ñ *ô *ð *ð ‡N‚N•6Ð+Ð-?Ñ@Ô@Ð@ØÐr6   c                   óÚ   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	i e
j        fd„Zd	„ Zd
„ Zd„ Zd„ Z ee d¦  «         ee d¦  «        d„ ¦   «         ¦   «         Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚAppLoggerTestsz†
    Tests for L{app.AppLogger}.

    @ivar observers: list of observers installed during the tests.
    @type observers: C{list}
    c                 óX   ‡ — g ‰ _         ˆ fd„}‰                      t          d|¦  «         dS )zˆ
        Override L{globaLogBeginner.beginLoggingTo} so that we can trace the
        observers installed in C{self.observers}.
        c                 ón   •— | D ]0}‰j                              |¦  «         t          j        |¦  «         Œ1d S r)   )Ú	observersr•   r   ÚaddObserver)r~  ri  rQ   s     €r4   ÚbeginLoggingToz,AppLoggerTests.setUp.<locals>.beginLoggingToQ  sF   ø€ Ø%ð 9ð 9�Ø”×%Ò% hÑ/Ô/Ð/Ý"Ô.¨xÑ8Ô8Ð8Ð8ð9ð 9r6   r€  N)r~  rD   r   )rQ   r€  s   ` r4   r  zAppLoggerTests.setUpJ  sE   ø€ ð
 ˆŒð	9ð 	9ð 	9ð 	9ð 	9ð
 	�
Š
Õ$Ð&6¸ÑGÔGÐGÐGÐGr6   c                 óB   — | j         D ]}t          j        |¦  «         ŒdS )z1
        Remove all installed observers.
        N)r~  r   ÚremoveObserver©rQ   ri  s     r4   ÚtearDownzAppLoggerTests.tearDownX  s3   € ð œð 	8ð 	8ˆHÝÔ-¨hÑ7Ô7Ð7Ð7ð	8ð 	8r6   c                 ód   — t          t          ¦  «         G d„ d¦  «        ¦   «         } |¦   «         S )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                   ó   — e Zd Zg Zd„ ZdS )ú2AppLoggerTests._makeObserver.<locals>.TestObserverc                 ó:   — | j                              |¦  «         d S r)   )Ú_logsr•   )rQ   Úevents     r4   Ú__call__z;AppLoggerTests._makeObserver.<locals>.TestObserver.__call__k  s   € Ø”
×!Ò! %Ñ(Ô(Ð(Ð(Ð(r6   N)rS   rT   rU   r‰  r‹  rX   r6   r4   ÚTestObserverr‡  g  s(   € € € € € àˆEð)ð )ð )ð )ð )r6   rŒ  )r   r   )rQ   rŒ  s     r4   Ú_makeObserverzAppLoggerTests._makeObserver_  sM   € õ 
•\Ñ	"Ô	"ð	)ð 	)ð 	)ð 	)ð 	)ñ 	)ô 	)ñ 
#Ô	"ð	)ð ˆ|‰~Œ~Ðr6   c                 óÚ   — |                       | j        |g¦  «         |                      d|j        d         d         ¦  «         |                      d|j        d         d         ¦  «         dS )z�
        Ensure that initial C{twistd} logs are written to logs.

        @param observer: The observer made by L{self._makeObserver).
        ústarting upr   Ú
log_formatzreactor classr÷   N)rz   r~  r”   r‰  rƒ  s     r4   Ú_checkObserverzAppLoggerTests._checkObserverp  sd   € ð 	×Ò˜œ¨(¨Ñ4Ô4Ð4Ø�Š�m X¤^°AÔ%6°|Ô%DÑEÔEÐEØ�Š�o x¤~°aÔ'8¸Ô'FÑGÔGÐGÐGÐGr6   c                 óÎ   ‡— t          j        i ¦  «        }|                      ¦   «         Šˆfd„|_         |j        t          ¦   «         ¦  «         |                      ‰¦  «         dS )z”
        L{app.AppLogger.start} calls L{globalLogBeginner.addObserver}, and then
        writes some messages about twistd and the reactor.
        c                  ó   •— ‰ S r)   rX   ©ri  s   €r4   rá   z+AppLoggerTests.test_start.<locals>.<lambda>�  s   ø€ ¨€ r6   N)r
   Ú	AppLoggerr�  Ú_getLogObserverr^   r   r‘  )rQ   r   ri  s     @r4   Ú
test_startzAppLoggerTests.test_startz  sf   ø€ õ
 ”˜rÑ"Ô"ˆØ×%Ò%Ñ'Ô'ˆØ!1Ð!1Ð!1Ð!1ˆÔØˆŒ•]‘_”_Ñ%Ô%Ð%Ø×Ò˜HÑ%Ô%Ð%Ð%Ð%r6   c                 óò   — t          ¦   «         }|                      ¦   «         }|                     t          |¦  «         t	          j        i ¦  «        } |j        |¦  «         |                      |¦  «         dS )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•  r^   r‘  )rQ   r]   ri  r   s       r4   Ú$test_startUsesApplicationLogObserverz3AppLoggerTests.test_startUsesApplicationLogObserver…  so   € õ $‘o”oˆØ×%Ò%Ñ'Ô'ˆØ× Ò ¥¨xÑ8Ô8Ð8Ý”˜rÑ"Ô"ˆØˆŒ�[Ñ!Ô!Ð!Ø×Ò˜HÑ%Ô%Ð%Ð%Ð%r6   c                 óž   ‡— |                       ¦   «         Šdˆfd„i}|                     |¦  «          ||¦  «        } |j        |¦  «         ‰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)   rX   r”  s   €r4   rá   z7AppLoggerTests._setupConfiguredLogger.<locals>.<lambda>¤  s   ø€  X€ r6   )r�  rB  r^   )rQ   r]   ÚextraLogArgsÚ	appLoggerÚlogArgsr   ri  s         @r4   Ú_setupConfiguredLoggerz%AppLoggerTests._setupConfiguredLogger’  sb   ø€ ð" ×%Ò%Ñ'Ô'ˆØÐ-Ð-Ð-Ð-Ð.ˆØ�Š�|Ñ$Ô$Ð$Ø�˜7Ñ#Ô#ˆØˆŒ�[Ñ!Ô!Ð!Øˆr6   c                 ór   — t          ¦   «         }|                      |                      |¦  «        ¦  «         dS )a  
        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   r\   s     r4   Ú#test_startUsesConfiguredLogObserverz2AppLoggerTests.test_startUsesConfiguredLogObserverª  s5   € õ $‘o”oˆØ×Ò˜D×7Ò7¸ÑDÔDÑEÔEÐEÐEÐEr6   c                 ó  — |                       ¦   «         }t          ¦   «         }|                     t          |¦  «         |                      |                      |¦  «        ¦  «         |                      |j        g ¦  «         dS )zk
        C{--logger} takes precedence over a L{ILogObserver} component set on
        Application.
        N)r�  r   r™  r   r‘  r   rz   r‰  )rQ   ri  r]   s      r4   Ú(test_configuredLogObserverBeatsComponentz7AppLoggerTests.test_configuredLogObserverBeatsComponent´  st   € ð
 ×%Ò%Ñ'Ô'ˆÝ#‘o”oˆØ× Ò ¥¨xÑ8Ô8Ð8Ø×Ò˜D×7Ò7¸ÑDÔDÑEÔEÐEØ×Ò˜œ¨Ñ,Ô,Ð,Ð,Ð,r6   c                 óâ   — g }t          ¦   «         }|                     t          |j        ¦  «         |                      |                      |¦  «        ¦  «         |                      |g ¦  «         dS )zq
        C{--logger} takes precedence over a L{LegacyILogObserver} component
        set on Application.
        N)r   r™  ÚLegacyILogObserverr•   r‘  r   rz   )rQ   Únonlogsr]   s      r4   Ú.test_configuredLogObserverBeatsLegacyComponentz=AppLoggerTests.test_configuredLogObserverBeatsLegacyComponent¿  si   € ð
 ˆÝ#‘o”oˆØ× Ò Õ!3°W´^ÑDÔDÐDØ×Ò˜D×7Ò7¸ÑDÔDÑEÔEÐEØ×Ò˜ "Ñ%Ô%Ð%Ð%Ð%r6   c                 ób  — g }|                       ¦   «         }t          ¦   «         }|                     t          |¦  «         |                     t          |j        ¦  «         t          j        i ¦  «        } |j        |¦  «         |  	                    |¦  «         |  
                    |g ¦  «         dS )zw
        A L{ILogObserver} takes precedence over a L{LegacyILogObserver}
        component set on Application.
        N)r�  r   r™  r   r¦  r•   r
   r•  r^   r‘  rz   )rQ   r§  ri  r]   r   s        r4   Ú.test_loggerComponentBeatsLegacyLoggerComponentz=AppLoggerTests.test_loggerComponentBeatsLegacyLoggerComponentÊ  s£   € ð
 ˆØ×%Ò%Ñ'Ô'ˆÝ#‘o”oˆØ× Ò ¥¨xÑ8Ô8Ð8Ø× Ò Õ!3°W´^ÑDÔDÐDå”˜rÑ"Ô"ˆØˆŒ�[Ñ!Ô!Ð!à×Ò˜HÑ%Ô%Ð%Ø×Ò˜ "Ñ%Ô%Ð%Ð%Ð%r6   r³   zsyslog not availablec                 óÎ   — t          | ¦  «        }t          ¦   «         }|                      |                      |ddit          ¦  «        ¦  «         |                      |g ¦  «         dS )z`
        C{--logger} takes precedence over a C{--syslog} command line
        argument.
        rw  TN)ry  r   r‘  r   r"   rz   )rQ   Úlogsr]   s      r4   Ú%test_configuredLogObserverBeatsSyslogz4AppLoggerTests.test_configuredLogObserverBeatsSyslogÛ  sj   € õ ˜DÑ!Ô!ˆÝ#‘o”oˆØ×ÒØ×'Ò'¨°hÀÐ5EÅ}ÑUÔUñ	
ô 	
ð 	
ð 	×Ò˜˜rÑ"Ô"Ð"Ð"Ð"r6   c                 ó  — t          ¦   «         }|                      ¦   «         }|                      |                      |ddi¦  «        ¦  «         |                      t
          j                             |¦  «        ¦  «         dS )za
        C{--logger} takes precedence over a C{--logfile} command line
        argument.
        Úlogfilerâ   N)r   ræ   r‘  r   r«   r:   râ   rÝ   )rQ   r]   râ   s      r4   Ú&test_configuredLogObserverBeatsLogfilez5AppLoggerTests.test_configuredLogObserverBeatsLogfileé  st   € õ
 $‘o”oˆØ�{Š{‰}Œ}ˆØ×ÒØ×'Ò'¨°iÀÐ5HÑIÔIñ	
ô 	
ð 	
ð 	×Ò�œŸš¨Ñ-Ô-Ñ.Ô.Ð.Ð.Ð.r6   c                 óæ  — t          j        ddi¦  «        }t          | j        ¦  «        } |j        ¦   «          |                      t          |¦  «        d¦  «         |                      |d         t          j	        ¦  «         t          j        ddi¦  «        } |j        ¦   «          |                      t          |¦  «        d¦  «         |                      |d         t          j	        ¦  «         dS )z’
        When logfile is empty or set to C{-}, L{app.AppLogger._getLogObserver}
        returns a log observer pointing at C{sys.stdout}.
        r¯  ú-r÷   r   Ú r†  N)
r
   r•  rk  rD   r–  rz   r  rÓ   r1  rÐ   )rQ   r   rg  s      r4   Útest_getLogObserverStdoutz(AppLoggerTests.test_getLogObserverStdoutõ  sÎ   € õ
 ” 	¨3Ð/Ñ0Ô0ˆÝ,¨T¬ZÑ8Ô8ˆàˆÔÑ Ô Ð à×Ò�˜X™œ¨Ñ*Ô*Ð*Ø�Š�h˜q”k¥3¤:Ñ.Ô.Ð.å” 	¨2˜Ñ/Ô/ˆØˆÔÑ Ô Ð à×Ò�˜X™œ¨Ñ*Ô*Ð*Ø�Š�h˜q”k¥3¤:Ñ.Ô.Ð.Ð.Ð.r6   c                 óª  — t          | j        ¦  «        }|                      ¦   «         }t          j        d|i¦  «        }|                     ¦   «         }|                      |j        j        ¦  «         |  	                    t          |¦  «        d¦  «         |  	                    |d         j        t          j                             |¦  «        ¦  «         dS )z•
        When passing the C{logfile} option, L{app.AppLogger._getLogObserver}
        returns a log observer pointing at the specified path.
        r¯  r÷   r   N)rk  rD   ræ   r
   r•  r–  Ú
addCleanupÚ_outFiler  rz   r  râ   r:   Úabspath)rQ   rg  ÚfilenameÚsutri  s        r4   Útest_getLogObserverFilez&AppLoggerTests.test_getLogObserverFile  sª   € õ
 -¨T¬ZÑ8Ô8ˆØ—;’;‘=”=ˆÝŒm˜Y¨Ð1Ñ2Ô2ˆà×&Ò&Ñ(Ô(ˆØ�Š˜Ô)Ô/Ñ0Ô0Ð0à×Ò�˜X™œ¨Ñ*Ô*Ð*Ø×Ò˜ !œÔ)­2¬7¯?ª?¸8Ñ+DÔ+DÑEÔEÐEÐEÐEr6   c                 ól  ‡— g Št          ¦   «         }ˆfd„}|                      t          d|¦  «         t          j        i ¦  «        }||_         |j        ¦   «          |                      ‰|g¦  «          |j        ¦   «          |                      ‰|g¦  «         |                      |j        ¦  «         dS )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                 ó2   •— ‰                      | ¦  «         d S r)   r@  )ri  Úremoveds    €r4   Úremovez(AppLoggerTests.test_stop.<locals>.remove   s   ø€ Ø�NŠN˜8Ñ$Ô$Ð$Ð$Ð$r6   r‚  N)	r2  rD   r   r
   r•  Ú	_observerr   rz   r�   )rQ   ri  r¿  r   r¾  s       @r4   Ú	test_stopzAppLoggerTests.test_stop  sÄ   ø€ ð ˆÝ‘8”8ˆð	%ð 	%ð 	%ð 	%ð 	%ð 	�
Š
Õ%Ð'7¸Ñ@Ô@Ð@Ý”˜rÑ"Ô"ˆØ#ˆÔØˆŒ‰ŒˆØ×Ò˜ 8 *Ñ-Ô-Ð-ØˆŒ‰ŒˆØ×Ò˜ 8 *Ñ-Ô-Ð-Ø×Ò˜&Ô*Ñ+Ô+Ð+Ð+Ð+r6   c                 ó¤  ‡‡— g Št          j        i ¦  «        }t          t          ¦  «         G ˆfd„d¦  «        ¦   «         Šˆfd„|_         |j        t          ¦   «         ¦  «         |                      dt          ‰d         ¦  «        ¦  «         |  	                    | j
        g¦  «        }|                      t          |¦  «        d|¦  «         dS )zt
        L{app.AppLogger} using a legacy logger observer still works, wrapping
        it in a compat shim.
        c                   ó   •— e Zd ZdZˆ fd„ZdS )ú;AppLoggerTests.test_legacyObservers.<locals>.LoggerObserverzX
            An observer which implements the legacy L{LegacyILogObserver}.
            c                 ó2   •— ‰                      |¦  «         dS )z<
                Add C{x} to the logs list.
                Nr@  )rQ   Úxr¬  s     €r4   r‹  zDAppLoggerTests.test_legacyObservers.<locals>.LoggerObserver.__call__:  s   ø€ ð —’˜A‘”���r6   N)rS   rT   rU   rV   r‹  ©r¬  s   €r4   ÚLoggerObserverrÄ  4  s8   ø€ € € € € ðð ðð ð ð ð ð ð r6   rÈ  c                  ó   •—  ‰ ¦   «         S r)   rX   )rÈ  s   €r4   rá   z5AppLoggerTests.test_legacyObservers.<locals>.<lambda>@  s   ø€ ¨.¨.Ñ*:Ô*:€ r6   r�  r   N)r
   r•  r   r¦  Ú_observerFactoryr^   r   r”   r   r  Útest_legacyObserversrz   r  )rQ   r   ÚwarningsrÈ  r¬  s      @@r4   rË  z#AppLoggerTests.test_legacyObservers,  sç   øø€ ð
 ˆÝ”˜rÑ"Ô"ˆå	Õ'Ñ	(Ô	(ð		ð 		ð 		ð 		ð 		ð 		ð 		ñ 		ô 		ñ 
)Ô	(ð		ð #;Ð":Ð":Ð":ˆÔØˆŒ•]‘_”_Ñ%Ô%Ð%à�Š�mÕ%6°t¸A´wÑ%?Ô%?Ñ@Ô@Ð@Ø×%Ò% tÔ'@Ð&AÑBÔBˆØ×Ò�˜X™œ¨¨8Ñ4Ô4Ð4Ð4Ð4r6   c                 ó”  ‡— g Št          j        i ¦  «        }ˆfd„|_         |j        t	          ¦   «         ¦  «         |                      dt          ‰d         ¦  «        ¦  «         |                      | j        g¦  «        }|  	                    |d         d         d¦  «         |  	                    t          |¦  «        d|¦  «         dS )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                  ó   •— ‰ j         S r)   r@  rÇ  s   €r4   rá   zAAppLoggerTests.test_unmarkedObserversDeprecated.<locals>.<lambda>O  s	   ø€ ¨¬€ r6   r�  r   r  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.r÷   N)r
   r•  r–  r^   r   r”   r   r  Ú test_unmarkedObserversDeprecatedrz   r  )rQ   r   rÌ  r¬  s      @r4   rÏ  z/AppLoggerTests.test_unmarkedObserversDeprecatedG  sÉ   ø€ ð ˆÝ”˜rÑ"Ô"ˆØ!4Ð!4Ð!4Ð!4ˆÔØˆŒ•]‘_”_Ñ%Ô%Ð%à�Š�mÕ%6°t¸A´wÑ%?Ô%?Ñ@Ô@Ð@à×%Ò% tÔ'LÐ&MÑNÔNˆØ×ÒØ�QŒK˜	Ô"ð0ñ	
ô 	
ð 	
ð 	×Ò�˜X™œ¨¨8Ñ4Ô4Ð4Ð4Ð4r6   N)rS   rT   rU   rV   r  r„  r�  r‘  r—  rš  r
   r•  r   r¢  r¤  r¨  rª  r   rÙ   rw  r­  r°  r´  r»  rÁ  rË  rÏ  rX   r6   r4   r{  r{  B  s}  € € € € € ðð ðHð Hð Hð8ð 8ð 8ðð ð ð"Hð Hð Hð	&ð 	&ð 	&ð&ð &ð &ð )+°c´mðð ð ð ð0Fð Fð Fð	-ð 	-ð 	-ð	&ð 	&ð 	&ð&ð &ð &ð" €V�ÐÐ9Ñ:Ô:Ø€V�ˆJÐ.Ñ/Ô/ð
#ð 
#ñ 0Ô/ñ ;Ô:ð
#ð
/ð 
/ð 
/ð/ð /ð /ð&Fð Fð Fð,ð ,ð ,ð*5ð 5ð 5ð65ð 5ð 5ð 5ð 5r6   r{  c                   ób   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	 e
e d¦  «        d	„ ¦   «         Zd
S )ÚUnixAppLoggerTestszw
    Tests for L{UnixAppLogger}.

    @ivar signals: list of signal handlers installed.
    @type signals: C{list}
    c                 óX   ‡ — g ‰ _         ˆ fd„}‰                      t          d|¦  «         dS )zs
        Fake C{signal.signal} for not installing the handlers but saving them
        in C{self.signals}.
        c                 ó@   •— ‰j                              | |f¦  «         d S r)   )Úsignalsr•   )rò   rê   rQ   s     €r4   Ú
fakeSignalz,UnixAppLoggerTests.setUp.<locals>.fakeSignalu  s#   ø€ ØŒL×Ò  a Ñ)Ô)Ð)Ð)Ð)r6   ÚsignalN)rÔ  rD   rÖ  )rQ   rÕ  s   ` r4   r  zUnixAppLoggerTests.setUpn  sC   ø€ ð
 ˆŒð	*ð 	*ð 	*ð 	*ð 	*ð 	�
Š
•6˜8 ZÑ0Ô0Ð0Ð0Ð0r6   c                 óÖ  — t          | j        ¦  «        }t          dddœ¦  «        } |j        ¦   «          |                      t          |¦  «        d¦  «         |                      |d         t          j        ¦  «         t          dddœ¦  «        } |j        ¦   «          |                      t          |¦  «        d¦  «         |                      |d         t          j        ¦  «         dS )	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²  T©r¯  rC  r÷   r   r³  r†  N)	rk  rD   r"   r–  rz   r  rÓ   r1  rÐ   )rQ   rg  r   s      r4   r´  z,UnixAppLoggerTests.test_getLogObserverStdoutz  sÑ   € õ -¨T¬ZÑ8Ô8ˆå¨3¸DÐAÐAÑBÔBˆØˆÔÑ Ô Ð Ø×Ò�˜X™œ¨Ñ*Ô*Ð*Ø�Š�h˜q”k¥3¤:Ñ.Ô.Ð.å¨2¸4Ð@Ð@ÑAÔAˆØˆÔÑ Ô Ð Ø×Ò�˜X™œ¨Ñ*Ô*Ð*Ø�Š�h˜q”k¥3¤:Ñ.Ô.Ð.Ð.Ð.r6   c                 ó°   — t          dddœ¦  «        }|                      t          |j        ¦  «        }|                      t          |¦  «        d¦  «         dS )z
        When daemonized and C{logfile} is set to C{-},
        L{UnixAppLogger._getLogObserver} raises C{SystemExit}.
        r²  FrØ  z&Daemons cannot log to stdout, exiting!N)r"   rœ   r�   r–  rz   r®   )rQ   r   rY  s      r4   Útest_getLogObserverStdoutDaemonz2UnixAppLoggerTests.test_getLogObserverStdoutDaemonŒ  sT   € õ
 ¨3¸EÐBÐBÑCÔCˆØ×!Ò!¥*¨fÔ.DÑEÔEˆØ×Ò�˜U™œÐ%MÑNÔNÐNÐNÐNr6   c                 óÒ  ‡— t          | j        ¦  «        }|                      ¦   «         }t          d|i¦  «        }|                     ¦   «         }|                      |j        j        ¦  «         |                      t          |¦  «        d¦  «         |                      |d         j
        t          j
                             |¦  «        ¦  «         |                      t          | j        ¦  «        d¦  «         |                      | j        d         d         t          j        ¦  «         t!          ¦   «         Šˆfd„}||d         _        | j        d         d         } |dd¦  «         ‰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¯  r÷   r   c                  ó2   •— ‰                       d ¦  «         d S r)   )Úcallback)Úds   €r4   Úrotatez:UnixAppLoggerTests.test_getLogObserverFile.<locals>.rotateª  s   ø€ Ø�JŠJ�tÑÔÐÐÐr6   N)rk  rD   ræ   r"   r–  r¶  r·  r  rz   r  râ   r:   r¸  rÔ  rÖ  ÚSIGUSR1r   rß  )rQ   rg  r¹  rº  ri  rß  Ú	rotateLogrÞ  s          @r4   r»  z*UnixAppLoggerTests.test_getLogObserverFile•  s=  ø€ õ -¨T¬ZÑ8Ô8ˆØ—;’;‘=”=ˆÝ˜Y¨Ð1Ñ2Ô2ˆà×&Ò&Ñ(Ô(ˆØ�Š˜Ô)Ô/Ñ0Ô0Ð0à×Ò�˜X™œ¨Ñ*Ô*Ð*Ø×Ò˜ !œÔ)­2¬7¯?ª?¸8Ñ+DÔ+DÑEÔEÐEà×Ò�˜Tœ\Ñ*Ô*¨AÑ.Ô.Ð.Ø×Ò˜œ aœ¨Ô+­V¬^Ñ<Ô<Ð<å‰JŒJˆð	ð 	ð 	ð 	ð 	ð $ˆ�ŒÔà”L ”O AÔ&ˆ	Øˆ	�$˜ÑÔÐØˆr6   c                 ó0  ‡ — ˆ fd„}‰                       t          d|¦  «         ‰                      ¦   «         }t          d|i¦  «        }|                     ¦   «         }‰                      |j        j        ¦  «         ‰                      ‰ j	        g ¦  «         dS )zy
        If a signal handler is already installed,
        L{UnixAppLogger._getLogObserver} doesn't override it.
        c                 ó`   •— ‰                      | t          j        ¦  «         t          ¦   «         S r)   )rz   rÖ  rà  r2  )rò   rQ   s    €r4   ÚfakeGetSignalzVUnixAppLoggerTests.test_getLogObserverDontOverrideSignalHandler.<locals>.fakeGetSignal¹  s$   ø€ Ø×Ò˜S¥&¤.Ñ1Ô1Ð1Ý‘8”8ˆOr6   Ú	getsignalr¯  N)
rD   rÖ  ræ   r"   r–  r¶  r·  r  rz   rÔ  )rQ   rä  r¹  rº  ri  s   `    r4   Ú,test_getLogObserverDontOverrideSignalHandlerz?UnixAppLoggerTests.test_getLogObserverDontOverrideSignalHandler³  sš   ø€ ð	ð 	ð 	ð 	ð 	ð 	�
Š
•6˜;¨Ñ6Ô6Ð6Ø—;’;‘=”=ˆÝ˜Y¨Ð1Ñ2Ô2ˆà×&Ò&Ñ(Ô(ˆØ�Š˜Ô)Ô/Ñ0Ô0Ð0à×Ò˜œ rÑ*Ô*Ð*Ð*Ð*r6   c                 óp  — t          | j        ¦  «        }t          dddœ¦  «        } |j        ¦   «         }|                      |j        j        ¦  «         |                      t          |¦  «        d¦  «         |                      |d         j	        t          j	                             d¦  «        ¦  «         dS )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³  FrØ  r÷   r   z
twistd.logN)rk  rD   r"   r–  r¶  r·  r  rz   r  râ   r:   r¸  )rQ   rg  r   ri  s       r4   Útest_getLogObserverDefaultFilez1UnixAppLoggerTests.test_getLogObserverDefaultFileÆ  s�   € õ -¨T¬ZÑ8Ô8ˆÝ¨2¸5ÐAÐAÑBÔBˆØ)�6Ô)Ñ+Ô+ˆØ�Š˜Ô)Ô/Ñ0Ô0Ð0à×Ò�˜X™œ¨Ñ*Ô*Ð*Ø×Ò˜ !œÔ)­2¬7¯?ª?¸<Ñ+HÔ+HÑIÔIÐIÐIÐIr6   r³   c                 óâ   — t          | ¦  «        }t          dddœ¦  «        } |j        ¦   «         }|                      |dg¦  «          |ddi¦  «         |                      |dddig¦  «         dS )z’
        If C{syslog} is set to C{True}, L{UnixAppLogger._getLogObserver} starts
        a L{syslog.SyslogObserver} with given C{prefix}.
        Tztest-prefix)rw  rp  rÖ  ÚbN)ry  r"   r–  rz   )rQ   r¬  r   ri  s       r4   Útest_getLogObserverSyslogz,UnixAppLoggerTests.test_getLogObserverSyslogÔ  s‡   € õ ˜DÑ!Ô!ˆÝ¨$¸-ÐHÐHÑIÔIˆØ)�6Ô)Ñ+Ô+ˆØ×Ò˜ ˜Ñ/Ô/Ð/Øˆ�#�s�ÑÔÐØ×Ò˜ °°S¨zÐ:Ñ;Ô;Ð;Ð;Ð;r6   N)rS   rT   rU   rV   r  r´  rÚ  r»  ræ  rè  r   rÙ   rë  rX   r6   r4   rÑ  rÑ  e  sª   € € € € € ðð ð
1ð 
1ð 
1ð/ð /ð /ð$Oð Oð Oðð ð ð<+ð +ð +ð&Jð Jð Jð €V�ÐÐ9Ñ:Ô:ð
<ð 
<ñ ;Ô:ð
<ð 
<ð 
<r6   rÑ  z!twistd unix support not availablec                   ór   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚDaemonizeTestszH
    Tests for L{_twistd_unix.UnixApplicationRunner} daemonization.
    c                 ó”  — t          ¦   «         | _        t          j        ¦   «         | _        |                      t          d| j        ¦  «         t                               | j        ¦  «        | _        t          j
        d¦  «        | j        _        t          j        | j        _        t          j        | j        _        d„ | j        _        d S )Nr:   r  c                  ó   — d S r)   rX   )rÄ   s    r4   rá   z&DaemonizeTests.setUp.<locals>.<lambda>ð  s   € °€ r6   )r   Úmockosr   r}   r‚   rD   rÙ   r!   r  r   r  r]   r1  rÐ   rK  ÚstderrrL  rM  rc   s    r4   r  zDaemonizeTests.setUpè  sŒ   € Ý‘h”hˆŒÝÔ*Ñ,Ô,ˆŒØ�
Š
•<  t¤{Ñ3Ô3Ð3Ý"×8Ò8¸¼ÑEÔEˆŒÝ")Ô"5°eÑ"<Ô"<ˆŒÔÝ #¤
ˆŒÔÝ #¤
ˆŒÔØ#5Ð#5ˆŒÔ Ð Ð r6   c                 ó&  — t          t          ¦   «         ¦  «        5  | j                             ¦   «          ddd¦  «         n# 1 swxY w Y   |                      | j        j        g d¢¦  «         |                      | j        j        ddg¦  «         dS )zw
        When double fork succeeded in C{daemonize}, the child process writes
        B{0} to the status pipe.
        N)©r�  r«  ©rµ   rÅ  ©ÚforkTÚsetsidrõ  )rè   éþÿÿÿó   0©Úunlinkz
twistd.pidéýÿÿÿrø  )r   r²  r  rf   rz   rð  ÚactionsÚclosedrc   s    r4   Útest_successzDaemonizeTests.test_successò  sØ   € õ
 Õ4Ñ6Ô6Ñ7Ô7ð 	*ð 	*ØŒK×'Ò'Ñ)Ô)Ð)ð	*ð 	*ð 	*ñ 	*ô 	*ð 	*ð 	*ð 	*ð 	*ð 	*ð 	*øøøð 	*ð 	*ð 	*ð 	*à×ÒØŒKÔðð ð ñ	
ô 	
ð 	
ð 	×Ò˜œÔ+¨b°"¨XÑ6Ô6Ð6Ð6Ð6s   œAÁAÁ	Ac                 ól  — d| j         _        d| j         _        t          t	          ¦   «         ¦  «        5  |                      t          | j        j        ¦  «         ddd¦  «         n# 1 swxY w Y   |  	                    | j         j
        g d¢¦  «         |  	                    | j         j        dg¦  «         dS )zˆ
        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º  éÿÿÿÿéd   ©Úexitr   rú  r  )rð  ÚchildÚreadDatar   r²  rœ   ÚSystemErrorr  rf   rz   rý  rþ  rc   s    r4   Útest_successInParentz#DaemonizeTests.test_successInParent  s  € ð
 "ˆŒÔØ#ˆŒÔÝÕ4Ñ6Ô6Ñ7Ô7ð 	Hð 	HØ×Ò�k¨4¬;Ô+FÑGÔGÐGð	Hð 	Hð 	Hñ 	Hô 	Hð 	Hð 	Hð 	Hð 	Hð 	Hð 	Høøøð 	Hð 	Hð 	Hð 	Hà×ÒØŒKÔðð ð ñ
	
ô 
	
ð 
	
ð 	×Ò˜œÔ+¨b¨TÑ2Ô2Ð2Ð2Ð2s   ´&A&Á&A*Á-A*c                 ó~  ‡— g Šˆfd„}|| j         _        t          t          ¦   «         ¦  «        5  | j                             ¦   «          ddd¦  «         n# 1 swxY w Y   |                      | j         j        g d¢¦  «         |                      | j         j        ddg¦  «         |                      ddg‰¦  «         dS )z‚
        If the C{os.write} call to the status pipe raises an B{EINTR} error,
        the process child retries to write.
        c                 óŽ   •— ‰                      | |f¦  «         t          ‰¦  «        dk    rt          t          j        ¦  «        ‚d S r§  ©r•   r  rû   rü   ÚEINTR)Úfdr-  Úwrittens     €r4   ÚraisingWritez6DaemonizeTests.test_successEINTR.<locals>.raisingWrite$  sB   ø€ Ø�NŠN˜B ˜:Ñ&Ô&Ð&Ý�7‰|Œ|˜qÒ Ð Ý�eœkÑ*Ô*Ð*ð !Ð r6   N)ró  rô  rõ  r÷  rõ  rú  rü  rø  )rø  rù  )	rð  rè   r   r²  r  rf   rz   rý  rþ  )rQ   r  r  s     @r4   Útest_successEINTRz DaemonizeTests.test_successEINTR  s  ø€ ð
 ˆð	+ð 	+ð 	+ð 	+ð 	+ð
 )ˆŒÔÝÕ4Ñ6Ô6Ñ7Ô7ð 	*ð 	*ØŒK×'Ò'Ñ)Ô)Ð)ð	*ð 	*ð 	*ñ 	*ô 	*ð 	*ð 	*ð 	*ð 	*ð 	*ð 	*øøøð 	*ð 	*ð 	*ð 	*à×ÒØŒKÔðð ð ñ
	
ô 
	
ð 
	
ð 	×Ò˜œÔ+¨b°"¨XÑ6Ô6Ð6Ø×Ò˜* jÐ1°7Ñ;Ô;Ð;Ð;Ð;s   °AÁAÁAc                 ó¬  ‡— g Šˆfd„}|| j         _        d| j         _        t          t	          ¦   «         ¦  «        5  |                      t          | j        j        ¦  «         ddd¦  «         n# 1 swxY w Y   |  	                    | j         j
        g d¢¦  «         |  	                    | j         j        dg¦  «         |  	                    ddg‰¦  «         dS )z
        If the C{os.read} call on the status pipe raises an B{EINTR} error, the
        parent child retries to read.
        c                 óŽ   •— ‰                      | |f¦  «         t          ‰¦  «        dk    rt          t          j        ¦  «        ‚dS )Nr÷   rù  r  )r  Úsizerº  s     €r4   ÚraisingReadz=DaemonizeTests.test_successInParentEINTR.<locals>.raisingReadA  s=   ø€ Ø�KŠK˜˜T˜
Ñ#Ô#Ð#Ý�4‰yŒy˜AŠ~ˆ~Ý�eœkÑ*Ô*Ð*Ø�4r6   FN)ró  rô  rõ  r  rú  r  )r  r  )rð  rº  r  r   r²  rœ   r  r  rf   rz   rý  rþ  )rQ   r  rº  s     @r4   Útest_successInParentEINTRz(DaemonizeTests.test_successInParentEINTR:  s>  ø€ ð
 ˆð	ð 	ð 	ð 	ð 	ð 'ˆŒÔØ!ˆŒÔÝÕ4Ñ6Ô6Ñ7Ô7ð 	Hð 	HØ×Ò�k¨4¬;Ô+FÑGÔGÐGð	Hð 	Hð 	Hñ 	Hô 	Hð 	Hð 	Hð 	Hð 	Hð 	Hð 	Høøøð 	Hð 	Hð 	Hð 	Hà×ÒØŒKÔðð ð ñ		
ô 		
ð 		
ð 	×Ò˜œÔ+¨b¨TÑ2Ô2Ð2Ø×Ò˜) YÐ/°Ñ6Ô6Ð6Ð6Ð6s   ¼&A.Á.A2Á5A2c                 óÖ  ‡—  G ˆfd„dt           j        ¦  «        } |¦   «         }|                     | j        j        ¦  «         t          t          ¦   «         ¦  «        5  |                      t          | j        j	        ¦  «         ddd¦  «         n# 1 swxY w Y   |  
                    | j        j        ddddddd	|fd
g¦  «         |  
                    | j        j        dd	g¦  «         dS )z¶
        Assert L{UnixApplicationRunner.postApplication} writes
        C{reported} to its status pipe if the service raises an
        exception whose message is C{raised}.
        c                   ó   •— e Zd Zˆ fd„ZdS )ú6DaemonizeTests.assertErrorWritten.<locals>.FakeServicec                 ó"   •— t          ‰¦  «        ‚r)   rL  )rQ   Úraiseds    €r4   r`  zCDaemonizeTests.assertErrorWritten.<locals>.FakeService.startService`  s   ø€ Ý" 6Ñ*Ô*Ð*r6   N)rS   rT   rU   r`  )r  s   €r4   re  r  _  s.   ø€ € € € € ð+ð +ð +ð +ð +ð +ð +r6   re  Nró  rô  rõ  r÷  rè   rø  rú  rü  )r   rO   rY  r  r]   r   r²  rœ   r&  rf   rz   rð  rý  rþ  )rQ   r  Úreportedre  ÚerrorServices    `   r4   ÚassertErrorWrittenz!DaemonizeTests.assertErrorWrittenX  s]  ø€ ð	+ð 	+ð 	+ð 	+ð 	+ð 	+ð 	+�'œ/ñ 	+ô 	+ð 	+ð #�{‘}”}ˆØ×%Ò% d¤kÔ&=Ñ>Ô>Ð>åÕ4Ñ6Ô6Ñ7Ô7ð 	Ið 	IØ×Ò�l¨D¬KÔ,GÑHÔHÐHð	Ið 	Ið 	Iñ 	Iô 	Ið 	Ið 	Ið 	Ið 	Ið 	Ið 	Iøøøð 	Ið 	Ið 	Ið 	Ià×ÒØŒKÔàØ ØØØØ˜"˜hÐ'Ø(ðñ	
ô 	
ð 	
ð 	×Ò˜œÔ+¨b°"¨XÑ6Ô6Ð6Ð6Ð6s   Á &BÂBÂBc                 ó4   — |                       dd¬¦  «         dS )z„
        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  rc   s    r4   Ú
test_errorzDaemonizeTests.test_errorv  s1   € ð
 	×ÒØ'Ð2Wð 	 ñ 	
ô 	
ð 	
ð 	
ð 	
r6   c                 ó4   — |                       dd¬¦  «         dS )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!  rc   s    r4   Útest_unicodeErrorz DaemonizeTests.test_unicodeError  s$   € ð 	×Ò xÐ:TÐÑUÔUÐUÐUÐUr6   c                 ó  — d| j         _        || j         _        t          ¦   «         }|                      t
          d|¦  «         t          t          ¦   «         ¦  «        5  |                      t          | j
        j        ¦  «         ddd¦  «         n# 1 swxY w Y   |                      |                     ¦   «         |¦  «         |                      | j         j        |¦  «         |                      | j         j        dg¦  «         dS )a  
        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   r1  r   r²  rœ   r  r  rf   rz   rŸ   rý  rþ  )rQ   r  ÚerrorMessageÚmockOSActionsÚerrorIOs        r4   ÚassertErrorInParentBehaviorz*DaemonizeTests.assertErrorInParentBehavior‡  s-  € ð "ˆŒÔØ'ˆŒÔÝ‘*”*ˆØ�
Š
•3˜ gÑ.Ô.Ð.ÝÕ4Ñ6Ô6Ñ7Ô7ð 	Hð 	HØ×Ò�k¨4¬;Ô+FÑGÔGÐGð	Hð 	Hð 	Hñ 	Hô 	Hð 	Hð 	Hð 	Hð 	Hð 	Hð 	Høøøð 	Hð 	Hð 	Hð 	Hà×Ò˜×)Ò)Ñ+Ô+¨\Ñ:Ô:Ð:Ø×Ò˜œÔ,¨mÑ<Ô<Ð<Ø×Ò˜œÔ+¨b¨TÑ2Ô2Ð2Ð2Ð2s   Á&BÂBÂBc                 ó:   — |                       ddg d¢¬¦  «         dS )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õ  r  )r  r÷   rú  ©r  r'  r(  N©r*  rc   s    r4   Útest_errorInParentz!DaemonizeTests.test_errorInParent˜  sC   € ð 	×(Ò(Ø8ðBðð ð ð 	)ñ 	
ô 	
ð 	
ð 	
ð 	
r6   c                 ó:   — |                       ddg d¢¬¦  «         dS )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,  r-  Nr.  rc   s    r4   Útest_nonASCIIErrorInParentz)DaemonizeTests.test_nonASCIIErrorInParent®  sC   € ð 	×(Ò(Ø)ðBðð ð ð 	)ñ 	
ô 	
ð 	
ð 	
ð 	
r6   c                 óŽ   — d}d                      d¦  «        }|                      |d                      |¦  «        g d¢¬¦  «         dS )a
  
        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.
        ód   1 RuntimeError: \u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022zb'RuntimeError: {}'zb\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022\\u2022zHAn error has occurred: {}
Please look at log file for more information.
r,  r-  N)r¡   r*  )rQ   ÚtruncatedMessageÚreportedMessages      r4   Ú&test_errorInParentWithTruncatedUnicodez5DaemonizeTests.test_errorInParentWithTruncatedUnicodeÄ  ss   € ð AÐð 0×6Ò6°ÑGÔGˆØ×(Ò(Ø%ðBßBHÂ&Ø#ñCô Cðð ð ð 	)ñ 	
ô 	
ð 	
ð 	
ð 	
r6   c                 ó4   — |                       dd¬¦  «         dS )z{
        If an error occurs during daemonization and its message is too
        long, it's truncated by the child.
        ÚÈxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxsd   1 RuntimeError: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxr   Nr!  rc   s    r4   Útest_errorMessageTruncatedz)DaemonizeTests.test_errorMessageTruncatedá  s1   € ð
 	×ÒØÐ'Fð 	 ñ 	
ô 	
ð 	
ð 	
ð 	
r6   c                 ó4   — |                       dd¬¦  «         dS )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.
        uZ   â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢â€¢r3  r   Nr!  rc   s    r4   Ú!test_unicodeErrorMessageTruncatedz0DaemonizeTests.test_unicodeErrorMessageTruncatedê  s1   € ð 	×ÒØ Ø:ð 	 ñ 	
ô 	
ð 	
ð 	
ð 	
r6   c                 ó¾   — t          ¦   «         }| j                             |¦  «         |                      |j        ¦  «         |                      |j        ¦  «         dS )z¸
        C{daemonize} indeed calls L{IReactorDaemonize.beforeDaemonize} and
        L{IReactorDaemonize.afterDaemonize} if the reactor implements
        L{IReactorDaemonize}.
        N)r²  r  r¤  r§   r  r  r¨  s     r4   Útest_hooksCalledzDaemonizeTests.test_hooksCalledõ  sU   € õ )Ñ*Ô*ˆØŒ×Ò˜gÑ&Ô&Ð&Ø�Š˜Ô6Ñ7Ô7Ð7Ø�Š˜Ô5Ñ6Ô6Ð6Ð6Ð6r6   c                 ó¾   — t          ¦   «         }| j                             |¦  «         |                      |j        ¦  «         |                      |j        ¦  «         dS )zÀ
        C{daemonize} does NOT call L{IReactorDaemonize.beforeDaemonize} or
        L{IReactorDaemonize.afterDaemonize} if the reactor does NOT implement
        L{IReactorDaemonize}.
        N)r  r  r¤  r«   r  r  r¨  s     r4   Útest_hooksNotCalledz"DaemonizeTests.test_hooksNotCalled   sY   € õ ,Ñ-Ô-ˆØŒ×Ò˜gÑ&Ô&Ð&Ø×Ò˜Ô7Ñ8Ô8Ð8Ø×Ò˜Ô6Ñ7Ô7Ð7Ð7Ð7r6   N)rS   rT   rU   rV   r  rÿ  r	  r  r  r  r"  r$  r*  r/  r1  r6  r9  r;  r=  r?  rX   r6   r4   rí  rí  â  s  € € € € € ðð ð6ð 6ð 6ð7ð 7ð 7ð*3ð 3ð 3ð,<ð <ð <ð:7ð 7ð 7ð<7ð 7ð 7ð<
ð 
ð 
ðVð Vð Vð3ð 3ð 3ð"
ð 
ð 
ð,
ð 
ð 
ð,
ð 
ð 
ð:
ð 
ð 
ð	
ð 	
ð 	
ð	7ð 	7ð 	7ð	8ð 	8ð 	8ð 	8ð 	8r6   rí  c                   óH   — e Zd ZdZed„ ¦   «         Zej        d„ ¦   «         ZdS )ÚSignalCapturingMemoryReactorz‰
    MemoryReactor that implements the _ISupportsExitSignalCapturing interface,
    all other operations identical to MemoryReactor.
    c                 ó   — | j         S r)   ©Ú_valrc   s    r4   rˆ  z(SignalCapturingMemoryReactor._exitSignal  s
   € àŒyÐr6   c                 ó   — || _         d S r)   rC  )rQ   Úvals     r4   rˆ  z(SignalCapturingMemoryReactor._exitSignal  s   € àˆŒ	ˆ	ˆ	r6   N)rS   rT   rU   rV   Úpropertyrˆ  ÚsetterrX   r6   r4   rA  rA    sX   € € € € € ðð ð
 ðð ñ „Xðð Ôðð ñ Ôðð ð r6   rA  c                   ó2   ‡ — e Zd ZdZeZˆ fd„Zd„ Zd„ Zˆ xZ	S )ÚStubApplicationRunnerWithSignalzï
    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                 óX   •— t          ¦   «                              |¦  «         d | _        d S r)   )Úsuperrr   Ú_signalValue)rQ   r‚   Ú	__class__s     €r4   rr   z(StubApplicationRunnerWithSignal.__init__'  s)   ø€ Ý‰Œ×Ò˜Ñ Ô Ð Ø ˆÔÐÐr6   c                 ó   — dS )z
        Does nothing.
        NrX   rc   s    r4   rd   z.StubApplicationRunnerWithSignal.preApplication+  r!  r6   c                 ó�   — t          ¦   «         }| j        |_        |                      |t          j        t          j        ¦  «         dS )z`
        Instantiate a SignalCapturingMemoryReactor and start it
        in the runner.
        N)rA  rM  rˆ  rM  r1  rÐ   rñ  r¨  s     r4   rf   z/StubApplicationRunnerWithSignal.postApplication0  s<   € õ
 /Ñ0Ô0ˆØ"Ô/ˆÔØ×Ò˜'¥3¤:­s¬zÑ:Ô:Ð:Ð:Ð:r6   )
rS   rT   rU   rV   rZ   rg   rr   rd   rf   Ú__classcell__)rN  s   @r4   rJ  rJ    sg   ø€ € € € € ðð ð &€Mð!ð !ð !ð !ð !ðð ð ð
;ð ;ð ;ð ;ð ;ð ;ð ;r6   rJ  c                 ó   ‡ — ˆ fd„}|S )aI  
    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                 ó4   •— t          | ¦  «        }‰|_        |S )a·  
        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
        )rJ  rM  )r‚   r  Úsignums     €r4   ÚstubApplicationRunnerFactoryzIstubApplicationRunnerFactoryCreator.<locals>.stubApplicationRunnerFactoryG  s   ø€ õ 1°Ñ8Ô8ˆØ$ˆÔØˆr6   rX   )rT  rU  s   ` r4   Ú#stubApplicationRunnerFactoryCreatorrV  :  s$   ø€ ðð ð ð ð ð  (Ð'r6   c                   ó*   — e Zd ZdZd„ Zd„ Zd„ Zd„ ZdS )ÚExitWithSignalTestsz?
    Tests for L{twisted.application.app._exitWithSignal}.
    c                 ó  ‡ — t          j        ¦   «         ‰ _        dt          ¦   «         i‰ j        _        t          ¦   «         ‰ j        _        d‰ j        _        ddg‰ _        ˆ fd„}‰  	                    t          d|¦  «         dS )zM
        Set up the server options and a fake for use by test cases.
        r/  Nc                 ó0   •— | ‰j         d<   |‰j         d<   dS )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.
            r   r÷   N)ÚfakeKillArgs)rñ   rò   rQ   s     €r4   ÚfakeKillz+ExitWithSignalTests.setUp.<locals>.fakeKillj  s%   ø€ ð $'ˆDÔ˜aÑ Ø#&ˆDÔ˜aÑ Ð Ð r6   ró   )r   r}   r‚   rK   r1  r2  r3  r„   r[  rD   r:   )rQ   r\  s   ` r4   r  zExitWithSignalTests.setUp`  s†   ø€ õ Ô*Ñ,Ô,ˆŒØ%3Õ5EÑ5GÔ5GÐ$HˆŒÔ!Ý!'¡¤ˆŒÔØ!/ˆŒÔØ! 4˜LˆÔð		'ð 		'ð 		'ð 		'ð 		'ð 	�
Š
•2�v˜xÑ(Ô(Ð(Ð(Ð(r6   c                 óà  ‡— ddgŠˆfd„}|                       t          d|¦  «         t          j        t          j        ¦  «         |                      ‰d         t          j        ¦  «         |                      ‰d         t          j        ¦  «         |                      | j        d         t          j	        ¦   «         ¦  «         |                      | j        d         t          j        ¦  «         dS )zœ
        exitWithSignal replaces the existing signal handler with the default
        handler and sends the replaced signal to the current process.
        Nc                 ó   •— | ‰d<   |‰d<   d S )Nr   r÷   rX   )rò   ÚhandlerÚfakeSignalArgss     €r4   Úfake_signalz<ExitWithSignalTests.test_exitWithSignal.<locals>.fake_signal  s   ø€ Ø #ˆN˜1ÑØ 'ˆN˜1ÑÐÐr6   rÖ  r   r÷   )
rD   rÖ  r
   Ú_exitWithSignalÚSIGINTr‹  ÚSIG_DFLr[  r:   rÿ   )rQ   ra  r`  s     @r4   Útest_exitWithSignalz'ExitWithSignalTests.test_exitWithSignalw  sÖ   ø€ ð  ˜ˆð	(ð 	(ð 	(ð 	(ð 	(ð 	�
Š
•6˜8 [Ñ1Ô1Ð1ÝÔ�FœMÑ*Ô*Ð*à×Ò˜.¨Ô+­V¬]Ñ;Ô;Ð;Ø×Ò˜.¨Ô+­V¬^Ñ<Ô<Ð<Ø×Ò˜$Ô+¨AÔ.µ´	±´Ñ<Ô<Ð<Ø×Ò˜$Ô+¨AÔ.µ´Ñ>Ô>Ð>Ð>Ð>r6   c                 ó
  — |                       t          dt          d¦  «        ¦  «         t          j        | j        ¦  «         |                      | j        d         ¦  «         |                      | j        d         ¦  «         dS )zb
        _exitWithSignal is not called if the runner does not exit with a
        signal.
        rf  Nr   r÷   )rD   r   rV  ÚrunAppr‚   r�   r[  rc   s    r4   Útest_normalExitz#ExitWithSignalTests.test_normalExit‹  s~   € ð
 	�
Š
ÝÐ,Õ.QÐRVÑ.WÔ.Wñ	
ô 	
ð 	
õ 	Œ�d”kÑ"Ô"Ð"Ø×Ò˜$Ô+¨AÔ.Ñ/Ô/Ð/Ø×Ò˜$Ô+¨AÔ.Ñ/Ô/Ð/Ð/Ð/r6   c                 óX  — |                       t          dt          t          j        ¦  «        ¦  «         t          j        | j        ¦  «         |                      | j        d         t          j
        ¦   «         ¦  «         |                      | j        d         t          j        ¦  «         dS )zP
        _exitWithSignal is called when the runner exits with a signal.
        rf  r   r÷   N)rD   r   rV  rÖ  rc  rg  r‚   r‹  r[  r:   rÿ   rc   s    r4   Útest_runnerExitsWithSignalz.ExitWithSignalTests.test_runnerExitsWithSignal—  s‹   € ð 	�
Š
ÝØ$Ý/µ´Ñ>Ô>ñ	
ô 	
ð 	
õ
 	Œ�d”kÑ"Ô"Ð"Ø×Ò˜$Ô+¨AÔ.µ´	±´Ñ<Ô<Ð<Ø×Ò˜$Ô+¨AÔ.µ´Ñ>Ô>Ð>Ð>Ð>r6   N)rS   rT   rU   rV   r  re  rh  rj  rX   r6   r4   rX  rX  Z  sZ   € € € € € ðð ð)ð )ð )ð.?ð ?ð ?ð(
0ð 
0ð 
0ð?ð ?ð ?ð ?ð ?r6   rX  )hrV   rü   rÛ  r:   r  rÖ  r1  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#   rw  r$   r%   r&   rI   rK   r•  rZ   rf  ra   ri   rÛ   r	  r  r%  r#  r-  r–  rÈ  r
  r  r²  rx  r(  rk  ry  r{  rÑ  rí  rA  rJ  rV  rX  rX   r6   r4   ú<module>r…     s7  ððð ð
 €€€Ø €€€Ø 	€	€	€	Ø €€€Ø €€€Ø 
€
€
€
ðØÐÐÐØÐÐÐð
 €CØ
€C€Cøð ð ð ð Ø
€CØ
€C€C€Cðøøøð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à &Ð &Ð &Ð &Ð &Ð &Ø .Ð .Ð .Ð .Ð .Ð .à ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø -Ð -Ð -Ð -Ð -Ð -Ø +Ð +Ð +Ð +Ð +Ð +Ø XÐ XÐ XÐ XÐ XÐ XÐ XÐ XØ @Ð @Ð @Ð @Ð @Ð @Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø NÐ NÐ NÐ NÐ NÐ NÐ NÐ NÐ NÐ NØ Ð Ð Ð Ð Ð Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø /Ð /Ð /Ð /Ð /Ð /Ø TÐ TÐ TÐ TÐ TÐ TÐ TÐ TØ 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø /Ð /Ð /Ð /Ð /Ð /Ø +Ð +Ð +Ð +Ð +Ð +Ø "Ð "Ð "Ð "Ð "Ð "Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø +Ð +Ð +Ð +Ð +Ð +àˆ}Ð;Ñ<Ô<€Øð ðð ð ð ð ð ð ð ð ð ð 
ˆÐ.Ñ	/Ô	/€Ø
ˆ-˜	Ñ
"Ô
"€Ø	ˆ�xÑ	 Ô	 €Øˆ=˜Ñ$Ô$€ð*.ð *.ð *.ðZð ð ð ð ñ ô ð ð"ð ð ð ð ˜œñ ô ð ðð ð ð ð  Ô =ñ ô ð ð UJð UJð UJð UJð UJ˜ñ UJô UJð UJðp €ˆLÐÐ5Ñ6Ô6ðCKð CKð CKð CKð CK�Hñ CKô CKñ 7Ô6ðCKðLDð Dð Dð Dð D�8ñ Dô Dð Dð0ð ð ð ð ñ ô ð ð*Jð Jð Jð Jð J˜CÔ1ñ Jô Jð Jð(p4ð p4ð p4ð p4ð p4˜Xñ p4ô p4ð p4ðf €ˆLÐÐ5Ñ6Ô6ðF+ð F+ð F+ð F+ð F+°ñ F+ô F+ñ 7Ô6ðF+ðR €ˆLÐÐ5Ñ6Ô6ðO?ð O?ð O?ð O?ð O?°ñ O?ô O?ñ 7Ô6ðO?ðd €ˆLÐÐ5Ñ6Ô6ð>ð >ð >ð >ð >¨(ñ >ô >ñ 7Ô6ð>ð<ð ð ð ð ñ ô ð ð8 €ÐÑÔðð ð ð ð Ð6ñ ô ñ  Ôððð ð ð ð ñ ô ð ð(w8ð w8ð w8ð w8ð w8˜ñ w8ô w8ð w8ðtð ð ð*ð ð ð$`5ð `5ð `5ð `5ð `5�Xñ `5ô `5ð `5ðF	 €ˆLÐÐ5Ñ6Ô6ðy<ð y<ð y<ð y<ð y<˜ñ y<ô y<ñ 7Ô6ðy<ðx €ˆLÐÐ=Ñ>Ô>ðf8ð f8ð f8ð f8ð f8�Xñ f8ô f8ñ ?Ô>ðf8ðR	 €Ð*Ñ+Ô+ðð ð ð ð  =ñ ô ñ ,Ô+ðð;ð ;ð ;ð ;ð ; fÔ&Cñ ;ô ;ð ;ð<(ð (ð (ð@H?ð H?ð H?ð H?ð H?˜(ñ H?ô H?ð H?ð H?ð H?s   œ) ©	5´5