ϪfgdZddlZddlZddlmZddlmZddlmZddl m Z m Z ddl m Z Gdd eZGd d e Zy) z Test strerror N)skipIf) ECONNABORTED)platform)_ErrorFormatter formatError)TestCaseceZdZdZy)_MyWindowsExceptionzT An exception type like L{ctypes.WinError}, but available on all platforms. N)__name__ __module__ __qualname____doc__j|jSN)appendr%) errorCode formatCallsrs r formatMessagez=ErrorFormatingTests.test_formatMessage..formatMessageHs   y )$$ $rNr rrrrr%)rr-rrr,s` @rtest_formatMessagez&ErrorFormatingTests.test_formatMessageAst   %$ -$"5"5!G ''(;(;< $"3"34 t':':&;.winErrorZs" OOI &&y$2C2CD Drcy)NzformatMessage: wrong messager)r"s rz3ErrorFormatingTests.test_winError..`srzerrorTab: wrong messageNr.)rr3rrr2s` @r test_winErrorz!ErrorFormatingTests.test_winErrorSs_  E$  8  "; < ''(;(;< $"3"34rwin32zTest will run only on Windows.c&tj}|jRddlm}|j |j |j||jjd|_|jHddl m }|j |j |j||jd|_ |j?ddl m }|j |j |j||jyy)z L{_ErrorFormatter.fromEnvironment} should create an L{_ErrorFormatter} instance with attributes populated from available modules. NrWinError FormatMessage)errorTab)rfromEnvironmentr3ctypesr:rrrrr-win32apir<r=socket)rrr:r<r=s rtest_fromEnvironmentz(ErrorFormatingTests.test_fromEnvironmentfs $335    ) '   %%d&9&9:,,-66 "&I   " " . .   %%d&9&9:d112 '+I #    ) '   %%d&9&9:,,-  *rcJtjtg} ddlm}|j |tj  ddlm }|j |t|jtt|y#t$rYMwxYw#t$rY:wxYw)z Given a known-good errno, make sure that formatMessage gives results matching either C{socket.errorTab}, C{ctypes.WinError}, or C{win32api.FormatMessage}. rr9r;N) rAr=rr?r:r*r ImportErrorr@r<assertInr)r acceptabler:r<s rtest_correctLookupsz'ErrorFormatingTests.test_correctLookupssool34   '   h|4== >  .   mL9 : k,/<       s#+B!B BB B"!B"N)r r r rrrr%rr#r&r/r6rrgetTyperBrGrrrrrs"N*LD D 5=$5& H   ' )+KLMB H   ' )+KL=M=rr)rrrAunittestrtwisted.internet.tcprtwisted.python.runtimertwisted.python.win32rrtwisted.trial.unittestrOSErrorr rrrrrOs; -+=+' E=(E=r