§
    Ètºf–V  ã                  óÚ  — d Z ddlmZ ddlZddlZddl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 ddlmZ ddlmZ ddlmZ ddlmZmZmZmZm Z   G d„ de¦  «        Z! G d„ de¦  «        Z" G d„ d¦  «        Z# G d„ d¦  «        Z$ G d„ de¦  «        Z% G d„ de¦  «        Z& G d„ de¦  «        Z' G d„ de¦  «        Z( G d„ d e¦  «        Z) G d!„ d"e¦  «        Z*dS )#z!
Tests for L{twisted.trial.util}
é    )ÚannotationsN)ÚStringIO)Ú	Generator)Úimplementer)Úassert_thatÚequal_to)ÚDelayedCall)ÚIProcessTransport)Úfilepath)ÚFailure)Úutil)ÚSynchronousTestCase)ÚDirtyReactorAggregateErrorÚ_JanitorÚacquireAttributeÚexcInfoOrFailureToExcInfoÚopenTestLogc                  ó2   — e Zd ZdZd	d„Zd	d„Zd	d„Zd	d„ZdS )
ÚMktempTestszm
    Tests for L{TestCase.mktemp}, a helper function for creating temporary file
    or directory names.
    ÚreturnÚNonec                óæ   — |                       ¦   «         }t          j                             |¦  «                             t          j        ¦  «        dd…         }|                      |g d¢¦  «         dS )z–
        The path name returned by C{mktemp} is directly beneath a directory
        which identifies the test method which created the name.
        Néÿÿÿÿ)ztwisted.trial.test.test_utilr   Ú	test_name)ÚmktempÚosÚpathÚdirnameÚsplitÚsepÚassertEqual)ÚselfÚnameÚdirss      ú[/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/trial/test/test_util.pyr   zMktempTests.test_name)   sk   € ð
 �{Š{‰}Œ}ˆÝŒw�Š˜tÑ$Ô$×*Ò*­2¬6Ñ2Ô2°3°B°3Ô7ˆØ×ÒØÐNÐNÐNñ	
ô 	
ð 	
ð 	
ð 	
ó    c                ó~   — |                       ¦   «         }|                      ||                       ¦   «         ¦  «         dS )zF
        Repeated calls to C{mktemp} return different values.
        N)r   ÚassertNotEqual)r"   r#   s     r%   Útest_uniquezMktempTests.test_unique4   s5   € ð �{Š{‰}Œ}ˆØ×Ò˜D $§+¢+¡-¤-Ñ0Ô0Ð0Ð0Ð0r&   c                ó4  — |                       ¦   «         }t          j                             |¦  «        }|                      t          j                             |¦  «        ¦  «         |                      t          j                             |¦  «        ¦  «         dS )zS
        The directory part of the path name returned by C{mktemp} exists.
        N)r   r   r   r   Ú
assertTrueÚexistsÚassertFalse)r"   r#   r   s      r%   Útest_createdzMktempTests.test_created;   sl   € ð �{Š{‰}Œ}ˆÝ”'—/’/ $Ñ'Ô'ˆØ�Š�œŸš wÑ/Ô/Ñ0Ô0Ð0Ø×Ò�œŸš¨Ñ-Ô-Ñ.Ô.Ð.Ð.Ð.r&   c                óÚ   — t           j                             |                      ¦   «         ¦  «        }|                      |                     t          j        ¦   «         ¦  «        ¦  «         dS )zZ
        The path returned by C{mktemp} is beneath the current working directory.
        N)r   r   Úabspathr   r+   Ú
startswithÚgetcwd)r"   r   s     r%   Útest_locationzMktempTests.test_locationD   sI   € õ Œw�Š˜tŸ{š{™}œ}Ñ-Ô-ˆØ�Š˜Ÿš­¬	©¬Ñ4Ô4Ñ5Ô5Ð5Ð5Ð5r&   N©r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r)   r.   r3   © r&   r%   r   r   #   sn   € € € € € ðð ð
	
ð 	
ð 	
ð 	
ð1ð 1ð 1ð 1ð/ð /ð /ð /ð6ð 6ð 6ð 6ð 6ð 6r&   r   c                  ó*   — e Zd ZdZdd„Zdd„Zdd„ZdS )	ÚDirtyReactorAggregateErrorTestsz6
    Tests for the L{DirtyReactorAggregateError}.
    r   r   c                ón   — t          ddg¦  «        }|                      t          |¦  «        d¦  «         dS )z5
        Delayed calls are formatted nicely.
        ÚFooÚbarzhReactor was unclean.
DelayedCalls: (set twisted.internet.base.DelayedCall.debug = True to debug)
Foo
barN©r   r!   Ústr©r"   Úerrors     r%   Útest_formatDelayedCallz6DirtyReactorAggregateErrorTests.test_formatDelayedCallQ   sE   € õ +¨E°5¨>Ñ:Ô:ˆØ×ÒÝ�‰JŒJðñ	
ô 	
ð 	
ð 	
ð 	
r&   c                óp   — t          g ddg¦  «        }|                      t          |¦  «        d¦  «         dS )z3
        Selectables are formatted nicely.
        zselectable 1zselectable 2z;Reactor was unclean.
Selectables:
selectable 1
selectable 2Nr?   rA   s     r%   Útest_formatSelectablesz6DirtyReactorAggregateErrorTests.test_formatSelectables_   sH   € õ +¨2°ÀÐ/OÑPÔPˆØ×ÒÝ�‰JŒJðñ	
ô 	
ð 	
ð 	
ð 	
r&   c                ót   — t          ddgddg¦  «        }|                      t          |¦  «        d¦  «         dS )zR
        Both delayed calls and selectables can appear in the same error.
        ÚbleckÚBoozoÚSel1ÚSel2zƒReactor was unclean.
DelayedCalls: (set twisted.internet.base.DelayedCall.debug = True to debug)
bleck
Boozo
Selectables:
Sel1
Sel2Nr?   rA   s     r%   Ú%test_formatDelayedCallsAndSelectableszEDirtyReactorAggregateErrorTests.test_formatDelayedCallsAndSelectablesm   sM   € õ +¨G°WÐ+=ÀÈÐ?OÑPÔPˆØ×ÒÝ�‰JŒJðñ
	
