
    daf{                        d dl Zd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	m
Z
 d dlmZ 	 d dlmZ d Z G d dej"                        Z G d d	      Z G d
 de      Z G d d      Z G d de      Z G d de      Z ej4                  edu d       G d dej"                               Zedk(  r ej:                          yy# e$ r dZY w xY w)    N)support)threading_helperhamtc                 B     t        j                          fd       }|S )z*Needed to make reftracking test mode work.c                  X    t        j                         } |j                  g| i |S NcontextvarsContextrun)argskwargsctxfuncs      ,/root/Python-3.12.4/Lib/test/test_context.pywrapperz!isolated_context.<locals>.wrapper   s,    !!#swwt-d-f--    )	functoolswraps)r   r   s   ` r   isolated_contextr      s%    __T. . Nr   c                       e Zd Zd Zed        Zd Zd Zd Zd Z	d Z
d Zd	 Zed
        Zd Zd Zd Zed        Zed        Zed        Zed        Zed        Zd Ze ej0                         d               Zy)ContextTestc                    | j                  t        d      5  t        j                          d d d        | j                  t        d      5  t        j                  d       d d d        t        j                  d      }| j	                  |j
                  d       | j                  t              5  d|_        d d d        | j                  t        |      t        d             y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   FxY w)Nztakes exactly 1zmust be a str   aaabbb)
assertRaisesRegex	TypeErrorr   
ContextVarassertEqualnameassertRaisesAttributeErrorassertNotEqualhash)selfcs     r   test_context_var_new_1z"ContextTest.test_context_var_new_1   s    ##I/@A 	%""$	% ##I? 	&""1%	& ""5)'~. 	AF	 	DGT%[1	% 	%	& 	&	 	s#   C#
C/.C;#C,/C8;Dc                    t        j                  d      }| j                  dt        |             t        j                  dd      }| j                  dt        |             g }t        j                  d|      }|j	                  |       | j                  dt        |             | j                  dt        |             |j                  d      }| j                  t        |      t        |             | j                  dt        |             |j                  |       | j                  dt        |             y )Na{   default123z...r   z used )r   r    assertInreprappendsetassertNotInreset)r'   r(   lstts       r   test_context_var_repr_1z#ContextTest.test_context_var_repr_1+   s    ""3'c47#""34eT!W%""34

1eT!W%eT#Y'EE!Hd1gtAw'47+	
hQ(r   c                    | j                  t        d      5   G d dt        j                        }d d d        | j                  t        d      5   G d dt        j                        }d d d        | j                  t        d      5   G d dt        j
                        }d d d        y # 1 sw Y   zxY w# 1 sw Y   NxY w# 1 sw Y   y xY w)Nznot an acceptable base typec                       e Zd Zy)<ContextTest.test_context_subclassing_1.<locals>.MyContextVarN__name__
__module____qualname__ r   r   MyContextVarr;   A   s    r   rA   c                       e Zd Zy)9ContextTest.test_context_subclassing_1.<locals>.MyContextNr<   r@   r   r   	MyContextrC   F       r   rD   c                       e Zd Zy)7ContextTest.test_context_subclassing_1.<locals>.MyTokenNr<   r@   r   r   MyTokenrG   J   rE   r   rH   )r   r   r   r    r   Token)r'   rA   rD   rH   s       r   test_context_subclassing_1z&ContextTest.test_context_subclassing_1?   s    ##I/LM 	{55 	
 ##I/LM 	K// 	 ##I/LM 	+++ 	 		 	
	 		 	s#   B*B6C*B36B?Cc                    | j                  t        d      5  t        j                  d       d d d        | j                  t        d      5  t        j                  dd       d d d        | j                  t        d      5  t        j                  d       d d d        t        j                  di i  y # 1 sw Y   xY w# 1 sw Y   `xY w# 1 sw Y   7xY w)Nzany argumentsr   r+   r@   )r   r   r   r   r'   s    r   test_context_new_1zContextTest.test_context_new_1M   s    ##I? 	#"	###I? 	(Q'	(##I? 	%!$	%!b!	# 	#	( 	(	% 	%s#   B6CC6B?CCc                 b   t        j                         }| j                  t        d      5  |d    d d d        | j                  t        d      5  d|v  d d d        | j                  t        d      5  |j	                  d       d d d        y # 1 sw Y   ]xY w# 1 sw Y   FxY w# 1 sw Y   y xY w)NzContextVar key was expectedr   )r   r   r   r   getr'   r   s     r   test_context_typerrors_1z$ContextTest.test_context_typerrors_1V   s    !!###I/LM 	F	##I/LM 	H	##I/LM 	GGAJ	 			 		 		 	s#   BB2B%BB"%B.c                 l    t        j                         }| j                  |t         j                         y r	   )r   copy_contextassertIsInstancer   rQ   s     r   test_context_get_context_1z&ContextTest.test_context_get_context_1`   s&    &&(c;#6#67r   c                     t        j                         }| j                  t        d      5  |j	                          d d d        y # 1 sw Y   y xY w)Nzmissing 1 required)r   r   r   r   r   rQ   s     r   test_context_run_1zContextTest.test_context_run_1d   s?    !!###I/CD 	GGI	 	 	s   AAc                    t        j                         }d }|t        j                  |      fD ]  }| j	                  |j                  |      dddif       | j	                  |j                  |d      dddif       | j	                  |j                  |d      dddd	f       | j	                  |j                  |d
