a „oe,#ã@sîddlZddlZddlmZddlmZddlmZddlm Z Gdd„de ƒZ Gdd „d ƒZ d d „Z z ddlZWneyˆdZYn0edur´ddlZGd d „d ejƒZdd„Zedkrêe ƒedurÐeƒddlmZeƒedƒdS)éN)ÚDispatch)Ú COMException)Úwrap)Ú CaptureWriterc@seZdZddd„ZdS)ÚerrorNcCst ||t|ƒ¡dS©N)Ú ExceptionÚ__init__Ústr)ÚselfÚmsgZ com_exception©r ú=C:\Program Files\Certbot\pkgs\win32com\test\errorSemantics.pyr szerror.__init__)N)Ú__name__Ú __module__Ú __qualname__r r r r rrsrc@s,eZdZgd¢ZejgZdd„Zdd„ZdS)Ú TestServer)ÚCloneÚCommitZ LockRegionZReadcCstdtjd�‚dS)Nú Not today)Zscode)rÚwinerrorÚ E_UNEXPECTED©r r r rr szTestServer.ClonecCs:|dkrtdƒ‚tjddddtjf}t tjd|d¡‚dS)Nrõ😀ÚsourceÚhelpfileéZdesc)rrrÚE_FAILÚ pythoncomÚ com_error)r ÚflagsÚ excepinfor r rr#súzTestServer.CommitN) rrrZ_public_methods_rÚ IID_IStreamZ_com_interfaces_rrr r r rrsrc Csättƒtjƒ}z| ¡tdƒ‚Wnttjy–}zZ|jtj krJtd|ƒ‚|j }|rb|dtj krltd|ƒ‚|ddkr‚td|ƒ‚WYd}~n d}~00t ƒ}z6|  ¡z|  d¡W| ¡n | ¡0tdƒ‚WnXtj�y,}z<|jtjkrþtd |ƒ‚|j d d k�rtd|ƒ‚WYd}~n d}~00| ¡ d ¡dk�rTtd | ¡fƒ‚tttƒƒƒ}z| ¡tdƒ‚Wn~tj�yô}zb|jtjk�r¢td|ƒ‚|j }|�r¾|dtj k�rÈtd|ƒ‚|ddk�ràtd|ƒ‚WYd}~n d}~00| ¡z6|  ¡z|  d¡W| ¡n | ¡0tdƒ‚Wn~tj�y²}zb|jtjk�r`td|ƒ‚|j }|�r||dtjk�r†td|ƒ‚|d d k�ržtd|ƒ‚WYd}~n d}~00| ¡ d ¡dk�rÚtd | ¡fƒ‚| ¡z6|  ¡z|  d ¡W| ¡n | ¡0tdƒ‚WnÆtj�yÞ}zª|jtjk�rDtd|ƒ‚|j }|�r`|dtjk�rjtd|ƒ‚|d dk�r‚td|ƒ‚|ddk�rštd|ƒ‚|ddk�r²td|ƒ‚|dd k�rÊtd|ƒ‚WYd}~n d}~00dS)NzExpecting this call to fail!z;Calling the object natively did not yield the correct scodeéÿÿÿÿzHThe scode element of the exception tuple did not yield the correct scodeérzGThe 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 stringrérzDThe helpfile in the exception tuple did not yield the correct stringézHThe help context in the exception tuple did not yield the correct string)rrrr"rrrZhresultrrr!rZcapturerÚreleaserZ get_capturedÚfindrZDISP_E_EXCEPTIONÚclear)Ú com_serverZcom_excÚexcZcapr r rÚtest6sö  ÿþ þ    þ þþþ  þþþ  þþþþþþr,c@s$eZdZdd„Zdd„Zdd„ZdS)ÚTestLogHandlercCs| ¡tj |¡dSr)ÚresetÚloggingÚHandlerr rr r rr ÇszTestLogHandler.__init__cCsd|_d|_dS)Nr)Ú num_emitsÚ last_recordrr r rr.ËszTestLogHandler.resetcCs|jd7_| |¡|_dS)Nrz--- record startz--- record end)r1Úformatr2Úprint)r Úrecordr r rÚemitÏs  zTestLogHandler.emitN)rrrr r.r6r r r rr-Æsr-c Cs\ttdƒrJ‚tƒ}t d¡}| |¡t d¡}| |¡|t_t t ƒt j ƒ}z|  d¡tdƒ‚Wn>t jy¤}z$|jd}| d¡s�J‚WYd}~n d}~00|jdksºJ|jƒ‚|j d ¡sÊJ‚| ¡tt t ƒƒƒ}z|  d¡tdƒ‚WnBt j�y8}z&|jd}| d¡�s$J‚WYd}~n d}~00|jdk�sPJ|jƒ‚| ¡dS) NÚloggerz %(message)sZ win32com_testrzshould have failedr$uException: 😀 rz@pythoncom error: Unexpected exception in gateway method 'Commit')ÚhasattrÚwin32comr-r/Z FormatterZ setFormatterZ getLoggerZ addHandlerr7rrrr"rÚ RuntimeErrorrr!Úendswithr1r2Ú startswithr.r)ZhandlerÚ formatterÚlogr*r+Úmessager r rÚ testLogger×s8       $ÿ   &r@Ú__main__)Ú CheckCleanzerror semantic tests worked)rrZwin32com.clientrZwin32com.server.exceptionrZwin32com.server.utilrZwin32com.test.utilrrrrr,r/Ú ImportErrorr9r0r-r@rrBr4r r r rÚs0        %