ô 
	
ð 
	
ð 
	
ð 
	
r&   Nr4   )r5   r6   r7   r8   rC   rE   rK   r9   r&   r%   r;   r;   L   sZ   € € € € € ðð ð
ð 
ð 
ð 
ð
ð 
ð 
ð 
ð
ð 
ð 
ð 
ð 
ð 
r&   r;   c                  ó8   — e Zd ZdZ	 ddd	„Zddd„Zdd„Zdd„ZdS )ÚStubReactora~  
    A reactor stub which contains enough functionality to be used with the
    L{_Janitor}.

    @ivar iterations: A list of the arguments passed to L{iterate}.
    @ivar removeAllCalled: Number of times that L{removeAll} was called.
    @ivar selectables: The value that will be returned from L{removeAll}.
    @ivar delayedCalls: The value to return from L{getDelayedCalls}.
    NÚdelayedCallsúlist[DelayedCall]Úselectablesúlist[object] | Noner   r   c                óF   — || _         g | _        d| _        |sg }|| _        dS )zƒ
        @param delayedCalls: See L{StubReactor.delayedCalls}.
        @param selectables: See L{StubReactor.selectables}.
        r   N)rN   Ú
iterationsÚremoveAllCalledrP   )r"   rN   rP   s      r%   Ú__init__zStubReactor.__init__Š   s6   € ð )ˆÔØ.0ˆŒØ ˆÔØð 	ØˆKØ&ˆÔÐÐr&   Útimeoutúfloat | Nonec                ó:   — | j                              |¦  «         dS )z/
        Increment C{self.iterations}.
        N)rS   Úappend)r"   rV   s     r%   ÚiteratezStubReactor.iterate˜   s    € ð 	Œ×Ò˜wÑ'Ô'Ð'Ð'Ð'r&   c                ó   — | j         S )z.
        Return C{self.delayedCalls}.
        )rN   ©r"   s    r%   ÚgetDelayedCallszStubReactor.getDelayedCallsž   s   € ð Ô Ð r&   úlist[object]c                ó0   — | xj         dz  c_         | j        S )zS
        Increment C{self.removeAllCalled} and return C{self.selectables}.
        é   )rT   rP   r\   s    r%   Ú	removeAllzStubReactor.removeAll¤   s!   € ð 	ÐÔ Ñ!ÐÔØÔÐr&   ©N)rN   rO   rP   rQ   r   r   )rV   rW   r   r   )r   rO   )r   r^   )r5   r6   r7   r8   rU   rZ   r]   ra   r9   r&   r%   rM   rM      s   € € € € € ðð ð SWð'ð 'ð 'ð 'ð 'ð(ð (ð (ð (ð (ð!ð !ð !ð !ð ð  ð  ð  ð  ð  r&   rM   c                  ó"   — e Zd ZdZdd„Zdd	„Zd
S )ÚStubErrorReporterz½
    A subset of L{twisted.trial.itrial.IReporter} which records L{addError}
    calls.

    @ivar errors: List of two-tuples of (test, error) which were passed to
        L{addError}.
    r   r   c                ó   — g | _         d S rb   )Úerrorsr\   s    r%   rU   zStubErrorReporter.__init__µ   s   € Ø46ˆŒˆˆr&   ÚtestÚobjectrB   r   c                ó>   — | j                              ||f¦  «         dS )z6
        Record parameters in C{self.errors}.
        N)rf   rY   )r"   rg   rB   s      r%   ÚaddErrorzStubErrorReporter.addError¸   s$   € ð 	Œ×Ò˜D %˜=Ñ)Ô)Ð)Ð)Ð)r&   Nr4   )rg   rh   rB   r   r   r   )r5   r6   r7   r8   rU   rj   r9   r&   r%   rd   rd   ¬   sF   € € € € € ðð ð7ð 7ð 7ð 7ð*ð *ð *ð *ð *ð *r&   rd   c                  ój   — e Zd ZdZdd„Zdd„Zdd„Zdd„Zdd„Zdd	„Z	dd
„Z
dd„Zdd„Zdd„Zdd„ZdS )ÚJanitorTestsz 
    Tests for L{_Janitor}!
    r   r   c                óª   — t          g ¦  «        }t          dd|¬¦  «        }|                     ¦   «          |                      |j        ddg¦  «         dS )a  
        During pending-call cleanup, the reactor will be spun twice with an
        instant timeout. This is not a requirement, it is only a test for
        current behavior. Hopefully Trial will eventually not do this kind of
        reactor stuff.
        N©Úreactorr   )rM   r   Ú_cleanPendingr!   rS   ©r"   ro   Újans      r%   Útest_cleanPendingSpinsReactorz*JanitorTests.test_cleanPendingSpinsReactorÄ   sX   € õ ˜b‘/”/ˆÝ�t˜T¨7Ð3Ñ3Ô3ˆØ×ÒÑÔÐØ×Ò˜Ô+¨a°¨VÑ4Ô4Ð4Ð4Ð4r&   c                óà   — d	d„}g }t          d|di |j        d„ ¦  «        }t          |g¦  «        }t          dd|¬¦  «        }|                     ¦   «          |                      ||g¦  «         dS )
