
    ;e                         d dl Z d dlZd dlZd dlmZ  G d de j                  Z G d de j                  Ze	dk    r e j
                     dS dS )    N)systemc                   D    e Zd Z	 d Zd Zd ZdZd Zd Zd Z	d Z
d	 Zd
S )ExceptionClassTestsc                 `    |                      t          t          t                               d S N)
assertTrue
issubclass	Exceptionobjectselfs    ./usr/lib/python3.11/test/test_baseexception.pytest_builtins_new_stylez+ExceptionClassTests.test_builtins_new_style   s$    
9f5566666    c                 x    dD ]6}|                      t          ||          |j        j        d|d           7d S )N)args__str____repr__z	 missing z
 attribute)r   hasattr	__class____name__)r   insattrs      r   verify_instance_interfacez-ExceptionClassTests.verify_instance_interface   s[    3 	8 	8DOOGC..///78 8 8 8	8 	8r   c                 t   t                      }t          j                                        D ]B}	 t	          |t
                    r|                    |j                   3# t          $ r Y ?w xY wt          t          j                            t          j                            t                    d         d          d          }	 |                                                                }	 t#          t          |          }n(# t$          $ r |                     d|z             Y nw xY w|                     ||d|z             |                    |           g }d}|D ]}|                                }|                    d          }	||	dz   d          }
d	|
v rW|
                    d	          }|
|d
z   d         }|
d |d
z
           }
t1                      |k    r|                    |
           d|
v r"|
                    d          }|
d |d
z
           }
	 t#          t          |
          }n(# t$          $ r |                     d|
z             Y nw xY w||	k     r|                    ||f           n>||	k    r8|d         d         |	k    r&|                                 |d         d         |	k    &|                     t	          ||d         d
                   |j        d|d         d
         j                   	 |                      |                       n# t          $ r Y nw xY w|                     |
|           |                    |
           |}|	} 	 |                                 n# |                                 w xY w|                     t?          |          dd|z             d S )Nr   zexception_hierarchy.txtzutf-8)encodingzbase class %s not a built-inz%s not foundu   ─   (   [z%s not a built-in exceptionz is not a subclass of z%s not accounted for) setbuiltins__dict__valuesr	   BaseExceptionaddr   	TypeErroropenospathjoinsplit__file__readlinerstripgetattrAttributeErrorfailassertIndiscardrindexindexplatform_systemappendpopr   r   closeassertEquallen)r   exc_setobject_inheritance_treesuperclass_namelast_excsuperclasses
last_depthexc_linedepthexc_nameparen_indexplatform_nameleft_bracketexcs                  r   test_inheritancez$ExceptionClassTests.test_inheritance   s#   %%(//11 	 	Gg}55 2KK 0111     RW]]844Q79RSS " " ".	%.7799@@BBOL"8_==! L L L		8?JKKKKKLMM/7(?:< < <OOO,,,LJ, !# !##??,, ..#E!GHH-(??"*.."5"5K$,[]2-=$>M'Q7H&((M99111 (??#+>>##6#6L'a8HH!(H55CC% H H HII;hFGGGGGH%% ''X(>????%''&r*1-66$((*** 'r*1-66
3R0@0C D D03 $Q'0023 3 32233559999    Dh000)))"

C!#F ""$$$$""$$$$Wq*@7*JKKKKKs   /A  
A-,A-&M8 /D M8 "D*'M8 )D**C2M8 H32M8 3"IM8 IB*M8 L! M8 !
L.+M8 -L..4M8 8N)lengthr   strreprc           
          t          | j        |          D ]'\  }\  }}|                     |||d|d|           (d S )Nz: z != )zipinterface_testsr<   )r   results	test_namegivenexpecteds        r   interface_test_driverz)ExceptionClassTests.interface_test_driverU   si    ,/0Dg,N,N 	" 	"(I(xUH			xx/! " " " "	" 	"r   c                    d}t          |          }t          |j                  dg|j        d         |gt          |          t          |          gt	          |          |j        j        d|dgf}|                     |           d S )Nspamr   r   r   ))r
   r=   r   rN   rO   r   r   rW   )r   argrK   rS   s       r   test_interface_single_argz-ExceptionClassTests.test_interface_single_argZ   s    nnMM1%S'9HHc#hh'#YYCM$:$:$:CCC@AC 	""7+++++r   c                 T   d}t          t          |                    }t          | }t          |j                  |g|j        |gt          |          t          |          gt          |          |j        j        t          |j                  z   gf}| 	                    |           d S )N   )
tupleranger
   r=   r   rN   rO   r   r   rW   )r   	arg_countr   rK   rS   s        r   test_interface_multi_argz,ExceptionClassTests.test_interface_multi_argc   s    	U9%%&&MM9-$/?S3t99%cCM2T#(^^CDF 	""7+++++r   c                     t                      }t          |j                  dg|j        t                      gt	          |          dgt          |          |j        j        dz   gf}|                     |           d S )Nr    z())	r
   r=   r   r_   rN   rO   r   r   rW   )r   rK   rS   s      r   test_interface_no_argz)ExceptionClassTests.test_interface_no_argm   sp    kkMM1%%''':S2cCM2T9:< 	""7+++++r   c                     dd l }i  G fddt                    } G d dt                    }t                      } |             |            <   |                               |                                 d S )Nr   c                   (     e Zd Zdef fdZ xZS )XExceptionClassTests.test_setstate_refcount_no_crash.<locals>.HashThisKeyWillClearTheDictreturnc                 l                                      t                                                      S r   )clearsuper__hash__)r   r   ds    r   rm   zaExceptionClassTests.test_setstate_refcount_no_crash.<locals>.HashThisKeyWillClearTheDict.__hash__{   s&    			ww'')))r   )r   
__module____qualname__intrm   __classcell__)r   rn   s   @r   HashThisKeyWillClearTheDictrh   z   sJ        *# * * * * * * * * * * *r   rs   c                       e Zd ZdS )BExceptionClassTests.test_setstate_refcount_no_crash.<locals>.ValueNr   ro   rp    r   r   Valueru   ~           Dr   rx   )gcrN   r
   __setstate__collect)r   rz   rs   rx   rK   rn   s        @r   test_setstate_refcount_no_crashz3ExceptionClassTests.test_setstate_refcount_no_crashu   s     					* 	* 	* 	* 	* 	* 	*# 	* 	* 	*	 	 	 	 	C 	 	 	kk+0577
%
%
'
'( 	 	

r   N)r   ro   rp   r   r   rL   rR   rW   r\   rb   re   r}   rw   r   r   r   r      s        7 7 78 8 8<L <L <L| 8O" " "
, , ,, , ,, , ,    r   r   c                   :    e Zd Z	 d Zd Zd Zd Zd Zd Zd Z	dS )	
UsageTestsc                 ,    	 	 |# t           $ r Y d S w xY wr   )r(   r3   typer   r?   s     r   raise_failszUsageTests.raise_fails   s1    D	M 	 	 	FF	s    
c                 ^   	 	 	 t           # |$ r Y nw xY wn@# t          $ r Y n4t           $ r( |                     dt          |          z             Y nw xY w	 	 t           # |f$ r Y d S w xY w# t          $ r Y d S t           $ r) |                     dt          |          z             Y d S w xY w)Nz#TypeError expected when catching %sz;TypeError expected when catching %s as specified in a tuple)r
   r(   r3   r   r   s     r   catch_failszUsageTests.catch_fails   s1   :	M    	 	 	D 	M 	M 	MII;d7mmKLLLLL	M		1:    	 	 	FF 	1 	1 	1II  "&w--0 1 1 1 1 1 1	1sT      
A.AAA   A*&A- )A**A- -
B,:.B,+B,c                      G d dt                     }|                     |           |                      |                       d S )Nc                       e Zd ZdS )DUsageTests.test_raise_new_style_non_exception.<locals>.NewStyleClassNrv   rw   r   r   NewStyleClassr      ry   r   r   )r   r   )r   r   s     r   "test_raise_new_style_non_exceptionz-UsageTests.test_raise_new_style_non_exception   s`    
	 	 	 	 	F 	 	 	''')))))r   c                 0    |                      d           d S NrY   )r   r   s    r   test_raise_stringzUsageTests.test_raise_string            r   c                      G d dt                     }|                     |           |                      |                       d S )Nc                       e Zd ZdS )AUsageTests.test_catch_non_BaseException.<locals>.NonBaseExceptionNrv   rw   r   r   NonBaseExceptionr      ry   r   r   )r   r   )r   r   s     r   test_catch_non_BaseExceptionz'UsageTests.test_catch_non_BaseException   se    	 	 	 	 	v 	 	 	)***))++,,,,,r   c                 H    |                      t                                 d S r   )r   r&   r   s    r   !test_catch_BaseException_instancez,UsageTests.test_catch_BaseException_instance   s     )))))r   c                 0    |                      d           d S r   )r   r   s    r   test_catch_stringzUsageTests.test_catch_string   r   r   N)
r   ro   rp   r   r   r   r   r   r   r   rw   r   r   r   r      s        "G G G1 1 1.* * *! ! !- - -* * *! ! ! ! !r   r   __main__)unittestr#   r*   platformr   r8   TestCaser   r   r   mainrw   r   r   <module>r      s      				 . . . . . .D D D D D(+ D D DN?! ?! ?! ?! ?!" ?! ?! ?!D zHMOOOOO r   