Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/test/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pyc

ó
[³XMc@s~dZddlZddlZddlmZddlmZddlmZm	Z	ddl
mZdefd„ƒYZdS(	s
Test strerror
iÿÿÿÿN(tTestCase(tECONNABORTED(t_ErrorFormattertformatError(tplatformtErrorFormatingTestCasecBs•eZdZeZdZd„Zd„Zd„Zd„Z	d„Z
d„Zej
ƒdkrld	e_nd
„Zej
ƒdkr“d	e_nRS(s3
    Tests for C{_ErrorFormatter.formatError}.
    scorrect message valuecCsDtdddƒ}|j|jƒ}|j|tj|jƒƒdS(sž
        L{_ErrorFormatter.formatError} should use L{os.strerror} to format
        error messages if it is constructed without any better mechanism.
        N(RtNoneRtprobeErrorCodetassertEqualtoststrerror(tselft	formattertmessage((s>/usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pyttest_strerrorFormattingscCsdd}|j|j|ƒtddid|6ƒ}|j|jƒ}|j|tj|jƒƒdS(sØ
        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.
        is
wrong messageN(tassertNotEqualRRRRRR	R
(RterrorRR
((s>/usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pyttest_emptyErrorTab#s
cCsHtddi|j|j6ƒ}|j|jƒ}|j||jƒdS(sˆ
        L{_ErrorFormatter.formatError} should use C{errorTab} if it is supplied
        and contains the requested error code.
        N(RRtprobeMessageRRR(RRR
((s>/usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pyt
test_errorTab1scssg‰‡‡fd†}td|idˆj6ƒ}|jˆjƒ}ˆj|ˆjƒˆjˆˆjgƒdS(s~
        L{_ErrorFormatter.formatError} should return the return value of
        C{formatMessage} if it is supplied.
        csˆj|ƒˆjS(N(tappendR(t	errorCode(RtformatCalls(s>/usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pyt
formatMessageBs
s
wrong messageN(RRRRRR(RRRR
((RRs>/usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pyttest_formatMessage<scs`g‰‡‡fd†}t|d„idˆj6ƒ}|jˆjƒ}ˆj|ˆjƒdS(sŸ
        L{_ErrorFormatter.formatError} should return the message argument from
        the exception L{winError} returns, if L{winError} is supplied.
        csˆj|ƒ|ˆjfS(N(RR(R(twinCallsR(s>/usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pytwinErrorRs
cSsdS(NsformatMessage: wrong message((R((s>/usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pyt<lambda>WsserrorTab: wrong messageN(RRRRR(RRRR
((RRs>/usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pyt
test_winErrorLscCsùtjƒ}|jdk	r`ddlm}|j|j|jƒ||jƒdƒd|_n|j	dk	r°ddl
m}|j|j|jƒ||jƒƒd|_	n|jdk	rõddl
m}|j|j|jƒ||jƒndS(s›
        L{_ErrorFormatter.fromEnvironment} should create an L{_ErrorFormatter}
        instance with attributes populated from available modules.
        iÿÿÿÿ(tWinErrori(t
FormatMessage(terrorTabN(RtfromEnvironmentRRtctypesRRRRRtwin32apiRRtsocket(RRRRR((s>/usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pyttest_fromEnvironment]s$twin32s'This error lookup only works on WindowscCs¤tjtg}y+ddlm}|j|tƒdƒWntk
rNnXy'ddlm}|j|tƒƒWntk
r‰nX|j	t
tƒ|ƒdS(s½
        Given an known-good errno, make sure that formatMessage gives results
        matching either C{socket.errorTab}, C{ctypes.WinError}, or
        C{win32api.FormatMessage}.
        iÿÿÿÿ(Ri(RN(R#RRR!RRtImportErrorR"RtassertInR(Rt
acceptableRR((s>/usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pyttest_correctLookups|s

(t__name__t
__module__t__doc__RRRRRRRRR$RtgetTypetskipR)(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pyRs	
						(
R,R#R	ttwisted.trial.unittestRttwisted.internet.tcpRttwisted.python.win32RRttwisted.python.runtimeRR(((s>/usr/lib/python2.7/dist-packages/twisted/test/test_strerror.pyt<module>s