zW
        During pending-call cleanup, the janitor cancels pending timed calls.
        r   r@   c                 ó   — dS )NÚLulzr9   r9   r&   r%   Úfuncz8JanitorTests.test_cleanPendingCancelsCalls.<locals>.funcÕ   s   € Ø�6r&   é,  r9   c                ó   — d S rb   r9   ©Úxs    r%   ú<lambda>z<JanitorTests.test_cleanPendingCancelsCalls.<locals>.<lambda>Ù   s   € ÐQU€ r&   Nrn   ©r   r@   )r	   rY   rM   r   rp   r!   )r"   rw   Ú	cancelledÚdelayedCallro   rr   s         r%   Útest_cleanPendingCancelsCallsz*JanitorTests.test_cleanPendingCancelsCallsÐ   sŒ   € ð
	ð 	ð 	ð 	ð (*ˆ	Ý! # t¨R°°YÔ5EÀ~À~ÑVÔVˆÝ˜{˜mÑ,Ô,ˆÝ�t˜T¨7Ð3Ñ3Ô3ˆØ×ÒÑÔÐØ×Ò˜ [ MÑ2Ô2Ð2Ð2Ð2r&   c           	     óò   — t          dd„ di d„ d„ d„ ¬¦  «        }t          |¦  «        }t          |g¦  «        }t          dd|¬	¦  «        }|                     ¦   «         }|                      ||g¦  «         dS )
aK  
        The Janitor produces string representations of delayed calls from the
        delayed call cleanup method. It gets the string representations
        *before* cancelling the calls; this is important because cancelling the
        call removes critical debugging information from the string
        representation.
        rx   c                 ó   — d S rb   r9   r9   r&   r%   r|   zIJanitorTests.test_cleanPendingReturnsDelayedCallStrings.<locals>.<lambda>è   ó   € ˜€ r&   r9   c                ó   — d S rb   r9   rz   s    r%   r|   zIJanitorTests.test_cleanPendingReturnsDelayedCallStrings.<locals>.<lambda>è   ó   € °€ r&   c                ó   — d S rb   r9   rz   s    r%   r|   zIJanitorTests.test_cleanPendingReturnsDelayedCallStrings.<locals>.<lambda>è   ó   € À€ r&   c                 ó   — dS ©Nr   r9   r9   r&   r%   r|   zIJanitorTests.test_cleanPendingReturnsDelayedCallStrings.<locals>.<lambda>è   ó   € ÐWX€ r&   ©ÚsecondsNrn   )r	   r@   rM   r   rp   r!   )r"   r   ÚdelayedCallStringro   rr   Ústringss         r%   Ú*test_cleanPendingReturnsDelayedCallStringsz7JanitorTests.test_cleanPendingReturnsDelayedCallStringsß   s“   € õ "Ø��˜r 2 ~ ~°~°~ÈyÈyð
ñ 
ô 
ˆõ   Ñ,Ô,ÐÝ˜{˜mÑ,Ô,ˆÝ�t˜T¨7Ð3Ñ3Ô3ˆØ×#Ò#Ñ%Ô%ˆØ×Ò˜Ð#4Ð"5Ñ6Ô6Ð6Ð6Ð6r&   c                ó¦   — t          g ¦  «        }t          dd|¬¦  «        }|                     ¦   «          |                      |j        d¦  «         dS )zM
        The Janitor will remove selectables during reactor cleanup.
        Nrn   r`   )rM   r   Ú_cleanReactorr!   rT   rq   s      r%   Ú#test_cleanReactorRemovesSelectablesz0JanitorTests.test_cleanReactorRemovesSelectablesð   sT   € õ ˜b‘/”/ˆÝ�t˜T¨7Ð3Ñ3Ô3ˆØ×ÒÑÔÐØ×Ò˜Ô0°!Ñ4Ô4Ð4Ð4Ð4r&   c                ó  — t          t          ¦  «         G d„ d¦  «        ¦   «         } |¦   «         }t          g |g¦  «        }t          dd|¬¦  «        }|                     ¦   «          |                      |j        dg¦  «         dS )zI
        The Janitor will kill processes during reactor cleanup.
        c                  ó"   — e Zd ZdZd	d„Zd
d„ZdS )úJJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransportz˜
            A stub L{IProcessTransport} provider which records signals.
            @ivar signals: The signals passed to L{signalProcess}.
            r   r   c                ó   — g | _         d S rb   )Úsignalsr\   s    r%   rU   zSJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransport.__init__  s   € Ø02�”��r&   Úsignalú	str | intc                ó:   — | j                              |¦  «         dS )zF
                Append C{signal} to C{self.signals}.
                N)r—   rY   )r"   r˜   s     r%   ÚsignalProcesszXJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransport.signalProcess  s    € ð ”×#Ò# FÑ+Ô+Ð+Ð+Ð+r&   Nr4   )r˜   r™   r   r   )r5   r6   r7   r8   rU   r›   r9   r&   r%   ÚStubProcessTransportr•   þ   sF   € € € € € ðð ð
3ð 3ð 3ð 3ð,ð ,ð ,ð ,ð ,ð ,r&   rœ   Nrn   ÚKILL)r   r
   rM   r   r‘   r!   r—   )r"   rœ   Úptro   rr   s        r%   Útest_cleanReactorKillsProcessesz,JanitorTests.test_cleanReactorKillsProcessesù   s§   € õ
 
Õ&Ñ	'Ô	'ð	,ð 	,ð 	,ð 	,ð 	,ñ 	,ô 	,ñ 
(Ô	'ð	,ð "Ð!Ñ#Ô#ˆÝ˜b 2 $Ñ'Ô'ˆÝ�t˜T¨7Ð3Ñ3Ô3ˆØ×ÒÑÔÐØ×Ò˜œ f XÑ.Ô.Ð.Ð.Ð.r&   c                óÈ   —  G d„ d¦  «        }t          g  |¦   «         g¦  «        }t          dd|¬¦  «        }|                      |                     ¦   «         dg¦  «         dS )z‹
        The Janitor returns string representations of the selectables that it
        cleaned up from the reactor cleanup method.
        c                  ó   — e Zd ZdZdd„ZdS )úJJanitorTests.test_cleanReactorReturnsSelectableStrings.<locals>.Selectablezl
            A stub Selectable which only has an interesting string
            representation.
            r   r@   c                ó   — dS )Nú(SELECTABLE!)r9   r\   s    r%   Ú__repr__zSJanitorTests.test_cleanReactorReturnsSelectableStrings.<locals>.Selectable.__repr__   s   € Ø&�r&   Nr}   )r5   r6   r7   r8   r¥   r9   r&   r%   Ú
Selectabler¢     s2   € € € € € ðð ð
'ð 'ð 'ð 'ð 'ð 'r&   r¦   Nrn   r¤   )rM   r   r!   r‘   )r"   r¦   ro   rr   s       r%   Ú)test_cleanReactorReturnsSelectableStringsz6JanitorTests.test_cleanReactorReturnsSelectableStrings  s‚   € ð	'ð 	'ð 	'ð 	'ð 	'ñ 	'ô 	'ð 	'õ ˜b : :¡<¤< .Ñ1Ô1ˆÝ�t˜T¨7Ð3Ñ3Ô3ˆØ×Ò˜×*Ò*Ñ,Ô,¨Ð.?Ñ@Ô@Ð@Ð@Ð@r&   c                ó  — t          g ¦  «        }t          ¦   «         }t          ¦   «         }t          |||¬¦  «        }|                      |                     ¦   «         ¦  «         |                      |j        g ¦  «         dS )z�
        The post-case cleanup method will return True and not call C{addError}
        on the result if there are no pending calls.
        rn   N)rM   rh   rd   r   r+   ÚpostCaseCleanupr!   rf   ©r"   ro   rg   Úreporterrr   s        r%   Útest_postCaseCleanupNoErrorsz)JanitorTests.test_postCaseCleanupNoErrors'  ss   € õ
 ˜b‘/”/ˆÝ‰xŒxˆÝ$Ñ&Ô&ˆÝ�t˜X¨wÐ7Ñ7Ô7ˆØ�Š˜×+Ò+Ñ-Ô-Ñ.Ô.Ð.Ø×Ò˜œ¨"Ñ-Ô-Ð-Ð-Ð-r&   c           	     óØ  — t          dd„ di d„ d„ d„ ¬¦  «        }t          |¦  «        }t          |gg ¦  «        }t          ¦   «         }t	          ¦   «         }t          |||¬¦  «        }|                      |                     ¦   «         ¦  «         |                      t          |j
        ¦  «        d	¦  «         |                      |j
        d
         d	         j        j        |g¦  «         dS )z¼
        The post-case cleanup method will return False and call C{addError} on
        the result with a L{DirtyReactorAggregateError} Failure if there are
        pending calls.
        rx   c                 ó   — d S rb   r9   r9   r&   r%   r|   z=JanitorTests.test_postCaseCleanupWithErrors.<locals>.<lambda>:  rƒ   r&   r9   c                ó   — d S rb   r9   rz   s    r%   r|   z=JanitorTests.test_postCaseCleanupWithErrors.<locals>.<lambda>:  r…   r&   c                ó   — d S rb   r9   rz   s    r%   r|   z=JanitorTests.test_postCaseCleanupWithErrors.<locals>.<lambda>:  r‡   r&   c                 ó   — dS r‰   r9   r9   r&   r%   r|   z=JanitorTests.test_postCaseCleanupWithErrors.<locals>.<lambda>:  rŠ   r&   r‹   rn   r`   r   N)r	   r@   rM   rh   rd   r   r-   r©   r!   Úlenrf   ÚvaluerN   ©r"   r   r�   ro   rg   r«   rr   s          r%   Útest_postCaseCleanupWithErrorsz+JanitorTests.test_postCaseCleanupWithErrors3  sê   € õ "Ø��˜r 2 ~ ~°~°~ÈyÈyð
