+
    Dfjg                         R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
Ht ^ RIHt  ! R R]4      t ! R	 R
]4      tR# )z
Test strerror
N)skipIf)ECONNABORTED)platform)_ErrorFormatterformatError)TestCasec                       ] tR t^tRtRtR# )_MyWindowsExceptionzL
An exception type like L{ctypes.WinError}, but available on all platforms.
 N)__name__
__module____qualname____firstlineno____doc____static_attributes__r
       </usr/lib/python3/dist-packages/twisted/test/test_strerror.pyr	   r	      s    r   r	   c                      a  ] tR t^t o Rt]tRtR tR t	R t
R tR t]! ]P                  ! 4       R8g  R	4      R
 4       t]! ]P                  ! 4       R8g  R	4      R 4       tRtV tR# )ErrorFormatingTestsz+
Tests for C{_ErrorFormatter.formatError}.
zcorrect message valuec                    \        RRR4      pVP                  V P                  4      pV P                  V\        P
                  ! V P                  4      4       R# )z
L{_ErrorFormatter.formatError} should use L{os.strerror} to format
error messages if it is constructed without any better mechanism.
N)r   r   probeErrorCodeassertEqualosstrerrorself	formattermessages   &  r   test_strerrorFormatting+ErrorFormatingTests.test_strerrorFormatting    sG    
 $D$5	''(;(;<"++d.A.A"BCr   c                    ^pV P                  V P                  V4       \        RRVR/4      pVP                  V P                  4      pV P	                  V\
        P                  ! V P                  4      4       R# )z
L{_ErrorFormatter.formatError} should use L{os.strerror} to format
error messages if it is constructed with only an error tab which does
not contain the error code it is called with.
Nwrong message)assertNotEqualr   r   r   r   r   r   )r   errorr   r   s   &   r   test_emptyErrorTab&ErrorFormatingTests.test_emptyErrorTab)   sg     D//7#D$0HI	''(;(;<"++d.A.A"BCr   c                    \        RRV P                  V P                  /4      pVP                  V P                  4      pV P	                  W P                  4       R# )zp
L{_ErrorFormatter.formatError} should use C{errorTab} if it is supplied
and contains the requested error code.
N)r   r   probeMessager   r   r   s   &  r   test_errorTab!ErrorFormatingTests.test_errorTab6   sR    
 $$,,d.?.?@
	 ''(;(;<"3"34r   c                   a a . oVV 3R lp\        RVS P                  R/4      pVP                  S P                  4      pS P                  VS P                  4       S P                  SS P                  .4       R# )zf
L{_ErrorFormatter.formatError} should return the return value of
C{formatMessage} if it is supplied.
c                 >   < SP                  V 4       SP                  # N)appendr'   )	errorCodeformatCallsr   s   &r   formatMessage=ErrorFormatingTests.test_formatMessage.<locals>.formatMessageH   s    y)$$$r   Nr!   r   r   r   r   r'   )r   r0   r   r   r/   s   f   @r   test_formatMessage&ErrorFormatingTests.test_formatMessageA   st    
 	% $-$"5"5!G
	 ''(;(;<$"3"34t':':&;<r   c                   a a . oV V3R lp\        VR S P                  R/4      pVP                  S P                  4      pS P                  VS P                  4       R# )z
L{_ErrorFormatter.formatError} should return the message argument from
the exception L{winError} returns, if L{winError} is supplied.
c                 R   < SP                  V 4       \        V SP                  4      # r,   )r-   r	   r'   )r.   r   winCallss   &r   winError3ErrorFormatingTests.test_winError.<locals>.winErrorZ   s"    OOI&&y$2C2CDDr   c                     R # )zformatMessage: wrong messager
   )r#   s   &r   <lambda>3ErrorFormatingTests.test_winError.<locals>.<lambda>`   s    8r   zerrorTab: wrong messageNr2   )r   r8   r   r   r7   s   f   @r   test_winError!ErrorFormatingTests.test_winErrorS   s_    
 	E $8  ";<
	
 ''(;(;<$"3"34r   win32zTest will run only on Windows.c                >   \         P                  ! 4       pVP                  eS   ^ RIHp V P                  VP                  V P                  4      V! V P                  4      P                  4       RVn        VP                  eI   ^ RI
Hp V P                  VP                  V P                  4      V! V P                  4      4       RVn	        VP                  eD   ^ RIHp V P                  VP                  V P                  4      W@P                  ,          4       R# R# )z
L{_ErrorFormatter.fromEnvironment} should create an L{_ErrorFormatter}
instance with attributes populated from available modules.
NWinErrorFormatMessage)errorTab)r   fromEnvironmentr8   ctypesrB   r   r   r   r   r0   win32apirD   rE   socket)r   r   rB   rD   rE   s   &    r   test_fromEnvironment(ErrorFormatingTests.test_fromEnvironmentf   s     $335	)'%%d&9&9:,,-66 "&I""..%%d&9&9:d112 '+I#)'%%d&9&9:,,- *r   c                \   \         P                  \        ,          .p ^ RIHp VP                  V! \        4      P                  4        ^ RIH	p VP                  V! \        4      4       V P                  \        \        4      V4       R#   \         d     LPi ; i  \         d     L?i ; i)z
Given a known-good errno, make sure that formatMessage gives results
matching either C{socket.errorTab}, C{ctypes.WinError}, or
C{win32api.FormatMessage}.
rA   rC   N)rI   rE   r   rG   rB   r-   r   ImportErrorrH   rD   assertInr   )r   
acceptablerB   rD   s   &   r   test_correctLookups'ErrorFormatingTests.test_correctLookups   s     ool34
	'h|4==>	.mL9: 	k,/<  		  		s#   +B 
!B BBB+*B+r
   N)r   r   r   r   r   r   r   r'   r   r$   r(   r3   r=   r   r   getTyperJ   rP   r   __classdictcell__)__classdict__s   @r   r   r      s      "N*LDD	5=$5& H')+KL MB H')+KL= M=r   r   )r   r   rI   unittestr   twisted.internet.tcpr   twisted.python.runtimer   twisted.python.win32r   r   twisted.trial.unittestr   OSErrorr	   r   r
   r   r   <module>r[      s;    
   - + = +' E=( E=r   