d      dddd	f       i }| j	                   |j
                  |d
fi |dddif       | j	                  |i         y )Nc                      d|d<   | dz  } | |fS )Nfoospambarr@   r   r   s     r   r   z,ContextTest.test_context_run_2.<locals>.funcm   s    "F6NHD<r   r]   r\   r[   r   )r   r^      rL   )r+   r\      )ra   r^   )r   r   r   partialr!   r   )r'   r   r   fr+   s        r   test_context_run_2zContextTest.test_context_run_2j   s   !!#	 
 	))$/0 	$A SWWQZ(VUO)DESWWQ]Z&%,IJQE235 2#Au568 A2##vuo.0 Q#%	$r   c                    t        j                         }d }| j                  t              5  |j	                  |       d d d        | j                  t              5  |j	                  |dd       d d d        | j                  t              5  |j	                  |ddd       d d d        y # 1 sw Y   nxY w# 1 sw Y   IxY w# 1 sw Y   y xY w)Nc                      ddz   y )Nr   r   r@   r_   s     r   r   z,ContextTest.test_context_run_3.<locals>.func   s	    Er   r   r`   r,   rL   )r   r   r#   ZeroDivisionErrorr   )r'   r   r   s      r   test_context_run_3zContextTest.test_context_run_3   s    !!#	 01 	GGDM	01 	 GGD!Q	 01 	'GGD!Q#G&	' 	'		 		  	 	' 	's#   B,B8C,B58CCc                 6    t        j                         }t        j                         t        j                  d       fd fd}|j                  |      } j	                  ||        j	                  |   d        j                  |       y )Nvarc                  F     j                  j                  d              y r	   )assertIsNonerP   r'   rj   s   r   func2z-ContextTest.test_context_run_4.<locals>.func2   s    cggdm,r   c                  V   j                  j                  d              j                  d       j                         j	                  j                  d       d       t        j                         } j	                  t        |       d       j	                  |    d       | S )Nr\   r   )rl   rP   r3   r   r!   r   rT   len)curctx2rn   r'   rj   s    r   func1z-ContextTest.test_context_run_4.<locals>.func1   s    cggdm,GGFOHHUOSWWT]F3**,CSXq)SXv.Jr   r\   )r   r   r    r   r!   r0   )r'   ctx1rs   returned_ctxrr   rn   rj   s   `   @@@r   test_context_run_4zContextTest.test_context_run_4   s{    ""$""$$$U+	-		 xx|,c*F3c<(r   c                     t        j                         }t        j                  d       fd} j                  t              5  |j                  |       d d d         j                  j                  d              y # 1 sw Y   *xY w)Nrj   c                  r     j                  j                  d              j                  d       ddz   y )Nr\   r   r   )rl   rP   r3   rm   s   r   r   z,ContextTest.test_context_run_5.<locals>.func   s+    cggdm,GGFOEr   )r   r   r    r#   rg   r   rl   rP   )r'   r   r   rj   s   `  @r   test_context_run_5zContextTest.test_context_run_5   so    !!#$$U+	
 01 	GGDM	 	#''$-(	 	s   BBc                      t        j                         t        j                  dd       fd}j                  |       y )Nr+   r   r-   c                  *   j                   j                         d       j                  j                                 j                  d       j                   j                         d       j                  j                         d       y )Nr   *   )r!   rP   rl   r3   )r(   r   r'   s   r   funz+ContextTest.test_context_run_6.<locals>.fun   sh    QUUWa(cggaj)EE"IQUUWb)SWWQZ,r   r   r   r    r   r'   r}   r(   r   s   ` @@r   test_context_run_6zContextTest.test_context_run_6   s5    !!#""32	- 	r   c                 b     t        j                          fdj                         y )Nc                  ~    j                  t        d      5   j                         d d d        y # 1 sw Y   y xY w)Nzis already entered)r   RuntimeErrorr   )r   r}   r'   s   r   r}   z+ContextTest.test_context_run_7.<locals>.fun   s4    ''6JK   s   3<r
   )r'   r   r}   s   `@@r   test_context_run_7zContextTest.test_context_run_7   s#    !!#	 	r   c                 R	   t        j                  d      }| j                  t              5  |j	                          d d d        | j                  |j	                  d              |j                  d      }| j                  |j	                         d       | j                  |j	                  d       d       | j                  |j                  |j                         | j                  |j                  t         j                  j                         | j                  |j                  |       |j                  d      }| j                  |j	                         d       | j                  |j	                  d       d       | j                  |j                  d       |j                  |       | j                  |j	                         d       | j                  |j	                  d       d       |j                  d       | j                  t        d      5  |j                  |       d d d        | j                  |j	                         d       t        j                          }| j#                  ||       |j                  |       | j                  t        d      5  |j                  |       d d d        | j                  |j	                  d              | j#                  ||       | j                  ||   d       | j                  |j	                  |d      d       | j                  t%        |      d       | j                  t'        |j)                               |dfg       | j                  t'        |j+                               dg       | j                  t'        |j-                               |g       | j                  t'        |      |g       t        j                          }| j/                  ||       | j                  t0              5  ||    d d d        | j                  |j	                  |d      d       | j                  t%        |      d       | j                  t'        |      g        y # 1 sw Y   <xY w# 1 sw Y   `xY w# 1 sw Y   xY w# 1 sw Y   xY w)	Nr(   r|   r\   spam2zhas already been usedaar   r   )r   r    r#   LookupErrorrP   rl   r3   r!   assertIs	old_valueMISSINGrI   rj   r5   r   r   rT   r0   rp   listitemsvalueskeysr4   KeyError)r'   r(   t0r7   rt   rr   s         r   test_context_getset_1z!ContextTest.test_context_getset_1   sm   ""3'{+ 	EEG	 	!%%+&UU2Y"%tb)bllBJJ/bllK$5$5$=$=>bffa EE&M&)tf-b)	