ñ 
ô 
ˆõ   Ñ,Ô,ÐÝ˜{˜m¨RÑ0Ô0ˆÝ‰xŒxˆÝ$Ñ&Ô&ˆÝ�t˜X¨wÐ7Ñ7Ô7ˆØ×Ò˜×,Ò,Ñ.Ô.Ñ/Ô/Ð/Ø×Ò�˜Xœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø×Ò˜œ¨Ô+¨AÔ.Ô4ÔAÐDUÐCVÑWÔWÐWÐWÐWr&   c                óÞ   — t          g ¦  «        }t          ¦   «         }t          ¦   «         }t          |||¬¦  «        }|                     ¦   «          |                      |j        g ¦  «         dS )z�
        The post-class cleanup method will not call C{addError} on the result
        if there are no pending calls or selectables.
        rn   N)rM   rh   rd   r   ÚpostClassCleanupr!   rf   rª   s        r%   Útest_postClassCleanupNoErrorsz*JanitorTests.test_postClassCleanupNoErrorsE  sg   € õ
 ˜b‘/”/ˆÝ‰xŒxˆÝ$Ñ&Ô&ˆÝ�t˜X¨wÐ7Ñ7Ô7ˆØ×ÒÑÔÐØ×Ò˜œ¨"Ñ-Ô-Ð-Ð-Ð-r&   c           	     ó²  — t          dd„ di d„ d„ d„ ¬¦  «        }t          |¦  «        }t          |gg ¦  «        }t          ¦   «         }t	          ¦   «         }t          |||¬¦  «        }|                     ¦   «          |                      t          |j	        ¦  «        d	¦  «         |                      |j	        d
         d	         j
        j        |g¦  «         dS )zŸ
        The post-class cleanup method call C{addError} on the result with a
        L{DirtyReactorAggregateError} Failure if there are pending calls.
        rx   c                 ó   — d S rb   r9   r9   r&   r%   r|   zIJanitorTests.test_postClassCleanupWithPendingCallErrors.<locals>.<lambda>W  rƒ   r&   r9   c                ó   — d S rb   r9   rz   s    r%   r|   zIJanitorTests.test_postClassCleanupWithPendingCallErrors.<locals>.<lambda>W  r…   r&   c                ó   — d S rb   r9   rz   s    r%   r|   zIJanitorTests.test_postClassCleanupWithPendingCallErrors.<locals>.<lambda>W  r‡   r&   c                 ó   — dS r‰   r9   r9   r&   r%   r|   zIJanitorTests.test_postClassCleanupWithPendingCallErrors.<locals>.<lambda>W  rŠ   r&   r‹   rn   r`   r   N)r	   r@   rM   rh   rd   r   r·   r!   r²   rf   r³   rN   r´   s          r%   Ú*test_postClassCleanupWithPendingCallErrorsz7JanitorTests.test_postClassCleanupWithPendingCallErrorsQ  sÜ   € õ
 "Ø��˜r 2 ~ ~°~°~ÈyÈyð
ñ 
ô 
ˆõ   Ñ,Ô,ÐÝ˜{˜m¨RÑ0Ô0ˆÝ‰xŒxˆÝ$Ñ&Ô&ˆÝ�t˜X¨wÐ7Ñ7Ô7ˆØ×ÒÑÔÐØ×Ò�˜Xœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø×Ò˜œ¨Ô+¨AÔ.Ô4ÔAÐDUÐCVÑWÔWÐWÐWÐWr&   c                ó~  — d}t          g |g¦  «        }t          ¦   «         }t          ¦   «         }t          |||¬¦  «        }|                     ¦   «          |                      t          |j        ¦  «        d¦  «         |                      |j        d         d         j        j	        t          |¦  «        g¦  «         dS )z�
        The post-class cleanup method call C{addError} on the result with a
        L{DirtyReactorAggregateError} Failure if there are selectables.
        zSELECTABLE HERErn   r`   r   N)rM   rh   rd   r   r·   r!   r²   rf   r³   rP   Úrepr)r"   Ú
