
    %
i?"                     6   d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	  G d d          Z
d Z	 d dlZn# e$ r dZY nw xY wed dlZ G d	 d
ej                  Zd Zedk    r3 e             e
 e             d dlmZ  e              ed           dS dS )    N)Dispatch)COMException)wrap)CaptureWriterc                   2    e Zd Zg dZej        gZd Zd ZdS )
TestServer)CloneCommit
LockRegionReadc                 8    t          dt          j                  )N	Not today)scode)r   winerrorE_UNEXPECTEDselfs    C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\win32com/test/errorSemantics.pyr	   zTestServer.Clone   s    ;h.CDDDD    c                     |dk    rt          d          t          j        ddddt          j        f}t	          j        t          j        d|d           )Nr      😀sourcehelpfile   desc)	Exceptionr   r   E_FAIL	pythoncom	com_error)r   flags	excepinfos      r   r
   zTestServer.Commit   sX     A::/000 !O
	 !("7DQQQr   N)	__name__
__module____qualname___public_methods_r   IID_IStream_com_interfaces_r	   r
    r   r   r   r      sR        @@@!-.E E ER R R R Rr   r   c                  4   t          t                      t          j                  } 	 |                                  t          d          # t          j        $ r}|j        t          j	        k    sJ dt          |          f            |j        }|r|d         t          j	        k    sJ dt          |          f            |d         dk    sJ dt          |          f            Y d }~nd }~ww xY wt                      }	 |                                 	 |                     d           |                                 n# |                                 w xY wt          d          # t          j        $ rb}|j        t          j        k    sJ d	t          |          f            |j        d
         dk    sJ dt          |          f            Y d }~nd }~ww xY w|                                                    d          dk    sJ d|                                            t'          t          t                                          } 	 |                                  t          d          # t          j        $ r}|j        t          j        k    sJ dt          |          f            |j        }|r|d         t          j	        k    sJ dt          |          f            |d         dk    sJ dt          |          f            Y d }~nd }~ww xY w|                                 	 |                                 	 |                     d           |                                 n# |                                 w xY wt          d          # t          j        $ r}|j        t          j        k    sJ dt          |          f            |j        }|r|d         t          j        k    sJ dt          |          f            |d
         dk    sJ dt          |          f            Y d }~nd }~ww xY w|                                                    d          dk    sJ d|                                            |                                 	 |                                 	 |                     d
           |                                 n# |                                 w xY wt          d          # t          j        $ r}|j        t          j        k    sJ dt          |          f            |j        }|r|d         t          j        k    sJ dt          |          f            |d
         dk    sJ dt          |          f            |d         dk    sJ dt          |          f            |d         dk    sJ dt          |          f            |d         d
k    sJ dt          |          f            Y d }~d S d }~ww xY w)NzExpecting 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 scode   r   zGThe description in the exception tuple did not yield the correct stringr   z0The hresult was not E_FAIL for an internal errorr   z Python COM Server Internal Error	Tracebackz&Could not find a traceback in stderr: z@Calling the object via IDispatch did not yield the correct scoder   zBThe source in the exception tuple did not yield the correct stringr      r   zDThe helpfile in the exception tuple did not yield the correct string   zHThe help context in the exception tuple did not yield the correct string)r   r   r   r&   r	   AssertionErrorr   hresultr   r   strr!   r   capturer
   releaser   get_capturedfindr   DISP_E_EXCEPTIONclear)
com_servercom_excexccaps       r   testr<   1   s   jllI$9::J
;<<< 
 
 
("7777ILL:
777  	
s2w("7777VLL:
777 1v$$$ULL'
$$$$$$$$
 //C
	a   KKMMMMCKKMMMM;<<< 
 
 
(/111>LL4
111  #'IIIIULLL
IIIIIIII
 "";//1444G1A1A1C1CGG 544
 $z||,,--J
;<<< 
 
 
(";;;;NLL>
;;;  	
s2w("7777VLL:
777 1v$$$ULL'
$$$$$$$$
 IIKKK
	a   KKMMMMCKKMMMM;<<< 
 
 
(";;;;NLL>
;;;  	
s2w(/111VLL4
111 1v;;;;ULL>
;;;;;;;;
 "";//1444G1A1A1C1CGG 544
 IIKKK 
	a   KKMMMMCKKMMMM;<<< 
 
 
(";;;;NLL>
;;;  	
s2w(/111VLL4
111 1v!!!PLL$
!!! 1v%%%ULL(
%%% 1v###RLL&
### 1v{{{VLL
{{{{{{{{{-
s   #A C/BC**C/E( E  +E(  EE( (G7AGG#I2 2LBLL.N M- N -NN P9$BP44P9T 0S T S00T XC:XXc                        e Zd Zd Zd Zd ZdS )TestLogHandlerc                 l    |                                   t          j                            |            d S )N)resetloggingHandler__init__r   s    r   rC   zTestLogHandler.__init__   s+    JJLLLO$$T*****r   c                 "    d| _         d | _        d S )Nr   )	num_emitslast_recordr   s    r   r@   zTestLogHandler.reset   s    DN#Dr   c                 Z    | xj         dz  c_         |                     |          | _        d S )Nr   )rE   formatrF   print)r   records     r   emitzTestLogHandler.emit   s+    NNaNN#{{622DFr   N)r"   r#   r$   rC   r@   rK   r(   r   r   r>   r>      sA        	+ 	+ 	+	$ 	$ 	$	$ 	$ 	$ 	$ 	$r   r>   c                  ,   t          t          d          rJ t                      } t          j        d          }|                     |           t          j        d          }|                    |            |t          _        t          t                      t          j                  }	 |                    d           t          d          # t          j        $ r.}|j        d         }|                    d          sJ Y d }~nd }~ww xY w| j        dk    sJ | j                    | j                            d	          sJ |                                  t-          t          t                                          }	 |                    d           t          d          # t          j        $ r.}|j        d         }|                    d          sJ Y d }~nd }~ww xY w| j        dk    sJ | j                    |                                  d S )
Nloggerz%(message)swin32com_testr   zshould have failedr+   u   Exception: 😀
r   z@pythoncom error: Unexpected exception in gateway method 'Commit')hasattrwin32comr>   rA   	FormattersetFormatter	getLogger
addHandlerrM   r   r   r   r&   r
   r/   errorr!   endswithrE   rF   
startswithr@   r   )handler	formatterlogr8   r:   messages         r   
testLoggerr\      s+   8X..... ""%m44	Y'''00w *,,	(=>>
	?a    !5666 	? 	? 	?mA&G##$=>>>>>>>>>>	?  A%%%w'8%%%"--N
 
 	
 	
 
 	 d:<<0011
	?a    !5666 	? 	? 	?mA&G##$=>>>>>>>>>>	?  A%%%w'8%%%s0   +$C D$DD$F& &G#5$GG#__main__)
CheckCleanzerror semantic tests worked)r   r   win32com.clientr   win32com.server.exceptionr   win32com.server.utilr   win32com.test.utilr   r   r<   rA   ImportErrorrP   rB   r>   r\   r"   r^   rI   r(   r   r   <module>rd      s        $ $ $ $ $ $ 2 2 2 2 2 2 % % % % % % , , , , , ,R R R R R R R R4{
 {
 {
|NNNN   GGG
OOO$ $ $ $ $ $ $ $"" " "J zDFFF
------JLLL	E
'((((( s   7 A A