"%tb)	g##L2IJ 	GGAJ	'*'')a	##L2IJ 	GGBK	!%%+&aa'*!T*G4TA&djjl+q'l^<dkkm,wi8diik*QC0daS)'')D!x( 	G	!T*D1TA&dR(c	 	,	 		 		 	s/   Q6RRR6R RRR&c                     t        j                  d      }t        j                  d      }|j                  d      }| j                  t        d      5  |j                  |       d d d        y # 1 sw Y   y xY w)Nv1v2r|   zby a different)r   r    r3   r   
ValueErrorr5   )r'   r   r   t1s       r   test_context_getset_2z!ContextTest.test_context_getset_2  s`    ##D)##D)VVBZ##J0@A 	HHRL	 	 	s   A--A6c                      t        j                  dd      t        j                          fd}j                  |       y )Nr(   r|   r-   c                     j                  j                         d       j                  t              5      d d d        j	                  j                               j                  j                  d      d       j                         j                  t        j                               g        j                  d      } j                  t        j                               g       j                     d       j                  |        j                  t        j                               g        j                  t              5      d d d        y # 1 sw Y   5xY w# 1 sw Y   y xY w)Nr|   r\   r   )
r!   rP   r#   r   rl   r4   r   r   r3   r5   )r7   r(   r   r'   s    r   r}   z.ContextTest.test_context_getset_3.<locals>.fun  s2   QUUWb)""8, Acggaj)SWWQ/8Q$T#((*-r2aAT#((*-s3SVQ'GGAJT#((*-r2""8, A   s   E0!E=0E:=F)r   r    r   r   r   s   ` @@r   test_context_getset_3z!ContextTest.test_context_getset_3  s5    ""33!!#	$ 	r   c                 
   t        j                  dd      }t        j                         }|j                  |j                  d      }| j                  t        d      5  |j                  |       d d d        y # 1 sw Y   y xY w)Nr(   r|   r-   r   zdifferent Context)r   r    r   r   r3   r   r   r5   )r'   r(   r   toks       r   test_context_getset_4z!ContextTest.test_context_getset_4)  sg    ""33!!#ggaeeQ##J0CD 	GGCL	 	 	s   A99Bc                      t        j                  dd      j                  g         fd}t        j                         j	                  |        j                  j                         g        y )Nr(   r|   r-   c                       j                  g         j                         j                  d       j                   j                         dg       y )Nr|   )r3   rP   r2   r!   r(   r'   s   r   r}   z.ContextTest.test_context_getset_5.<locals>.fun8  s8    EE"IEEGNN2QUUWrd+r   )r   r    r3   rT   r   r!   rP   )r'   r}   r(   s   ` @r   test_context_getset_5z!ContextTest.test_context_getset_53  sT    ""33	b		,
 	  "&&s+"%r   c                      t        j                         t        j                  dd       fd} fdj                  |       y )Nr(   r|   r-   c                  ^   j                  d       j                         } j                  |    d       j                  d       j                     d       j                  |    d       | j                         j                     d       j                  |    d       y )N
         )r3   copyr!   r   )rr   r(   rt   ctx2_funr'   s    r   ctx1_funz1ContextTest.test_context_copy_1.<locals>.ctx1_funD  s    EE"I99;DT!Wb)EE"IT!Wb)T!Wb)HHXT!Wb)T!Wb)r   c                      j                   j                         d        j                  d       j                   j                         d       y )Nr   r   )r!   rP   r3   r   s   r   r   z1ContextTest.test_context_copy_1.<locals>.ctx2_funR  s:    QUUWb)EE"IQUUWb)r   r~   )r'   r   r(   rt   r   s   ` @@@r   test_context_copy_1zContextTest.test_context_copy_1@  s;    ""$""33	*	*
 	r   c                 Z    t        j                  d       fd}t        j                  j	                  d      }	 t        |j                  |t        d                  }|j                           j                  |t        t        d                   y # |j                          w xY w)Ncvarc                     t        d      D ]b  }j                  | |z          t        j                  t	        j
                  dd             j                  j                         | |z          d | S )Nr   gMbP?g?)ranger3   timesleeprandomuniformr!   rP   )numir   r'   s     r   subz/ContextTest.test_context_threads_1.<locals>.sub^  s^    2Y 6q!

6>>%67  S1W56 Jr   r   )max_workers)
r   r    
concurrentfuturesThreadPoolExecutorr   mapr   shutdownr!   )r'   r   tpresultsr   s   `   @r   test_context_threads_1z"ContextTest.test_context_threads_1Y  s     %%f-	 22r2B	266#uRy12GKKM$uRy/2 KKMs   $B B*N)r=   r>   r?   r)   r   r8   rJ   rN   rR   rV   rX   rd   rh   rv   ry   r   r   r   r   r   r   r   r   r   requires_working_threadingr   r@   r   r   r   r      s    2 ) )&"8$8' ) )0) 3) 3)j    0   
& 
&2 00023 3 3r   r   c                   .    e Zd ZdZdddZd Zd Zd Zy)HashKeyNerror_on_eq_toc                <    |dk7  sJ || _         || _        || _        y )N)r"   r&   r   )r'   r&   r"   r   s       r   __init__zHashKey.__init__s  s$    rzz		,r   c                 <    d| j                    d| j                   dS )Nz
<Key name:z hash:>)r"   r&   rM   s    r   __repr__zHashKey.__repr__y  s    DII;fTYYKq99r   c                 j    | j                   | j                   j                  rt        | j                  S r	   )_crashererror_on_hashHashingErrorr&   rM   s    r   __hash__zHashKey.__hash__|  s(    ==$)D)Dyyr   c                    t        |t              st        S | j                  | j                  j                  rt
        | j                  | j                  |u rt        d| d|      |j                  |j                  | u rt        d|d|       | j                  | j                  f|j                  |j                  fk(  S )Nzcannot compare z to )