selectablero   rg   r«   rr   s         r%   Ú)test_postClassCleanupWithSelectableErrorsz6JanitorTests.test_postClassCleanupWithSelectableErrorsb  s­   € ð
 'ˆ
Ý˜b : ,Ñ/Ô/ˆÝ‰xŒxˆÝ$Ñ&Ô&ˆÝ�t˜X¨wÐ7Ñ7Ô7ˆØ×ÒÑÔÐØ×Ò�˜Xœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø×Ò˜œ¨Ô+¨AÔ.Ô4Ô@Å4È
ÑCSÔCSÐBTÑUÔUÐUÐUÐUr&   Nr4   )r5   r6   r7   r8   rs   r€   r�   r’   rŸ   r§   r¬   rµ   r¸   r¾   rÂ   r9   r&   r%   rl   rl   ¿   s  € € € € € ðð ð
5ð 
5ð 
5ð 
5ð3ð 3ð 3ð 3ð7ð 7ð 7ð 7ð"5ð 5ð 5ð 5ð/ð /ð /ð /ð6Að Að Að Að&
.ð 
.ð 
.ð 
.ðXð Xð Xð Xð$
.ð 
.ð 
.ð 
.ðXð Xð Xð Xð"Vð Vð Vð Vð Vð Vr&   rl   c                  ó*   — e Zd ZdZdd„Zdd„Zdd„ZdS )	ÚRemoveSafelyTestsz*
    Tests for L{util._removeSafely}.
    r   r   c                óú   — |                       ¦   «                              d¦  «        }t          j        |¦  «         t	          j        |¦  «        }|                      t          j        t          j	        |¦  «         dS )zÈ
        If a path doesn't contain a node named C{"_trial_marker"}, that path is
        not removed by L{util._removeSafely} and a L{util._NoTrialMarker}
        exception is raised instead.
        úutf-8N)
r   Úencoder   Úmkdirr   ÚFilePathÚassertRaisesr   Ú_NoTrialMarkerÚ_removeSafely)r"   Ú	directoryÚdirPaths      r%   Útest_removeSafelyNoTrialMarkerz0RemoveSafelyTests.test_removeSafelyNoTrialMarkerv  sc   € ð —K’K‘M”M×(Ò(¨Ñ1Ô1ˆ	Ý
Œ�ÑÔÐÝÔ# IÑ.Ô.ˆØ×Ò�$Ô-­tÔ/AÀ7ÑKÔKÐKÐKÐKr&   c                óÔ  — d	d„}t          ¦   «         }|                      t          d|¦  «         |                      ¦   «                              d¦  «        }t          j        |¦  «         t          j        |¦  «        }| 	                    d¦  «         
                    ¦   «          ||_        t          j        |¦  «         |                      d|                     ¦   «         ¦  «         dS )
zŸ
        If an L{OSError} is raised while removing a path in
        L{util._removeSafely}, an attempt is made to move the path to a new
        name.
        r   r   c                 ó   — t          ¦   «         ‚)ú…
            Raise an C{OSError} to emulate the branch of L{util._removeSafely}
            in which path removal fails.
            ©ÚOSErrorr9   r&   r%   ÚdummyRemovezORemoveSafelyTests.test_removeSafelyRemoveFailsMoveSucceeds.<locals>.dummyRemoveˆ  s   € õ
 ‘)”)ˆOr&   ÚstdoutrÆ   ó   _trial_markerúcould not remove FilePathNr4   )r   ÚpatchÚsysr   rÇ   r   rÈ   r   rÉ   ÚchildÚtouchÚremover   rÌ   ÚassertInÚgetvalue)r"   rÕ   ÚoutrÍ   rÎ   s        r%   Ú(test_removeSafelyRemoveFailsMoveSucceedsz:RemoveSafelyTests.test_removeSafelyRemoveFailsMoveSucceeds�  sÎ   € ð	ð 	ð 	ð 	õ ‰jŒjˆØ�
Š
•3˜ #Ñ&Ô&Ð&ð —K’K‘M”M×(Ò(¨Ñ1Ô1ˆ	Ý
Œ�ÑÔÐÝÔ# IÑ.Ô.ˆØ�ŠÐ&Ñ'Ô'×-Ò-Ñ/Ô/Ð/à$ˆŒåÔ˜7Ñ#Ô#Ð#Ø�ŠÐ1°3·<²<±>´>ÑBÔBÐBÐBÐBr&   c                óV  — dd„}ddd	„}t          ¦   «         }|                      t          d
|¦  «         |                      ¦   «                              d¦  «        }t          j        |¦  «         t          j        |¦  «        }| 	                    d¦  «         
                    ¦   «          ||_        ||_        |                      t          t          j        |¦  «        }|                      t%          |¦  «        d¦  «         |                      d|                     ¦   «         ¦  «         dS )zÓ
        If an L{OSError} is raised while removing a path in
        L{util._removeSafely}, an attempt is made to move the path to a new
        name. If that attempt fails, the L{OSError} is re-raised.
        r   r   c                 ó    — t          d¦  «        ‚)rÒ   zpath removal failedrÓ   r9   r&   r%   rÕ   zLRemoveSafelyTests.test_removeSafelyRemoveFailsMoveFails.<locals>.dummyRemove¥  s   € õ
 Ð/Ñ0Ô0Ð0r&   TÚdestinationrh   ÚfollowLinksÚboolc                ó    — t          d¦  «        ‚)z†
            Raise an C{OSError} to emulate the branch of L{util._removeSafely}
            in which path movement fails.
            úpath movement failedrÓ   )rä   rå   s     r%   ÚdummyMoveTozLRemoveSafelyTests.test_removeSafelyRemoveFailsMoveFails.<locals>.dummyMoveTo¬  s   € õ
 Ð0Ñ1Ô1Ð1r&   rÖ   rÆ   r×   rè   rØ   Nr4   )T)rä   rh   rå   ræ   r   r   )r   rÙ   rÚ   r   rÇ   r   rÈ   r   rÉ   rÛ   rÜ   rÝ   ÚmoveTorÊ   rÔ   r   rÌ   r!   r@   rÞ   rß   )r"   rÕ   ré   rà   rÍ   rÎ   rB   s          r%   Ú%test_removeSafelyRemoveFailsMoveFailsz7RemoveSafelyTests.test_removeSafelyRemoveFailsMoveFailsž  s  € ð	1ð 	1ð 	1ð 	1ð	2ð 	2ð 	2ð 	2ð 	2õ ‰jŒjˆØ�
