
    /hh                         S SK r S SKrS SKrS SKJr   " S S\ R                  5      r " S S\ R                  5      r\	S:X  a  \ R                  " 5         gg)    N)systemc                   L    \ rS rSrSrS rS rS rSrS r	S r
S	 rS
 rS rSrg)ExceptionClassTests   zYTests for anything relating to exception objects themselves (e.g.,
inheritance hierarchy)c                 J    U R                  [        [        [        5      5        g N)
assertTrue
issubclass	Exceptionobjectselfs    @/opt/python-3.13.8/usr/lib/python3.13/test/test_baseexception.pytest_builtins_new_style+ExceptionClassTests.test_builtins_new_style   s    
9f56    c                     S H:  nU R                  [        X5      UR                  R                  < SU< S35        M<     g )N)args__str____repr__z	 missing z
 attribute)r	   hasattr	__class____name__)r   insattrs      r   verify_instance_interface-ExceptionClassTests.verify_instance_interface   s3    3DOOGC.//78 4r   c                 |   [        5       n[        R                  R                  5        H6  n [	        U[
        5      (       a  UR                  UR                  5        M6  M8     [        [        R                  R                  [        R                  R                  [        5      S   S5      SS9n UR                  5       R!                  5       n [#        [        U5      nU R)                  XASU-  5        UR+                  U5        / nSnU GHk  nUR!                  5       nUR-                  S5      n	XS-   S  n
S	U
;   aA  U
R/                  S	5      nXS
-   S nU
S US
-
   n
[1        5       U:w  a  UR+                  U
5        Ms  SU
;   a  U
R/                  S5      nU
S US
-
   n
 [#        [        U
5      nXy:  a  UR3                  UW45        O/Xy:  a*  US   S   U	:  a  UR5                  5         US   S   U	:  a  M  U R7                  [	        WUS   S
   5      UR                  < SUS   S
   R                  < 35         U R9                  U" 5       5        U R)                  X5        UR+                  U
5        UnU	nGMn     UR;                  5         [        S U 5       5      nU R=                  [?        U5      SSU-  5        g ! [         a     GM  f = f! [$         a    U R'                  SU-  5         GNf = f! [$         a    U R'                  SU
-  5         GNgf = f! [         a     Nf = f! UR;                  5         f = f)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 c              3   T   #    U  H  oR                  S 5      (       a  M  Uv   M      g7f)_N)
startswith).0es     r   	<genexpr>7ExceptionClassTests.test_inheritance.<locals>.<genexpr>S   s     BAS0Aaas   (	(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_inheritance$ExceptionClassTests.test_inheritance   s   %((//1Gg}55KK 0 01 6 2  RWW]]84Q79RS ".	%.779@@BOL"8_= MM/(?:<OOO,LJ,#??, .#!GH-(?"*.."5K$,]2$>M'Q7H&(M91 (?#+>>##6L'a8HH!(H5C % ''X(>?'&r*1-6$((* 'r*1-6
3R0@0C D03 $Q'002322359 h0)"
C -F ""$ BBBWq*@7*JKq   " L		8?JKL. & HII;hFGH !  ""$s   0J=0L) K B>L) K4.AL) 6AL) :L+L) =
KKK1-L) 0K11L) 4LL) LL) 
L&#L) %L&&L) )L;)lengthr   strreprc           
          [        U R                  U5       H%  u  nu  p4U R                  X4U< SU< SU< 35        M'     g )Nz: z != )zipinterface_testsrF   )r   results	test_namegivenexpecteds        r   interface_test_driver)ExceptionClassTests.interface_test_driverX   s>    ,/0D0Dg,N(I(U	x/! " -Or   c                 
   Sn[        U5      n[        UR                  5      S/UR                  S   U/[        U5      [        U5      /[	        U5      UR
                  R                  < SU< S3/4nU R                  U5        g )Nspamr"   r   r!   ))r   rG   r   rY   rZ   r   r   rb   )r   argrU   r^   s       r   test_interface_single_arg-ExceptionClassTests.test_interface_single_arg]   sr    nM1%S'9Hc#h'#YCMM$:$:C@AC 	""7+r   c                 B   Sn[        [        U5      5      n[        U6 n[        UR                  5      U/UR                  U/[        U5      [        U5      /[        U5      UR                  R                  [        UR                  5      -   /4nU R                  U5        g )N   )
tupleranger   rG   r   rY   rZ   r   r   rb   )r   	arg_countr   rU   r^   s        r   test_interface_multi_arg,ExceptionClassTests.test_interface_multi_argf   s    	U9%&M9-$/?S3t9%cCMM22T#((^CDF 	""7+r   c                     [        5       n[        UR                  5      S/UR                  [        5       /[	        U5      S/[        U5      UR                  R                  S-   /4nU R                  U5        g )Nr    z())	r   rG   r   rl   rY   rZ   r   r   rb   )r   rU   r^   s      r   test_interface_no_arg)ExceptionClassTests.test_interface_no_argp   sc    kM1%%'':S2cCMM22T9:< 	""7+r   c                    ^ SS K n0 m " U4S jS[        5      n " S S[        5      n[        5       nU" 5       TU" 5       '   UR                  T5        UR	                  5         g )Nr   c                   4   >^  \ rS rSrS\4U U4S jjrSrU =r$ )XExceptionClassTests.test_setstate_refcount_no_crash.<locals>.HashThisKeyWillClearTheDict}   returnc                 @   > TR                  5         [        TU ]	  5       $ r   )clearsuper__hash__)r   r   ds    r   r}   aExceptionClassTests.test_setstate_refcount_no_crash.<locals>.HashThisKeyWillClearTheDict.__hash__~   s    	w'))r    )r   
__module____qualname____firstlineno__intr}   __static_attributes____classcell__)r   r~   s   @r   HashThisKeyWillClearTheDictrw   }   s    *# * *r   r   c                       \ rS rSrSrg)BExceptionClassTests.test_setstate_refcount_no_crash.<locals>.Value   r   Nr   r   r   r   r   r   r   r   Valuer          r   r   )gcrY   r   __setstate__collect)r   r   r   r   rU   r~   s        @r   test_setstate_refcount_no_crash3ExceptionClassTests.test_setstate_refcount_no_crashx   sW     		*# 	*	C 	k+07
%
'( 	 	

r   r   N)r   r   r   r   __doc__r   r   rV   r]   rb   rh   ro   rs   r   r   r   r   r   r   r      s8    78?LB 8O"
,,,r   r   c                   B    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)
UsageTests   zTest usage of exceptionsc                 (     Ue! [          a     gf = f)z6Make sure that raising 'object_' triggers a TypeError.N)r2   r=   typer   rI   s     r   raise_failsUsageTests.raise_fails   s    	M 		s    
c                 N     [         e! U a
       [         ef = f! [         a
       [         e[          a'    U R                  S[        U5      -  5           [         ef = f! U4 a     gf = f! [         a     g[          a     U R                  S[        U5      -  5         gf = f)z,Catching 'object_' should raise a TypeError.z#TypeError expected when catching %sNz;TypeError expected when catching %s as specified in a tuple)r   r2   r=   r   r   s     r   catch_failsUsageTests.catch_fails   s    	M 		1 			1  	MII;d7mKL		1	M :  	 	1II  "&w-0 1	1s^   	  A"  
AA" &AA" A"A,)A/ +A,,A/ /
B$;&B$#B$c                 p     " S S[         5      nU R                  U5        U R                  U" 5       5        g )Nc                       \ rS rSrSrg)DUsageTests.test_raise_new_style_non_exception.<locals>.NewStyleClass   r   Nr   r   r   r   NewStyleClassr      r   r   r   )r   r   )r   r   s     r   "test_raise_new_style_non_exception-UsageTests.test_raise_new_style_non_exception   s,    
	F 	')r   c                 &    U R                  S5        g Nre   )r   r   s    r   test_raise_stringUsageTests.test_raise_string        r   c                 p     " S S[         5      nU R                  U5        U R                  U" 5       5        g )Nc                       \ rS rSrSrg)AUsageTests.test_catch_non_BaseException.<locals>.NonBaseException   r   Nr   r   r   r   NonBaseExceptionr      r   r   r   )r   r   )r   r   s     r   test_catch_non_BaseException'UsageTests.test_catch_non_BaseException   s/    	v 	)*)+,r   c                 6    U R                  [        5       5        g r   )r   r0   r   s    r   !test_catch_BaseException_instance,UsageTests.test_catch_BaseException_instance   s    )r   c                 &    U R                  S5        g r   )r   r   s    r   test_catch_stringUsageTests.test_catch_string   r   r   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s)    "G1.*!-*!r   r   __main__)unittestr-   r4   platformr   rB   TestCaser   r   r   mainr   r   r   <module>r      sQ      	 .G(++ GT?!"" ?!D zMMO r   