ó
    ×›‘h–V  ã                  óœ  • S r SSKJr  SSKrSSKrSSKrSSKJr  SSKJ	r	  SSK
Jr  SSKJrJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJrJrJrJrJ r    " S S\5      r! " S S\5      r" " S S5      r# " S S5      r$ " S S\5      r% " S S\5      r& " S S\5      r' " S S\5      r( " S S \5      r) " S! S"\5      r*g)#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                  ó@   • \ rS rSrSrS	S jrS	S jrS	S jrS	S jrSr	g)
ÚMktempTestsé#   za
Tests for L{TestCase.mktemp}, a helper function for creating temporary file
or directory names.
c                óÊ   • U R                  5       n[        R                  R                  U5      R	                  [        R
                  5      SS nU R                  U/ SQ5        g)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      Ú`C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/trial/test/test_util.pyr   ÚMktempTests.test_name)   sK   € ð
 �{‰{‹}ˆÜ�w‰w�‰˜tÓ$×*Ñ*¬2¯6©6Ó2°3°BÐ7ˆØ×ÑØÒNõ	
ó    c                ób   • U R                  5       nU R                  XR                  5       5        g)z6
Repeated calls to C{mktemp} return different values.
N)r   ÚassertNotEqual)r!   r"   s     r$   Útest_uniqueÚMktempTests.test_unique4   s#   € ð �{‰{‹}ˆØ×Ñ˜D§+¡+£-Õ0r&   c                ó  • U R                  5       n[        R                  R                  U5      nU R	                  [        R                  R                  U5      5        U R                  [        R                  R                  U5      5        g)zC
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_createdÚMktempTests.test_created;   sU   € ð �{‰{‹}ˆÜ—'‘'—/‘/ $Ó'ˆØ�‰œŸ™Ÿ™ wÓ/Ô0Ø×ÑœŸ™Ÿ™¨Ó-Õ.r&   c                óÄ   • [         R                  R                  U R                  5       5      nU R	                  UR                  [         R                  " 5       5      5        g)zJ
The path returned by C{mktemp} is beneath the current working directory.
N)r   r   Úabspathr   r,   Ú
startswithÚgetcwd)r!   r   s     r$   Útest_locationÚMktempTests.test_locationD   s7   € ô �w‰w�‰˜tŸ{™{›}Ó-ˆØ�‰˜Ÿ™¬¯	ª	«Ó4Õ5r&   © N©ÚreturnÚNone)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r)   r/   r5   Ú__static_attributes__r7   r&   r$   r   r   #   s   † ñô
	
ô1ô/÷6r&   r   c                  ó6   • \ rS rSrSrSS jrSS jrSS jrSrg)	ÚDirtyReactorAggregateErrorTestséL   z.
Tests for the L{DirtyReactorAggregateError}.
c                óT   • [        SS/5      nU R                  [        U5      S5        g)z%
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_formatDelayedCallÚ6DirtyReactorAggregateErrorTests.test_formatDelayedCallQ   s,   € ô +¨E°5¨>Ó:ˆØ×ÑÜ�‹Jðõ	
r&   c                óV   • [        / SS/5      nU R                  [        U5      S5        g)z#
Selectables are formatted nicely.
zselectable 1zselectable 2z;Reactor was unclean.
Selectables:
selectable 1
selectable 2NrG   rI   s     r$   Útest_formatSelectablesÚ6DirtyReactorAggregateErrorTests.test_formatSelectables_   s/   € ô +¨2°ÀÐ/OÓPˆØ×ÑÜ�‹Jðõ	
r&   c                óZ   • [        SS/SS/5      nU R                  [        U5      S5        g)zB
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
Sel2NrG   rI   s     r$   Ú%test_formatDelayedCallsAndSelectablesÚEDirtyReactorAggregateErrorTests.test_formatDelayedCallsAndSelectablesm   s4   € ô +¨G°WÐ+=ÀÈÐ?OÓPˆØ×ÑÜ�‹Jðõ
	
r&   r7   Nr8   )	r;   r<   r=   r>   r?   rK   rN   rU   r@   r7   r&   r$   rB   rB   L   s   † ñô
ô
÷
r&   rB   c                  óT   • \ rS rSrSr S	     S
S jjrS	SS jjrSS jrSS jrSr	g)ÚStubReactoré   ab  
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}.
Nc                óJ   • Xl         / U l        SU l        U(       d  / nX l        g)zk
@param delayedCalls: See L{StubReactor.delayedCalls}.
@param selectables: See L{StubReactor.selectables}.
r   N©ÚdelayedCallsÚ
iterationsÚremoveAllCalledÚselectables)r!   r\   r_   s      r$   Ú__init__ÚStubReactor.__init__Š   s'   € ð )ÔØ.0ˆŒØ ˆÔÞØˆKØ&Õr&   c                ó:   • U R                   R                  U5        g)z
Increment C{self.iterations}.
N)r]   Úappend)r!   Útimeouts     r$   ÚiterateÚStubReactor.iterate˜   s   € ð 	�‰×Ñ˜wÕ'r&   c                ó   • U R                   $ )z
Return C{self.delayedCalls}.
)r\   ©r!   s    r$   ÚgetDelayedCallsÚStubReactor.getDelayedCallsž   s   € ð × Ñ Ð r&   c                óD   • U =R                   S-  sl         U R                  $ )zC
Increment C{self.removeAllCalled} and return C{self.selectables}.
é   )r^   r_   rh   s    r$   Ú	removeAllÚStubReactor.removeAll¤   s!   € ð 	×Ò Ñ!ÕØ×ÑÐr&   r[   ©N)r\   úlist[DelayedCall]r_   zlist[object] | Noner9   r:   )rd   zfloat | Noner9   r:   )r9   rp   )r9   zlist[object])
r;   r<   r=   r>   r?   r`   re   ri   rm   r@   r7   r&   r$   rX   rX      s:   † ñð SWð'Ø-ð'Ø<Oð'à	õ'ö(ô!÷ r&   rX   c                  ó,   • \ rS rSrSrSS jrSS jrSrg)	ÚStubErrorReporteré¬   z©
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}.
c                ó   • / U l         g ro   ©Úerrorsrh   s    r$   r`   ÚStubErrorReporter.__init__µ   s	   € Ø46ˆ�r&   c                ó<   • U R                   R                  X45        g)z&
Record parameters in C{self.errors}.
N)rv   rc   )r!   ÚtestrJ   s      r$   ÚaddErrorÚStubErrorReporter.addError¸   s   € ð 	�‰×Ñ˜D˜=Õ)r&   ru   Nr8   )ry   ÚobjectrJ   r   r9   r:   )r;   r<   r=   r>   r?   r`   rz   r@   r7   r&   r$   rr   rr   ¬   s   † ñô7÷*r&   rr   c                  ó†   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSS jrSS jrSrg)ÚJanitorTestsé¿   z
Tests for L{_Janitor}!
c                óŒ   • [        / 5      n[        SSUS9nUR                  5         U R                  UR                  SS/5        g)zÜ
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   )rX   r   Ú_cleanPendingr    r]   ©r!   r‚   Újans      r$   Útest_cleanPendingSpinsReactorÚ*JanitorTests.test_cleanPendingSpinsReactorÄ   sA   € ô ˜b“/ˆÜ�t˜T¨7Ñ3ˆØ×ÑÔØ×Ñ˜×+Ñ+¨a°¨VÕ4r&   c                óº   • SS jn/ n[        SUS0 UR                  S 5      n[        U/5      n[        SSUS9nUR	                  5         U R                  X#/5        g)zG
During pending-call cleanup, the janitor cancels pending timed calls.
c                 ó   • g)NÚLulzr7   r7   r&   r$   ÚfuncÚ8JanitorTests.test_cleanPendingCancelsCalls.<locals>.funcÕ   s   € Ør&   é,  r7   c                ó   • g ro   r7   ©Úxs    r$   Ú<lambda>Ú<JanitorTests.test_cleanPendingCancelsCalls.<locals>.<lambda>Ù   s   € ÐQUr&   Nr�   ©r9   rH   )r	   rc   rX   r   rƒ   r    )r!   r‹   Ú	cancelledÚdelayedCallr‚   r…   s         r$   Útest_cleanPendingCancelsCallsÚ*JanitorTests.test_cleanPendingCancelsCallsÐ   s^   € ô
	ð (*ˆ	Ü! # t¨R°°Y×5EÑ5EÁ~ÓVˆÜ˜{˜mÓ,ˆÜ�t˜T¨7Ñ3ˆØ×ÑÔØ×Ñ˜ MÕ2r&   c           
     ó²   • [        SS S0 S S S S9n[        U5      n[        U/5      n[        SSUS	9nUR	                  5       nU R                  XR/5        g)
a  
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.
r�   c                 ó   • g ro   r7   r7   r&   r$   r‘   ÚIJanitorTests.test_cleanPendingReturnsDelayedCallStrings.<locals>.<lambda>è   ó   € ˜r&   r7   c                ó   • g ro   r7   r�   s    r$   r‘   rš   è   ó   € °r&   c                ó   • g ro   r7   r�   s    r$   r‘   rš   è   ó   € Àr&   c                 ó   • g©Nr   r7   r7   r&   r$   r‘   rš   è   ó   € ÐWXr&   ©ÚsecondsNr�   )r	   rH   rX   r   rƒ   r    )r!   r•   ÚdelayedCallStringr‚   r…   Ústringss         r$   Ú*test_cleanPendingReturnsDelayedCallStringsÚ7JanitorTests.test_cleanPendingReturnsDelayedCallStringsß   sc   € ô "Ø‘˜r 2¡~±~Éyñ
ˆô   Ó,ÐÜ˜{˜mÓ,ˆÜ�t˜T¨7Ñ3ˆØ×#Ñ#Ó%ˆØ×Ñ˜Ð"5Õ6r&   c                óˆ   • [        / 5      n[        SSUS9nUR                  5         U R                  UR                  S5        g)z=
The Janitor will remove selectables during reactor cleanup.
Nr�   rl   )rX   r   Ú_cleanReactorr    r^   r„   s      r$   Ú#test_cleanReactorRemovesSelectablesÚ0JanitorTests.test_cleanReactorRemovesSelectablesð   s=   € ô ˜b“/ˆÜ�t˜T¨7Ñ3ˆØ×ÑÔØ×Ñ˜×0Ñ0°!Õ4r&   c                óÔ   • [        [        5       " S S5      5       nU" 5       n[        / U/5      n[        SSUS9nUR	                  5         U R                  UR                  S/5        g)z9
The Janitor will kill processes during reactor cleanup.
c                  ó,   • \ rS rSrSrSS jrSS jrSrg)	ÚJJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransportéþ   zt
A stub L{IProcessTransport} provider which records signals.
@ivar signals: The signals passed to L{signalProcess}.
c                ó   • / U l         g ro   ©Úsignalsrh   s    r$   r`   ÚSJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransport.__init__  s	   € Ø02�•r&   c                ó:   • U R                   R                  U5        g)z&
Append C{signal} to C{self.signals}.
N)r³   rc   )r!   Úsignals     r$   ÚsignalProcessÚXJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransport.signalProcess  s   € ð —‘×#Ñ# FÕ+r&   r²   Nr8   )r¶   z	str | intr9   r:   )r;   r<   r=   r>   r?   r`   r·   r@   r7   r&   r$   ÚStubProcessTransportr¯   þ   s   † ñô
3÷,r&   r¹   Nr�   ÚKILL)r   r
   rX   r   rª   r    r³   )r!   r¹   Úptr‚   r…   s        r$   Útest_cleanReactorKillsProcessesÚ,JanitorTests.test_cleanReactorKillsProcessesù   si   € ô
 