Š
•3˜ #Ñ&Ô&Ð&ð —K’K‘M”M×(Ò(¨Ñ1Ô1ˆ	Ý
Œ�ÑÔÐÝÔ# IÑ.Ô.ˆØ�ŠÐ&Ñ'Ô'×-Ò-Ñ/Ô/Ð/ð %ˆŒØ$ˆŒà×!Ò!¥'­4Ô+=¸wÑGÔGˆØ×Ò�˜U™œÐ%;Ñ<Ô<Ð<Ø�ŠÐ1°3·<²<±>´>ÑBÔBÐBÐBÐBr&   Nr4   )r5   r6   r7   r8   rÏ   rá   rë   r9   r&   r%   rÄ   rÄ   q  sh   € € € € € ðð ð	Lð 	Lð 	Lð 	LðCð Cð Cð Cð:%Cð %Cð %Cð %Cð %Cð %Cr&   rÄ   c                  ó"   — e Zd ZdZdd„Zdd„ZdS )ÚExcInfoTestsz1
    Tests for L{excInfoOrFailureToExcInfo}.
    r   r   c                ó|   — t           t          d¦  «        df}|                      |t          |¦  «        u ¦  «         dS )z›
        L{excInfoOrFailureToExcInfo} returns exactly what it is passed, if it is
        passed a tuple like the one returned by L{sys.exc_info}.
        ÚfooN)Ú
