a oe,#@sddlZddlZddlmZddlmZddlmZddlm Z Gddde Z Gdd d Z d d Z z ddlZWneydZYn0edurddlZGd d d ejZddZedkre edureddlmZeeddS)N)Dispatch) COMException)wrap) CaptureWriterc@seZdZdddZdS)errorNcCst||t|dSN) Exception__init__str)selfmsgZ com_exceptionr =C:\Program Files\Certbot\pkgs\win32com\test\errorSemantics.pyr szerror.__init__)N)__name__ __module__ __qualname__r r r r rrsrc@s,eZdZgdZejgZddZddZdS) TestServer)CloneCommitZ LockRegionZReadcCstdtjddS)N Not today)Zscode)rwinerror E_UNEXPECTEDr r r rr szTestServer.ClonecCs:|dkrtdtjddddtjf}ttjd|ddS)Nr😀sourcehelpfileZdesc)rrrE_FAIL pythoncom com_error)r flags excepinfor r rr#szTestServer.CommitN) rrrZ_public_methods_r IID_IStreamZ_com_interfaces_rrr r r rrsrc Cstttj}z|tdWnttjy}zZ|jtj krJtd||j }|rb|dtj krltd||ddkrtd|WYd}~n d}~00t }z6| z| dW|n |0tdWnXtjy,}z<|jtjkrtd ||j d d krtd|WYd}~n d}~00|d dkrTtd |fttt}z|tdWn~tjy}zb|jtjkrtd||j }|r|dtj krtd||ddkrtd|WYd}~n d}~00|z6| z| dW|n |0tdWn~tjy}zb|jtjkr`td||j }|r||dtjkrtd||d d krtd|WYd}~n d}~00|d dkrtd |f|z6| z| d W|n |0tdWntjy}z|jtjkrDtd||j }|r`|dtjkrjtd||d dkrtd||ddkrtd||ddkrtd||dd krtd|WYd}~n d}~00dS)NzExpecting this call to fail!z;Calling the object natively did not yield the correct scodezHThe scode element of the exception tuple did not yield the correct scoderzGThe description in the exception tuple did not yield the correct stringrz0The hresult was not E_FAIL for an internal errorrz Python COM Server Internal ErrorZ Tracebackz(Could not find a traceback in stderr: %rz@Calling the object via IDispatch did not yield the correct scoderzBThe source in the exception tuple did not yield the correct stringrrzDThe helpfile in the exception tuple did not yield the correct stringzHThe help context in the exception tuple did not yield the correct string)rrrr"rrrZhresultrrr!rZcapturerreleaserZ get_capturedfindrZDISP_E_EXCEPTIONclear) com_serverZcom_excexcZcapr r rtest6s            r,c@s$eZdZddZddZddZdS)TestLogHandlercCs|tj|dSr)resetloggingHandlerr rr r rr szTestLogHandler.__init__cCsd|_d|_dS)Nr) num_emits last_recordrr r rr.szTestLogHandler.resetcCs|jd7_|||_dS)Nrz--- record startz--- record end)r1formatr2print)r recordr r remits  zTestLogHandler.emitN)rrrr r.r6r r r rr-sr-c Cs\ttdrJt}td}||td}|||t_t t t j }z| dtdWn>t jy}z$|jd}|dsJWYd}~n d}~00|jdksJ|j|jd sJ|tt t }z| dtdWnBt jy8}z&|jd}|ds$JWYd}~n d}~00|jdksPJ|j|dS) Nloggerz %(message)sZ win32com_testrzshould have failedr$uException: 😀 rz@pythoncom error: Unexpected exception in gateway method 'Commit')hasattrwin32comr-r/Z FormatterZ setFormatterZ getLoggerZ addHandlerr7rrrr"r RuntimeErrorrr!endswithr1r2 startswithr.r)Zhandler formatterlogr*r+messager r r testLoggers8       $   &r@__main__) CheckCleanzerror semantic tests worked)rrZwin32com.clientrZwin32com.server.exceptionrZwin32com.server.utilrZwin32com.test.utilrrrrr,r/ ImportErrorr9r0r-r@rrBr4r r r rs0        %