isinstancer   NotImplementedr   error_on_eqEqErrorr   r   r"   r&   )r'   others     r   __eq__zHashKey.__eq__  s    %)!!==$)B)BM*t/B/Be/Kthd5)DEE+0D0D0LuitD8DEE		499%%**ejj)AAAr   )r=   r>   r?   r   r   r   r   r   r@   r   r   r   r   p  s    H59 -:Br   r   c                   (     e Zd Z fdZ fdZ xZS )KeyStrc                     t         j                   t         j                  j                  rt        t        |          S r	   )r   r   r   r   superr   )r'   	__class__s    r   r   zKeyStr.__hash__  s1    'G,<,<,J,Jw!!r   c                     t         j                   t         j                  j                  rt        t        |   |      S r	   )r   r   r   r   r   r   )r'   r   r   s     r   r   zKeyStr.__eq__  s1    'G,<,<,H,HMw~e$$r   )r=   r>   r?   r   r   __classcell__)r   s   @r   r   r     s    "
% %r   r   c                   &    e Zd ZddddZd Zd Zy)HaskKeyCrasherFr   r   c                     || _         || _        y r	   r   )r'   r   r   s      r   r   zHaskKeyCrasher.__init__  s    *&r   c                 P    t         j                  t        d      | t         _        y )Nzcannot nest crashers)r   r   r   rM   s    r   	__enter__zHaskKeyCrasher.__enter__  s"    '566r   c                     d t         _        y r	   )r   r   )r'   excs     r   __exit__zHaskKeyCrasher.__exit__  s
    r   N)r=   r>   r?   r   r   r   r@   r   r   r   r     s    (-5 ' 
 r   r   c                       e Zd Zy)r   Nr<   r@   r   r   r   r         r   r   c                       e Zd Zy)r   Nr<   r@   r   r   r   r     r   r   r   z!_testcapi lacks "hamt()" functionc                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	 e