Ô&Ó	'÷	,ð 	,ó 
(ð	,ñ "Ó#ˆÜ˜b 2 $Ó'ˆÜ�t˜T¨7Ñ3ˆØ×ÑÔØ×Ñ˜Ÿ™ f XÕ.r&   c                ó”   •  " S S5      n[        / U" 5       /5      n[        SSUS9nU R                  UR                  5       S/5        g)zs
The Janitor returns string representations of the selectables that it
cleaned up from the reactor cleanup method.
c                  ó"   • \ rS rSrSrSS jrSrg)ÚJJanitorTests.test_cleanReactorReturnsSelectableStrings.<locals>.Selectablei  zH
A stub Selectable which only has an interesting string
representation.
c                ó   • g)Nú(SELECTABLE!)r7   rh   s    r$   Ú__repr__ÚSJanitorTests.test_cleanReactorReturnsSelectableStrings.<locals>.Selectable.__repr__   s   € Ø&r&   r7   Nr“   )r;   r<   r=   r>   r?   rÃ   r@   r7   r&   r$   Ú
SelectablerÀ     s   † ñ÷
'r&   rÅ   Nr�   rÂ   )rX   r   r    rª   )r!   rÅ   r‚   r…   s       r$   Ú)test_cleanReactorReturnsSelectableStringsÚ6JanitorTests.test_cleanReactorReturnsSelectableStrings  sH   € ÷	'ñ 	'ô ˜b¡:£< .Ó1ˆÜ�t˜T¨7Ñ3ˆØ×Ñ˜×*Ñ*Ó,¨Ð.?Õ@r&   c                óÌ   • [        / 5      n[        5       n[        5       n[        X#US9nU R	                  UR                  5       5        U R                  UR                  / 5        g)zu
The post-case cleanup method will return True and not call C{addError}
on the result if there are no pending calls.
r�   N)rX   r|   rr   r   r,   ÚpostCaseCleanupr    rv   ©r!   r‚   ry   Úreporterr…   s        r$   Útest_postCaseCleanupNoErrorsÚ)JanitorTests.test_postCaseCleanupNoErrors'  sQ   € ô
 ˜b“/ˆÜ‹xˆÜ$Ó&ˆÜ�t¨wÑ7ˆØ�‰˜×+Ñ+Ó-Ô.Ø×Ñ˜Ÿ™¨"Õ-r&   c           
     óŒ  • [        SS S0 S S S S9n[        U5      n[        U// 5      n[        5       n[	        5       n[        XEUS9nU R                  UR                  5       5        U R                  [        UR                  5      S	5        U R                  UR                  S
   S	   R                  R                  U/5        g)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.
r�   c                 ó   • g ro   r7   r7   r&   r$   r‘   Ú=JanitorTests.test_postCaseCleanupWithErrors.<locals>.<lambda>:  r›   r&   r7   c                ó   • g ro   r7   r�   s    r$   r‘   rÐ   :  r�   r&   c                ó   • g ro   r7   r�   s    r$   r‘   rÐ   :  rŸ   r&   c                 ó   • gr¡   r7   r7   r&   r$   r‘   rÐ   :  r¢   r&   r£   r�   rl   r   N)r	   rH   rX   r|   rr   r   r.   rÉ   r    Úlenrv   Úvaluer\   ©r!   r•   r¥   r‚   ry   rË   r…   s          r$   Útest_postCaseCleanupWithErrorsÚ+JanitorTests.test_postCaseCleanupWithErrors3  s±   € ô "Ø‘˜r 2¡~±~Éyñ
ˆô   Ó,ÐÜ˜{˜m¨RÓ0ˆÜ‹xˆÜ$Ó&ˆÜ�t¨wÑ7ˆØ×Ñ˜×,Ñ,Ó.Ô/Ø×Ñœ˜XŸ_™_Ó-¨qÔ1Ø×Ñ˜Ÿ™¨Ñ+¨AÑ.×4Ñ4×AÑAÐDUÐCVÕWr&   c                ó®   • [        / 5      n[        5       n[        5       n[        X#US9nUR	                  5         U R                  UR                  / 5        g)zu
The post-class cleanup method will not call C{addError} on the result
if there are no pending calls or selectables.
r�   N)rX   r|   rr   r   ÚpostClassCleanupr    rv   rÊ   s        r$   Útest_postClassCleanupNoErrorsÚ*JanitorTests.test_postClassCleanupNoErrorsE  sH   € ô
 ˜b“/ˆÜ‹xˆÜ$Ó&ˆÜ�t¨wÑ7ˆØ×ÑÔØ×Ñ˜Ÿ™¨"Õ-r&   c           
     ón  • [        SS S0 S S S S9n[        U5      n[        U// 5      n[        5       n[	        5       n[        XEUS9nUR                  5         U R                  [        UR                  5      S	5        U R                  UR                  S
   S	   R                  R                  U/5        g)z‡
The post-class cleanup method call C{addError} on the result with a
L{DirtyReactorAggregateError} Failure if there are pending calls.
r�   c                 ó   • g ro   r7   r7   r&   r$   r‘   ÚIJanitorTests.test_postClassCleanupWithPendingCallErrors.<locals>.<lambda>W  r›   r&   r7   c                ó   • g ro   r7   r�   s    r$   r‘   rß   W  r�   r&   c                ó   • g ro   r7   r�   s    r$   r‘   rß   W  rŸ   r&   c                 ó   • gr¡   r7   r7   r&   r$   r‘   rß   W  r¢   r&   r£   r�   rl   r   N)r	   rH   rX   r|   rr   r   rÚ   r    rÔ   rv   rÕ   r\   rÖ   s          r$   Ú*test_postClassCleanupWithPendingCallErrorsÚ7JanitorTests.test_postClassCleanupWithPendingCallErrorsQ  s¦   € ô
 "Ø‘˜r 2¡~±~Éyñ
ˆô   Ó,ÐÜ˜{˜m¨RÓ0ˆÜ‹xˆÜ$Ó&ˆÜ�t¨wÑ7ˆØ×ÑÔØ×Ñœ˜XŸ_™_Ó-¨qÔ1Ø×Ñ˜Ÿ™¨Ñ+¨AÑ.×4Ñ4×AÑAÐDUÐCVÕWr&   c                óH  • Sn[        / U/5      n[        5       n[        5       n[        X4US9nUR	                  5         U R                  [        UR                  5      S5        U R                  UR                  S   S   R                  R                  [        U5      /5        g)z…
The post-class cleanup method call C{addError} on the result with a
L{DirtyReactorAggregateError} Failure if there are selectables.
zSELECTABLE HEREr�   rl   r   N)rX   r|   rr   r   rÚ   r    rÔ   rv   rÕ   r_   Úrepr)r!   Ú
selectabler‚   ry   rË   r…   s         r$   Ú)test_postClassCleanupWithSelectableErrorsÚ6JanitorTests.test_postClassCleanupWithSelectableErrorsb  s‰   € ð
 'ˆ
Ü˜b : ,Ó/ˆÜ‹xˆÜ$Ó&ˆÜ�t¨wÑ7ˆØ×ÑÔØ×Ñœ˜XŸ_™_Ó-¨qÔ1Ø×Ñ˜Ÿ™¨Ñ+¨AÑ.×4Ñ4×@Ñ@Ä4È
ÓCSÐBTÕUr&   r7   Nr8   )r;   r<   r=   r>   r?   r†   r–   r§   r«   r¼   rÆ   rÌ   r×   rÛ   rã   rè   r@   r7   r&   r$   r~   r~   ¿   sB   † ñô
5ô3ô7ô"5ô/ô6Aô&
.ôXô$
.ôX÷"Vr&   r~   c                  ó6   • \ rS rSrSrSS jrSS jrSS jrSrg)	ÚRemoveSafelyTestsiq  z"
Tests for L{util._removeSafely}.
c                óø   • U R                  5       R                  S5      n[        R                  " U5        [        R
                  " U5      nU R                  [        R                  [        R                  U5        g)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_removeSafelyNoTrialMarkerÚ0RemoveSafelyTests.test_removeSafelyNoTrialMarkerv  sT   € ð —K‘K“M×(Ñ(¨Ó1ˆ	Ü
�Š�ÔÜ×#Ò# IÓ.ˆØ×Ñœ$×-Ñ-¬t×/AÑ/AÀ7ÕKr&   c                óœ  • SS jn[        5       nU R                  [        SU5        U R                  5       R	                  S5      n[
        R                  " U5        [        R                  " U5      nUR                  S5      R                  5         Xl        [        R                  " U5        U R                  SUR                  5       5        g)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.
c                 ó   • [        5       e)úa
Raise an C{OSError} to emulate the branch of L{util._removeSafely}
in which path removal fails.
©ÚOSErrorr7   r&   r$   ÚdummyRemoveÚORemoveSafelyTests.test_removeSafelyRemoveFailsMoveSucceeds.<locals>.dummyRemoveˆ  s   € ô
 “)ˆOr&   Ústdoutrí   ó   _trial_markerúcould not remove FilePathNr8   )r   ÚpatchÚsysr   rî   r   rï   r   rð   ÚchildÚtouchÚremover   ró   ÚassertInÚgetvalue)r!   rý   Úoutrô   rõ   s        r$   Ú(test_removeSafelyRemoveFailsMoveSucceedsÚ:RemoveSafelyTests.test_removeSafelyRemoveFailsMoveSucceeds�  s’   € ô	ô ‹jˆØ�
‰
”3˜ #Ô&ð —K‘K“M×(Ñ(¨Ó1ˆ	Ü
�Š�ÔÜ×#Ò# IÓ.ˆØ�‰Ð&Ó'×-Ñ-Ô/à$Œä×Ò˜7Ô#Ø�‰Ð1°3·<±<³>ÕBr&   c                ó
  • S	S jnS
SS jjn[        5       nU R                  [        SU5        U R                  5       R	                  S5      n[
        R                  " U5        [        R                  " U5      nUR                  S5      R                  5         Xl        X%l        U R                  [        [        R                   U5      nU R#                  [%        U5      S5        U R'                  SUR)                  5       5        g)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.
c                 ó   • [        S5      e)rú   zpath removal failedrû   r7   r&   r$   rý   ÚLRemoveSafelyTests.test_removeSafelyRemoveFailsMoveFails.<locals>.dummyRemove¥  s   € ô
 Ð/Ó0Ð0r&   c                ó   • [        S5      e)zb
Raise an C{OSError} to emulate the branch of L{util._removeSafely}
in which path movement fails.
úpath movement failedrû   )ÚdestinationÚfollowLinkss     r$   ÚdummyMoveToÚLRemoveSafelyTests.test_removeSafelyRemoveFailsMoveFails.<locals>.dummyMoveTo¬  s   € ô
 Ð0Ó1Ð1r&   rÿ   rí   r   r  r  Nr8   )T)r  r|   r  Úboolr9   r:   )r   r  r  r   rî   r   rï   r   rð   r  r  r  ÚmoveTorñ   rü   r   ró   r    rH   r  r  )r!   rý   r  r	  rô   rõ   rJ   s          r$   Ú%test_removeSafelyRemoveFailsMoveFailsÚ7RemoveSafelyTests.test_removeSafelyRemoveFailsMoveFailsž  s¿   € ô	1ö	2ô ‹jˆØ�
‰
”3˜ #Ô&ð —K‘K“M×(Ñ(¨Ó1ˆ	Ü
�Š�ÔÜ×#Ò# IÓ.ˆØ�‰Ð&Ó'×-Ñ-Ô/ð %ŒØ$Œà×!Ñ!¤'¬4×+=Ñ+=¸wÓGˆØ×Ñœ˜U›Ð%;Ô<Ø�‰Ð1°3·<±<³>ÕBr&   r7   Nr8   )	r;   r<   r=   r>   r?   rö   r
  r  r@   r7   r&   r$   rë   rë   q  s   † ñô	LôC÷:%Cr&   rë   c                  ó,   • \ rS rSrSrSS jrSS jrSrg)ÚExcInfoTestsiÆ  z)
Tests for L{excInfoOrFailureToExcInfo}.
c                ó`   • [         [        S5      S4nU R                  U[        U5      L 5        g)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_excInfoÚExcInfoTests.test_excInfoË  s,   € ô
 œJ uÓ-¨tÐ4ˆØ�‰˜Ô 9¸$Ó ?Ð?Õ@r&   c                ó¼   •  SS-    U R                  WR                  UR                  UR
                  4[        U5      5        g! [          a    [        5       n NSf = f)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.
rl   r   N)ÚBaseExceptionr   r    ÚtyperÕ   Útbr   )r!   Úfs     r$   Útest_failureÚExcInfoTests.test_failureÓ  sQ   € ð	Ø�ŠEð 	×Ñ˜!Ÿ&™& !§'¡'¨1¯4©4Ð0Ô2KÈAÓ2NÕOøô ó 	Ü“	ŠAð	ús   ‚A ÁAÁAr7   Nr8   )r;   r<   r=   r>   r?   r  r&  r@   r7   r&   r$   r  r  Æ  s   † ñôA÷
Pr&   r  c                  ó@   • \ rS rSrSrS	S jrS	S jrS	S jrS	S jrSr	g)
ÚAcquireAttributeTestsià  z 
Tests for L{acquireAttribute}.
c                ót   • [        5       =U l        nU R                  U[        U [        5       /S5      L 5        g)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©r|   rÕ   r,   r   ©r!   rÕ   s     r$   Útest_foundOnEarlierObjectÚ/AcquireAttributeTests.test_foundOnEarlierObjectå  s2   € ô $›XÐ%ˆŒ
�UØ�‰˜Ô!1°4¼»Ð2BÀGÓ!LÐLÕMr&   c                ót   • [        5       =U l        nU R                  U[        [        5       U /S5      L 5        g)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_foundOnLaterObjectÚ-AcquireAttributeTests.test_foundOnLaterObjectî  s2   € ô
 $›XÐ%ˆŒ
�UØ�‰˜Ô!1´6³8¸TÐ2BÀGÓ!LÐLÕMr&   c                óN   • U R                  [        [        [        5       /S5        g)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   r|   rh   s    r$   Útest_notFoundExceptionÚ,AcquireAttributeTests.test_notFoundExceptionö  s   € ð
 	×Ñœ.Ô*:¼V»X¸JÈÕNr&   c                óf   • [        5       nU R                  U[        [        5       /SU5      L 5        g)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)r|   r,   r   )r!   Údefaults     r$   Útest_notFoundDefaultÚ*AcquireAttributeTests.test_notFoundDefaultý  s*   € ô “(ˆØ�‰˜Ô#3´V³X°JÀÀwÓ#OÐOÕPr&   )rÕ   Nr8   )
r;   r<   r=   r>   r?   r-  r0  r4  r8  r@   r7   r&   r$   r)  r)  à  s   † ñôNôNôO÷Qr&   r)  c                  ór   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS jr
SS	 jrSS
 jrSS jrSrg)ÚListToPhraseTestsi  z¶
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.
c                ó\   • / nSn[         R                  " US5      nU R                  X#5        g)z2
If things is empty, an empty string is returned.
Ú ÚandN©r   Ú_listToPhraser    ©r!   ÚsampleÚexpectedÚresults       r$   Ú
test_emptyÚListToPhraseTests.test_empty  s.   € ð  ˆØˆÜ×#Ò# F¨EÓ2ˆØ×Ñ˜Õ*r&   c                ó^   • S/nSn[         R                  " US5      nU R                  X#5        g)z+
With a single item, the item is returned.
ÚOner>  Nr?  rA  s       r$   Útest_oneWordÚListToPhraseTests.test_oneWord  s0   € ð �ˆØˆÜ×#Ò# F¨EÓ2ˆØ×Ñ˜Õ*r&   c                ó`   • SS/nSn[         R                  " US5      nU R                  X#5        g)z1
Two words are separated by the final delimiter.
rH  ÚTwozOne and Twor>  Nr?  rA  s       r$   Útest_twoWordsÚListToPhraseTests.test_twoWords   s2   € ð ˜�ˆØ ˆÜ×#Ò# F¨EÓ2ˆØ×Ñ˜Õ*r&   c                ó`   • / SQnSn[         R                  " US5      nU R                  X#5        g)zI
With more than two words, the first two are separated by the delimiter.
)rH  rL  ÚThreezOne, Two, and Threer>  Nr?  rA  s       r$   Útest_threeWordsÚ!ListToPhraseTests.test_threeWords)  s.   € ò )ˆØ(ˆÜ×#Ò# F¨EÓ2ˆØ×Ñ˜Õ*r&   c                ó^   • / SQnSn[         R                  " USSS9nU R                  X#5        g)zG
If a delimiter is specified, it is used instead of the default comma.
)rH  rL  rP  ÚFourzOne; Two; Three; or FourÚorz; )Ú	delimiterNr?  rA  s       r$   Útest_fourWordsÚ ListToPhraseTests.test_fourWords2  s0   € ò 1ˆØ-ˆÜ×#Ò# F¨D¸DÑAˆØ×Ñ˜Õ*r&   c                ó`   • / SQnSn[         R                  " US5      nU R                  X#5        g)zC
If something in things is not a string, it is converted into one.
)rl   é   Úthreez1, 2, and threer>  Nr?  rA  s       r$   Útest_notStringÚ ListToPhraseTests.test_notString;  s.   € ò !ˆØ$ˆÜ×#Ò# F¨EÓ2ˆØ×Ñ˜Õ*r&   c                óŠ   • SnU R                  [        [        R                  US5      nU R	                  [        U5      S5        g)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    rH   ©r!   rB  rJ   s      r$   Útest_stringTypeErrorÚ&ListToPhraseTests.test_stringTypeErrorD  s:   € ð #ˆØ×!Ñ!¤)¬T×-?Ñ-?ÀÈÓOˆØ×Ñœ˜U›Ð%GÕHr&   c                ó    • [        / SQ5      nU R                  [        [        R                  US5      nU R                  [        U5      S5        g)z2
If things is an iterator, a TypeError is raised.
)rl   rZ  é   r>  r_  N)Úiterrñ   ra  r   r@  r    rH   rb  s      r$   Útest_iteratorTypeErrorÚ(ListToPhraseTests.test_iteratorTypeErrorL  s>   € ô ’i“ˆØ×!Ñ!¤)¬T×-?Ñ-?ÀÈÓOˆØ×Ñœ˜U›Ð%GÕHr&   c                ó�   • SS jnU R                  [        [        R                  US5      nU R	                  [        U5      S5        g)z2
If things is a generator, a TypeError is raised.
c               3  ó6   #   • [        S5       S h  v•N   g  N7f)NrZ  )Úranger7   r&   r$   rB  Ú9ListToPhraseTests.test_generatorTypeError.<locals>.sampleY  s   é € Ü˜Q“x×Óùs   ‚‘’r>  r_  N)r9   zGenerator[int, None, None]r`  rb  s      r$   Útest_generatorTypeErrorÚ)ListToPhraseTests.test_generatorTypeErrorT  s:   € ô
	 ð ×!Ñ!¤)¬T×-?Ñ-?ÀÈÓOˆØ×Ñœ˜U›Ð%GÕHr&   r7   Nr8   )r;   r<   r=   r>   r?   rE  rI  rM  rQ  rW  r\  rc  rh  rn  r@   r7   r&   r$   r;  r;    s7   † ñô+ô+ô+ô+ô+ô+ôIôI÷	Ir&   r;  c                  ó,   • \ rS rSrSrSS jrSS jrSrg)ÚOpenTestLogTestsi`  z
Tests for C{openTestLog}.
c                óV  • [         R                  " 5       nU R                  [         R                  [         R                  U5        [         R                  " [         R                  S5        Sn[
        R                  " U R                  5       5      n[        U5       nUR                  U5        SSS5        [        UR                  S5       nUR                  5       nSSS5        [        UR                  S5      [        W5      5        g! , (       d  f       Nb= f! , (       d  f       ND= f)zB
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_utf8ÚOpenTestLogTests.test_utf8e  sÁ   € ô ×(Ò(Ó*ˆØ�‰œ×(Ñ(¬&¯-©-¸ÔGÜ×ÒœŸ™¨Ô7à'ˆÜ×Ò˜dŸk™k›mÓ,ˆÜ˜Œ^˜qØ�G‰G�DŒM÷ ô �!—&‘&˜$Ô 1Ø—f‘f“hˆG÷  ô 	�D—K‘K Ó(¬(°7Ó*;Õ<÷ �^ú÷  Õús   ÂD	ÃDÄ	
DÄ
D(c                óØ  • SnSnS[         R                   S[         R                   3n[        R                  " U R	                  5       5      n[        U5       nUR                  U5        SSS5        [        U5       nUR                  U5        SSS5        [        UR                  5       R                  S5      [        U5      5        g! , (       d  f       Nf= f! , (       d  f       NR= f)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ÚnewTextrC  r€  r%  s         r$   Útest_appendÚOpenTestLogTests.test_append{  s§   € ð
 *ˆØ%ˆØ"¤2§:¡: ,Ð.>¼r¿z¹z¸lÐKˆÜ×Ò˜dŸk™k›mÓ,ˆÜ˜Œ^˜qØ�G‰G�LÔ!÷ ä˜Œ^˜qØ�G‰G�GÔ÷ ô 	Ø�L‰L‹N×!Ñ! 'Ó*Ü�XÓõ	
÷ �^úç�^ús   ÁC
Á=CÃ

CÃ
C)r7   Nr8   )r;   r<   r=   r>   r?   r‚  rŠ  r@   r7   r&   r$   rq  rq  `  s   † ñô=÷,
r&   rq  )+r?   Ú
__future__r   rv  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   rB   rX   rr   r~   rë   r  r)  r;  rq  r7   r&   r$   Ú<module>r˜     sÓ   ðñ
õ #ã Û 	Û 
Ý Ý å &ç *å -Ý 9Ý #Ý *Ý Ý 6÷õ ô&6Ð%ô &6ôR0
Ð&9ô 0
÷f* ñ * ÷Z*ñ *ô&oVÐ&ô oVôdRCÐ+ô RCôjPÐ&ô Pô4$QÐ/ô $QôNVIÐ+ô VIôr,
Ð*õ ,
r&   