ValueErrorr+   r   )r"   Úinfos     r%   Útest_excInfozExcInfoTests.test_excInfoË  s>   € õ
 �J uÑ-Ô-¨tÐ4ˆØ�Š˜Õ 9¸$Ñ ?Ô ?Ð?Ñ@Ô@Ð@Ð@Ð@r&   c                óº   — 	 ddz   n# t           $ r t          ¦   «         }Y nw xY w|                      |j        |j        |j        ft          |¦  «        ¦  «         dS )zì
        When called with a L{Failure} instance, L{excInfoOrFailureToExcInfo}
        returns a tuple like the one returned by L{sys.exc_info}, with the
        elements taken from the type, value, and traceback of the failure.
        r`   r   N)ÚBaseExceptionr   r!   Útyper³   Útbr   )r"   Úfs     r%   Útest_failurezExcInfoTests.test_failureÓ  sl   € ð	Ø�‰EˆEˆEøÝð 	ð 	ð 	Ý‘	”	ˆAˆAˆAð	øøøà×Ò˜!œ& !¤'¨1¬4Ð0Õ2KÈAÑ2NÔ2NÑOÔOÐOÐOÐOs   ‚ ˆ#¢#Nr4   )r5   r6   r7   r8   rò   rø   r9   r&   r%   rí   rí   Æ  sP   € € € € € ðð ðAð Að Að Að
Pð 
Pð 
Pð 
Pð 
Pð 
Pr&   rí   c                  ó2   — e Zd ZdZd	d„Zd	d„Zd	d„Zd	d„ZdS )
ÚAcquireAttributeTestsz(
    Tests for L{acquireAttribute}.
    r   r   c                ó–   — t          ¦   «         x| _        }|                      |t          | t          ¦   «         gd¦  «        u ¦  «         dS )z·
        The value returned by L{acquireAttribute} is the value of the requested
        attribute on the first object in the list passed in which has that
        attribute.
        r³   N©rh   r³   r+   r   ©r"   r³   s     r%   Útest_foundOnEarlierObjectz/AcquireAttributeTests.test_foundOnEarlierObjectå  sE   € õ $™XœXÐ%ˆŒ
�UØ�Š˜Õ!1°4½¹¼Ð2BÀGÑ!LÔ!LÐLÑMÔMÐMÐMÐMr&   c                ó–   — t          ¦   «         x| _        }|                      |t          t          ¦   «         | gd¦  «        u ¦  «         dS )z§
        The same as L{test_foundOnEarlierObject}, but for the case where the 2nd
        element in the object list has the attribute and the first does not.
        r³   Nrü   rý   s     r%   Útest_foundOnLaterObjectz-AcquireAttributeTests.test_foundOnLaterObjectî  sE   € õ
 $™XœXÐ%ˆŒ
�UØ�Š˜Õ!1µ6±8´8¸TÐ2BÀGÑ!LÔ!LÐLÑMÔMÐMÐMÐMr&   c                ód   — |                       t          t          t          ¦   «         gd¦  «         dS )z•
        If none of the objects passed in the list to L{acquireAttribute} have
        the requested attribute, L{AttributeError} is raised.
        rï   N)rÊ   ÚAttributeErrorr   rh   r\   s    r%   Útest_notFoundExceptionz,AcquireAttributeTests.test_notFoundExceptionö  s+   € ð
 	×Ò�.Õ*:½V¹X¼X¸JÈÑNÔNÐNÐNÐNr&   c                óˆ   — t          ¦   «         }|                      |t          t          ¦   «         gd|¦  «        u ¦  «         dS )z¼
        If none of the objects passed in the list to L{acquireAttribute} have
        the requested attribute and a default value is given, the default value
        is returned.
        rï   N)rh   r+   r   )r"   Údefaults     r%   Útest_notFoundDefaultz*AcquireAttributeTests.test_notFoundDefaultý  s=   € õ ‘(”(ˆØ�Š˜Õ#3µV±X´X°JÀÀwÑ#OÔ#OÐOÑPÔPÐPÐPÐPr&   Nr4   )r5   r6   r7   r8   rþ   r   r  r  r9   r&   r%   rú   rú   à  s€   € € € € € ðð ðNð Nð Nð NðNð Nð Nð NðOð Oð Oð OðQð Qð Qð Qð Qð Qr&   rú   c                  óZ   — e Zd ZdZdd„Zdd„Zdd„Zdd„Zdd„Zdd	„Z	dd
„Z
dd„Zdd„ZdS )ÚListToPhraseTestszÆ
    Input is transformed into a string representation of the list,
    with each item separated by delimiter (defaulting to a comma) and the final
    two being separated by a final delimiter.
    r   r   c                ód   — g }d}t          j        |d¦  «        }|                      ||¦  «         dS )zB
        If things is empty, an empty string is returned.
        Ú ÚandN©r   Ú_listToPhraser!   ©r"   ÚsampleÚexpectedÚresults       r%   Ú
test_emptyzListToPhraseTests.test_empty  s<   € ð  ˆØˆÝÔ# F¨EÑ2Ô2ˆØ×Ò˜ 6Ñ*Ô*Ð*Ð*Ð*r&   c                óf   — dg}d}t          j        |d¦  «        }|                      ||¦  «         dS )z;
        With a single item, the item is returned.
        ÚOner  Nr  r  s       r%   Útest_oneWordzListToPhraseTests.test_oneWord  s>   € ð �ˆØˆÝÔ# F¨EÑ2Ô2ˆØ×Ò˜ 6Ñ*Ô*Ð*Ð*Ð*r&   c                óh   — ddg}d}t          j        |d¦  «        }|                      ||¦  «         dS )zA
        Two words are separated by the final delimiter.
        r  ÚTwozOne and Twor  Nr  r  s       r%   Útest_twoWordszListToPhraseTests.test_twoWords   s@   € ð ˜�ˆØ ˆÝÔ# F¨EÑ2Ô2ˆØ×Ò˜ 6Ñ*Ô*Ð*Ð*Ð*r&   c                óh   — g d¢}d}t          j        |d¦  «        }|                      ||¦  «         dS )zY
        With more than two words, the first two are separated by the delimiter.
        )r  r  ÚThreezOne, Two, and Threer  Nr  r  s       r%   Útest_threeWordsz!ListToPhraseTests.test_threeWords)  sB   € ð )Ð(Ð(ˆØ(ˆÝÔ# F¨EÑ2Ô2ˆØ×Ò˜ 6Ñ*Ô*Ð*Ð*Ð*r&   c                ól   — g d¢}d}t          j        |dd¬¦  «        }|                      ||¦  «         dS )zW
        If a delimiter is specified, it is used instead of the default comma.
        )r  r  r  ÚFourzOne; Two; Three; or FourÚorz; )Ú	delimiterNr  r  s       r%   Útest_fourWordsz ListToPhraseTests.test_fourWords2  sG   € ð 1Ð0Ð0ˆØ-ˆÝÔ# F¨D¸DÐAÑAÔAˆØ×Ò˜ 6Ñ*Ô*Ð*Ð*Ð*r&   c                óh   — g d¢}d}t          j        |d¦  «        }|                      ||¦  «         dS )zS
        If something in things is not a string, it is converted into one.
        )r`   é   Úthreez1, 2, and threer  Nr  r  s       r%   Útest_notStringz ListToPhraseTests.test_notString;  s@   € ð !��ˆØ$ˆÝÔ# F¨EÑ2Ô2ˆØ×Ò˜ 6Ñ*Ô*Ð*Ð*Ð*r&   c                óž   — d}|                       t          t          j        |d¦  «        }|                      t          |¦  «        d¦  «         dS )z?
        If things is a string, a TypeError is raised.
        zOne, two, threer  ú Things must be a list or a tupleN©rÊ   Ú	TypeErrorr   r  r!   r@   ©r"   r  rB   s      r%   Útest_stringTypeErrorz&ListToPhraseTests.test_stringTypeErrorD  sH   € ð #ˆØ×!Ò!¥)­TÔ-?ÀÈÑOÔOˆØ×Ò�˜U™œÐ%GÑHÔHÐHÐHÐHr&   c                ó¼   — t          g d¢¦  «        }|                      t          t          j        |d¦  «        }|                      t          |¦  «        d¦  «         dS )zB
        If things is an iterator, a TypeError is raised.
        )r`   r"  é   r  r&  N)ÚiterrÊ   r(  r   r  r!   r@   r)  s      r%   Útest_iteratorTypeErrorz(ListToPhraseTests.test_iteratorTypeErrorL  sR   € õ �i�i�i‘”ˆØ×!Ò!¥)­TÔ-?ÀÈÑOÔOˆØ×Ò�˜U™œÐ%GÑHÔHÐHÐHÐHr&   c                ó¢   — dd„}|                       t          t          j        |d¦  «        }|                      t          |¦  «        d¦  «         dS )zB
        If things is a generator, a TypeError is raised.
        r   úGenerator[int, None, None]c               3  ó4   K  — t          d¦  «        E d {V —† d S )Nr"  )Úranger9   r&   r%   r  z9ListToPhraseTests.test_generatorTypeError.<locals>.sampleY  s*   è è € Ý˜Q‘x”xÐÐÐÐÐÐÐÐÐr&   r  r&  N)r   r0  r'  r)  s      r%   Útest_generatorTypeErrorz)ListToPhraseTests.test_generatorTypeErrorT  sW   € ð
	 ð 	 ð 	 ð 	 ð ×!Ò!¥)­TÔ-?ÀÈÑOÔOˆØ×Ò�˜U™œÐ%GÑHÔHÐHÐHÐHr&   Nr4   )r5   r6   r7   r8   r  r  r  r  r   r$  r*  r.  r3  r9   r&   r%   r  r    sà   € € € € € ðð ð+ð +ð +ð +ð+ð +ð +ð +ð+ð +ð +ð +ð+ð +ð +ð +ð+ð +ð +ð +ð+ð +ð +ð +ðIð Ið Ið IðIð Ið Ið Ið	Ið 	Ið 	Ið 	Ið 	Ið 	Ir&   r  c                  ó"   — e Zd ZdZdd„Zdd„ZdS )ÚOpenTestLogTestsz#
    Tests for C{openTestLog}.
    r   r   c                ój  — t          j        ¦   «         }|                      t           j        t           j        |¦  «         t          j        t           j        d¦  «         d}t          j        |                      ¦   «         ¦  «        }t          |¦  «        5 }| 	                    |¦  «         ddd¦  «         n# 1 swxY w Y   t          |j        d¦  «        5 }|                     ¦   «         }ddd¦  «         n# 1 swxY w Y   t          |                     d¦  «        t          |¦  «        ¦  «         dS )zR
        The log file is opened in text mode and uses UTF-8 for encoding.
        )ÚCÚasciiu   Here comes the â˜‰NÚrbrÆ   )ÚlocaleÚ	getlocaleÚ
addCleanupÚ	setlocaleÚLC_ALLr   rÉ   r   r   ÚwriteÚopenr   Úreadr   rÇ   r   )r"   ÚcurrentLocaleÚtextÚpr÷   Úwrittens         r%   Ú	test_utf8zOpenTestLogTests.test_utf8e  sk  € õ Ô(Ñ*Ô*ˆØ�Š�Ô(­&¬-¸ÑGÔGÐGÝÔ�œ¨Ñ7Ô7Ð7à'ˆÝÔ˜dŸkšk™mœmÑ,Ô,ˆÝ˜‰^Œ^ð 	˜qØ�GŠG�D‰MŒMˆMð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	õ �!”&˜$ÑÔð 	 1Ø—f’f‘h”hˆGð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	õ 	�D—K’K Ñ(Ô(­(°7Ñ*;Ô*;Ñ<Ô<Ð<Ð<Ð<s$   ÂB7Â7B;Â>B;ÃC8Ã8C<Ã?C<c                ó  — d}d}dt           j        › dt           j        › �}t          j        |                      ¦   «         ¦  «        }t          |¦  «        5 }|                     |¦  «         ddd¦  «         n# 1 swxY w Y   t          |¦  «        5 }|                     |¦  «         ddd¦  «         n# 1 swxY w Y   t          |                     ¦   «          	                    d¦  «        t          |¦  «        ¦  «         dS )z™
        The log file is opened in append mode so if runner configuration specifies
        an existing log file its contents are not wiped out.
        zHello, world.
 zGoodbye, world.
zHello, world.z Goodbye, world.NrÆ   )r   Úlinesepr   rÉ   r   r   r?  r   Ú
getContentÚdecoder   )r"   ÚexistingTextÚnewTextr  rD  r÷   s         r%   Útest_appendzOpenTestLogTests.test_append{  sa  € ð
 *ˆØ%ˆØK¥2¤:ÐKÐK½r¼zÐKÐKˆÝÔ˜dŸkšk™mœmÑ,Ô,ˆÝ˜‰^Œ^ð 	"˜qØ�GŠG�LÑ!Ô!Ð!ð	"ð 	"ð 	"ñ 	"ô 	"ð 	"ð 	"ð 	"ð 	"ð 	"ð 	"øøøð 	"ð 	"ð 	"ð 	"å˜‰^Œ^ð 	˜qØ�GŠG�GÑÔÐð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	õ 	Ø�LŠL‰NŒN×!Ò! 'Ñ*Ô*Ý�XÑÔñ	
ô 	
ð 	
ð 	
ð 	
s$   ÁA8Á8A<Á?A<ÂB4Â4B8Â;B8Nr4   )r5   r6   r7   r8   rF  rM  r9   r&   r%   r5  r5  `  sF   € € € € € ðð ð=ð =ð =ð =ð,
ð 
ð 
ð 
ð 
ð 
r&   r5  )+r8   Ú
__future__r   r:  r   rÚ   Úior   Útypingr   Úzope.interfacer   Úhamcrestr   r   Útwisted.internet.baser	   Útwisted.internet.interfacesr
   Útwisted.pythonr   Útwisted.python.failurer   Útwisted.trialr   Útwisted.trial.unittestr   Útwisted.trial.utilr   r   r   r   r   r   r;   rM   rd   rl   rÄ   rí   rú   r  r5  r9   r&   r%   ú<module>rZ     s7  ðð