j                  d      d	        Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)HamtTestc                    t        dd      }t        dd      }| j                  ||       | j                  t        |      t        |             t	               }d||<   d||<   | j                  ||   d       | j                  ||   d       y )Nr   r   r   r+   b)r   r%   r!   r&   dict)r'   k1k2ds       r   test_hashkey_helper_1zHamtTest.test_hashkey_helper_1  s    RRB#b48,F""2$2$r   c                     t               }d }y r	   r   r'   hs     r   test_hamt_basics_1zHamtTest.test_hamt_basics_1  s    Fr   c                 D   t               }| j                  t        |      d       |j                  dd      }| j	                  ||       | j                  t        |      d       | j                  t        |      d       | j                  |j                  d             | j                  |j                  dd      d       | j                  |j                  d      d       |j                  dd      }| j	                  ||       | j                  t        |      d       | j                  t        |      d       | j                  t        |      d       | j                  |j                  d      d       | j                  |j                  d      d       | j                  |j                  d             | j                  |j                  d             | j                  |j                  d             | j                  |j                  d      d       d x}x}}y )Nr   r+   r   r   r|   r   r`   )r   r!   rp   r3   assertIsNotrl   rP   )r'   r   h2h3s       r   test_hamt_basics_2zHamtTest.test_hamt_basics_2  s   FQ#UU3_BQ#R!$!%%*%sB,c*VVC_R Q#R!$R!$c*b)!%%*%"&&+&!%%*%c*Br   c                     t               }t               }|j                  d|      }|j                  d|      }| j                  ||       y )N1)r   objectr3   r   )r'   r   oh1r   s        r   test_hamt_basics_3zHamtTest.test_hamt_basics_3  s<    FHUU3]VVC^b"r   c                 P   t               }|j                  dg       }|j                  dg       }| j                  ||       | j                  t	        |      d       | j                  t	        |      d       | j                  |j                  d      |j                  d             y )Nkeyr   )r   r3   r   r!   rp   rP   )r'   r   r  r   s       r   test_hamt_basics_4zHamtTest.test_hamt_basics_4  s    FUU5"VVE2R R!$R!$u6r   c                    t        dd      }t        dd      }t        dd      }t               }|j                  |d      }|j                  |d      }| j                  |j	                  |      d        | j                  |j	                  |      d        | j                  |j	                  |      d       | j                  |j	                  |      d        | j                  |j	                  |      d       | j                  |j	                  |      d       |j                  |d      }|j                  |d      }| j                  |j	                  |      d       | j                  |j	                  |      d       | j                  |j	                  |      d       | j                  |j	                  |      d       | j                  |j	                  |      d        | j                  |j	                  |      d       | j                  |j	                  |      d       | j                  |j	                  |      d       | j                  |j	                  |      d       | j                  t        |      d	       | j                  t        |      d
       | j                  t        |      d       | j                  t        |      d       | j                  t        |      d       y )Nr   r   r   cccr+   r   ccr   r   r   r`      )r   r   r3   r!   rP   rp   )	r'   r   r   k3r   r   r   h4h5s	            r   test_hamt_collision_1zHamtTest.test_hamt_collision_1  s7   RRRFUU2s^VVB_rD)rD)S)T*S)S)VVBVVBS)S)S)T*T*S)T*T*T*Q#R!$R!$R!$R!$r   c                 J   t        dd      }t        dd      }t        dd      }t               }|j                  |d      }|j                  |d      }|j                  |d      }| j                  |j	                         D ch c]  }|j
                   c}h d       y c c}w )Nl        CDr   E>   r  r  r  )r   r   r3   r!   r   r"   )r'   r  r  r  r   ks         r   test_hamt_collision_3zHamtTest.test_hamt_collision_3  s     93?93?93?FEE!SMEE!SMEE!SM* 	!&&(3Q!&&3_E3s   B cpuc           	         d}d}d}d}d}t        |      D ]  }t               }t               }t        |      D ]k  }	t        |	      }
|	|z  sEt	        d      5  | j                  t              5  |j                  |
|	       d d d        d d d        |j                  |
|	      }|	|z  sMt	        d      5  | j                  t              5  |j                  t        |	             d d d        d d d        |	||
<   | j                  t        |      t        |             |	|z  r| j                  t        |j                               t        |j                                      | j                  t        |j                               t        |j                                      n | j                  t        |      |       t        |      D ]-  }
| j                  |j                  t        |
      d	      |
       / t        t        |            }t        j                  |       t!        |      D ]  \  }}	t        |	      }
||z  sDt	        d      5  | j                  t              5  |j#                  |
       d d d        d d d        ||z  sMt	        d      5  | j                  t              5  |j#                  t        |	             d d d        d d d        |j#                  |
      }| j                  |j                  |
d	      d	       ||
= | j                  t        |      t        |             ||d
z  k(  r|}|j%                         }||z  r(| j                  t        |j'                               t        |j'                                      | j                  t        |j'                               t        |j'                                       | j                  t        |      d       | j                  t        |      d       D ]/  }
| j                  j                  t)        |
            ||
          1 | j                  t        |      t                     t!        |      D ]  \  }	}
|j#                  t)        |
            }| j                  |j                  t)        |
      d	      d	       |j+                  t)        |
      d        | j                  t        |      t        |             |	|z  r| j                  t        |j-                               t        |j-                                      | j                  t        |j-                               t        |j-                                       | j                  t        |      d       | j                  t        |      d       | j                  t        |j                               g         y # 1 sw Y   mxY w# 1 sw Y   rxY w# 1 sw Y   #xY w# 1 sw Y   (xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   nxY w# 1 sw Y   sxY w)NiX  i  a   ra   r	  Tr   r   z	not foundr`   r   )r   r   r   r   r   r#   r   r3   r   rP   r!   rp   r   r   r   shuffle	enumeratedeleter   r   strpopr   )r'   COLLECTION_SIZETEST_ITERS_EVERYCRASH_HASH_EVERYCRASH_EQ_EVERY
RUN_XTIMES_r   r   r   r  keys_to_deleteiter_ihmdms                  r   test_hamt_stresszHamtTest.test_hamt_stress>  s   
z" P	2AAA?+ EQi,,'d; *!..|< *EE#qM** EE#qMN*'D9 -!..w7 -EE&),-- #  QQ0,,$$S^S^D$$S^S^D)E, SV_5_- G  vc{K!@#FG "%"89NNN>*&~6 C	Qi!11'd; *!..|< *HHSM** /'D9 0!..w7 0HHVAY/00 HHSM  sK!8+FcF  QQ0_11BB!11$$S]CMB$$S]CMB1C4 SVQ'SVQ'  <  C!12c7;<SWc"g.#N3 G3YYs3x(  C+!>Ls3x&  QQ0,,$$S_c!((*oF$$S_c!((*oFG SVQ'SVQ'T!'')_b1aP	2* ** *- -- -.* ** *0 00 0s   W:/W-	W:5XX	&XX.+X!	=X.Y4X;	Y-W72W::XXXX!X+&X..X8;Y YYc                 .   t        dd      }t        dd      }t        dd      }t        dd      }t        d	d
      }t        dd      }t        dd|      }t               }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }t        |      }	|j	                  |      }| j                  t        |      |	dz
         | j                  t        d      5  |j	                  |       d d d        |j	                  |      }| j                  t        |      |	dz
         |j	                  |      }
| j                  |
|       |j	                  |      }| j                  t        |      |	dz
         | j                  |j                  |d      d       | j                  |j                  |      d       | j                  |j                  |      d       y # 1 sw Y   xY w)Nd   Ae   Bf   r  g   r  h   r  ZErr   r+   r   r(   r   er   cannot comparer`   r	  r|   )
r   r   r3   rp   r  r!   r   r   r   rP   )r'   r+  r-  r  r  r  r2  r3  r   orig_lenr   s              r   test_hamt_delete_1zHamtTest.test_hamt_delete_1  s   CCCCCD#S$q1FEE!SMEE!SMEE!SMEE!SMEE!SMq6 HHQKQA.##J0@A 	HHRL	 HHQKQA.XXa[b!HHQKQA.q"r*q3'q3'	 	s   HHc                    t        dd      }t        dd      }t        dd      }t        dd      }t        d	d
      }t        dd      }t        dd|      }t               }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }t        |      }	| j	                  t
        d      5  |j                  |       d d d        |j                  |      }| j                  t        |      |	       |j                  |      }| j                  t        |      |	dz
         |j                  |      }| j                  t        |      |	dz
         |j                  |      }| j                  t        |      |	dz
         | j                  |j                  |      d       | j                  |j                  |      d       |j                  |      }|j                  |      }|j                  |      }|j                  |      }| j                  t        |      d       y # 1 sw Y   exY w)Nr*  r+  ) r-  鉊 r  r/  r  r0  r  r1  r2  r3  r   r+   r   r(   r   r4  r5  r   r`   r	  r   )	r   r   r3   rp   r   r   r  r!   rP   )