ð ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø 	€	€	€	Ø 
€
€
€
Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à &Ð &Ð &Ð &Ð &Ð &à *Ð *Ð *Ð *Ð *Ð *Ð *Ð *à -Ð -Ð -Ð -Ð -Ð -Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø #Ð #Ð #Ð #Ð #Ð #Ø *Ð *Ð *Ð *Ð *Ð *Ø Ð Ð Ð Ð Ð Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6ðð ð ð ð ð ð ð ð ð ð ð ð ð ð&6ð &6ð &6ð &6ð &6Ð%ñ &6ô &6ð &6ðR0
ð 0
ð 0
ð 0
ð 0
Ð&9ñ 0
ô 0
ð 0
ðf* ð * ð * ð * ð * ñ * ô * ð * ðZ*ð *ð *ð *ð *ñ *ô *ð *ð&oVð oVð oVð oVð oVÐ&ñ oVô oVð oVðdRCð RCð RCð RCð RCÐ+ñ RCô RCð RCðjPð Pð Pð Pð PÐ&ñ Pô Pð Pð4$Qð $Qð $Qð $Qð $QÐ/ñ $Qô $Qð $QðNVIð VIð VIð VIð VIÐ+ñ VIô VIð VIðr,
ð ,
ð ,
ð ,
ð ,
Ð*ñ ,
ô ,
ð ,
ð ,
ð ,
r&   