r'   r+  r-  r  r  r  r2  r3  r   r6  s
             r   test_hamt_delete_2zHamtTest.test_hamt_delete_2  s   CFC FC CCD#VT!4FEE!SMEE!SMEE!SMEE!SMEE!SMq6 ##J0@A 	HHRL	 HHQKQ*HHQKQA.HHQKQA.HHQKQA.q3'q3'HHQKHHQKHHQKHHQKQ#-	 	s   IIc                    t        dd      }t        dd      }t        dd      }t        dd      }t        dd	      }t               }|j                  |d
      }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }t        |      }|j	                  |      }| j                  t        |      |dz
         |j	                  |      }| j                  t        |      |dz
         | j                  |j                  |      d       | j                  |j                  |      d       y )Nr*  r+  r,  r-   r  r  r0  r  r+   r   r(   r   r4  r   r`   )r   r   r3   rp   r  r!   rP   r'   r+  r-  r  r  r  r   r6  s           r   test_hamt_delete_3zHamtTest.test_hamt_delete_3  s   CCFC FC CFEE!SMEE!SMEE!SMEE!SMEE!SMq6 HHQKQA.HHQKQA.q3'q3'r   c                 *   t        dd      }t        dd      }t        dd      }t        dd      }t        dd      }t               }|j                  |d	      }|j                  |d
      }|j                  |d      }|j                  |d      }|j                  |d      }t        |      }|j	                  |      }| j                  t        |      |dz
         |j	                  |      }| j                  t        |      |dz
         |j	                  |      }| j                  t        |      |dz
         |j	                  |      }| j                  t        |      |dz
         |j	                  |      }| j                  t        |      d       y )Nr*  r+  r,  r-  r=  r  r  r  r+   r   r(   r   r4  r   r`   r	     r   )r   r   r3   rp   r  r!   r>  s           r   test_hamt_delete_4zHamtTest.test_hamt_delete_4  sP   CCFC FC FC FEE!SMEE!SMEE!SMEE!SMEE!SMq6 HHQKQA.HHQKQA.HHQKQA.HHQKQA.HHQKQ#r   c                 Z   t               }g }t        d      D ]=  }t        |t        |            }|j	                  |       |j                  |d|       }? t        dd      }|j                  |d      }| j                  t        |      d       |j                  |d         }| j                  t        |      d       |j                  |      }| j                  t        |      d       |j                  |d         }| j                  t        |      d       |j                  |d	         }| j                  t        |      d
       |j                  |d	         }| j                  t        |      d
       |D ]  }|j                  |      } | j                  t        |      d       y )N   zval-   18	collision   r`      r      r   )	r   r   r   r  r2   r3   r!   rp   r  )r'   r   r   r   r  collision_key16s         r   test_hamt_delete_5zHamtTest.test_hamt_delete_5G  sq   Fr 	'A!SV$CKKcT!:&A	'
 ""d+EE/;/( 	Q$HHT!WQ$HH_%Q$HHT"XQ$HHT!WQ$HHT!WQ$ 	CA	Q#r   c           
         t        dd      }t        dd      }t        dd      }t        dd      }t        d	d
      }t        dd      }t               }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }|j                         }| j	                  t        t        |            |df|df|df|df|df|dfh       y )Nr*  r+  r9  r-  r:  r  r/  r  r0  r  n   Fr+   r   r(   r   r4  rc   r   r   r3   r   r!   r   	r'   r+  r-  r  r  r  rO  r   its	            r   test_hamt_items_1zHamtTest.test_hamt_items_1x  s    CFC FC CCCFEE!SMEE!SMEE!SMEE!SMEE!SMEE!SMWWYRMX3x!SAs8aX3xH	Jr   c           
         t        dd      }t        dd      }t        dd      }t        dd      }t        dd      }t        d	d
      }t               }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }|j                         }| j	                  t        t        |            |df|df|df|df|df|dfh       y Nr*  r+  r,  r-  r=  r  r  r  rN  rO  r+   r   r(   r   r4  rc   rP  rQ  s	            r   test_hamt_items_2zHamtTest.test_hamt_items_2  s    CCFC FC FC CFEE!SMEE!SMEE!SMEE!SMEE!SMEE!SMWWYRMX3x!SAs8aX3xH	Jr   c           	      D   t        dd      }t        dd      }t        dd      }t        dd      }t        dd      }t        d	d
      }t               }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }|j                  |d      }| j                  t        t	        |j                                     ||||||h       | j                  t        t	        |            ||||||h       y rU  )r   r   r3   r!   r   r   )r'   r+  r-  r  r  r  rO  r   s           r   test_hamt_keys_1zHamtTest.test_hamt_keys_1  s    CCFC FC FC CFEE!SMEE!SMEE!SMEE!SMEE!SMEE!SMT!&&(^,q!Q1a.@AT!W1aAq'9:r   c                     t               }| j                  t        |j                               d       | j                  t	        |j                               g        y )Nr   )r   r!   rp   r   r   r   s     r   test_hamt_items_3zHamtTest.test_hamt_items_3  s=    FQWWY+aggi"-r   c                    t        dd      }t        dd      }t        dd      }t        dd      }t        dd	      }t               }|j                  |d
      }|j                  |d      }|j                  |d      }|j                  |d      }t               }|j                  |d
      }| j                  ||k(         | j	                  ||k7         |j                  |d      }| j                  ||k(         | j	                  ||k7         |j                  |d      }| j                  ||k(         | j	                  ||k7         |j                  |d      }| j                  ||k(         | j	                  ||k7         |j                  |d      }| j	                  ||k(         | j                  ||k7         |j                  |d      }| j                  ||k(         | j	                  ||k7         |j                  |      }| j                  ||k(         | j	                  ||k7         |j                  |d      }| j                  ||k(         | j	                  ||k7         y )Nr*  r+  r,  r-  r=  r  r  x   r  r+   r   r(   r   d2r4  )r   r   r3   assertFalse
assertTruer  )r'   r+  r-  r  r  r  r  r   s           r   test_hamt_eq_1zHamtTest.test_hamt_eq_1  s   CCFC FC CVVVAs^VVAs^VVAs^VVAs^VVVAs^r"b!VVAs^r"b!VVAs^r"b!VVAt_r"b!VVAs^b!r"VVAs^r"b!YYq\r"b!VVAs^r"b!r   c                 h   t        dd      }t        dd|      }t               }|j                  |d      }t               }|j                  |d      }| j                  t        d      5  ||k(   d d d        | j                  t        d      5  ||k7   d d d        y # 1 sw Y   .xY w# 1 sw Y   y xY w)Nr*  r+  r3  r   r+   r5  )r   r   r3   r   r   )r'   r+  r3  r  r   s        r   test_hamt_eq_2zHamtTest.test_hamt_eq_2  s    CS$q1VVVAs^VVVB_##J0@A 	"H	 ##J0@A 	"H	 		 		 	s   )BB(B%(B1c                    t        dd      }t               }|j                  dd      }t        j                  |      }g }|j                  |       |j                  |       g }|j                  |       |j                  |       |j                  ||      }~~~t        j                          t        j                          t        j                          | j                   |              y )Nr*  r+  r   )	r   r   r3   weakrefrefr2   gccollectrl   )r'   r+  r   re  r+   r   s         r   test_hamt_gc_1zHamtTest.test_hamt_gc_1  s    CFEE!QKkk!n				EE!QKq!








#% r   c                    t        dd      }t        dd      }t               }|j                  |d      }|j                  ||      }t        j                  |      }|j                         }t        |       ~~t        j                          t        j                          t        j                          | j                   |              y )Nr*  r+  r,  r-  r+   )
r   r   r3   rd  re  r   nextrf  rg  rl   )r'   r+  r-  r   re  his         r   test_hamt_gc_2zHamtTest.test_hamt_gc_2  s    CCFEE!SMEE!QKkk!nWWYRr








#% r   c                    t        dd      }t        dd      }t        dd      }t               }|j                  |d      }| j                  ||v        | j	                  ||v        | j                  t              5  t        d      5  ||v  d d d        d d d        | j                  t              5  t        d      5  ||v  d d d        d d d        y # 1 sw Y   IxY w# 1 sw Y   MxY w# 1 sw Y   *xY w# 1 sw Y   y xY w	Nr*  r+  r,  r-  r   Tr  r  )	r   r   r3   r_  r^  r#   r   r   r   r'   r+  AAr-  r   s        r   test_hamt_in_1zHamtTest.test_hamt_in_1$  s    CS#CFEE!QKQa w' 	D1 a	 |, 	d3 a	 	 	 	
 	 	sH   <C"	CC"3C: C.C:C	C""C+.C7	3C::Dc                 v   t        dd      }t        dd      }t        dd      }t               }|j                  |d      }| j                  ||   d       | j                  ||   d       | j	                  t
              5  ||    d d d        | j	                  t              5  t        d      5  ||    d d d        d d d        | j	                  t              5  t        d      5  ||    d d d        d d d        y # 1 sw Y   zxY w# 1 sw Y   VxY w# 1 sw Y   ZxY w# 1 sw Y   6xY w# 1 sw Y   y xY wrn  )	r   r   r3   r!   r#   r   r   r   r   ro  s        r   test_hamt_getitem_1zHamtTest.test_hamt_getitem_18  s%   CS#CFEE!QK1q!2"x( 	aD	 w' 	D1 "	 |, 	d3 "	 		 	 	 	
 	 	sT    C?#D0D6DD/(D#.D/?DD	DD #D,	(D//D8N)r=   r>   r?   r   r   r   r  r  r  r  r   requires_resourcer(  r7  r;  r?  rB  rL  rS  rV  rX  rZ  r`  rb  rh  rl  rq  rs  r@   r   r   r   r     s    %<7#%J!FF Wu%W2 &W2r+(Z2$h"(H($T/$bJ*J*;&.
-"^ !.!((r   r   __main__)concurrent.futuresr   r   r   rf  r   r   unittestrd  testr   test.supportr   	_testcapir   ImportErrorr   TestCaser   r   r  r   r   	Exceptionr   r   skipIfr   r=   mainr@   r   r   <module>r     s       	      )
O3(## O3j
B BB	%S 	%   	9 		i 	 BCY
x   Y
 DY
x zHMMO E"  Ds   C CC