
    6bhe|                        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      ;/opt/python-3.12.12/usr/lib/python3.12/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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j2                         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""$ B ##I?""1% @ ""5)'~.AF / 	DGT%[1 BA @? /.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  N
 ##I/LMK//  N ##I/LM+++  NM NM
 NM NMs#   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                      G d dt               }| j                  t        d      5  t        j                   |              d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zd Zy)GContextTest.test_context_new_unhashable_str_subclass.<locals>.weird_strc                      y r	   r@   r'   others     r   __eq__zNContextTest.test_context_new_unhashable_str_subclass.<locals>.weird_str.__eq__Y   s    r   N)r=   r>   r?   rU   r@   r   r   	weird_strrQ   X   s    r   rV   zunhashable type)strr   r   r   r    )r'   rV   s     r   (test_context_new_unhashable_str_subclassz4ContextTest.test_context_new_unhashable_str_subclassV   s>    	 	 ##I/@A""9;/ BAAs   A

A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_1_   s    !!###I/LMF N##I/LMH N##I/LMGGAJ NM	 NMMMMMs#   BB2B%BB"%B.c                 l    t        j                         }| j                  |t         j                         y r	   )r   copy_contextassertIsInstancer   r[   s     r   test_context_get_context_1z&ContextTest.test_context_get_context_1i   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   r[   s     r   test_context_run_1zContextTest.test_context_run_1m   s7    !!###I/CDGGI EDDs   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>.funcv   s    "F6NHD<r   rg   rf   re   r   )r   rh      rL   )r+   rf      )rk   rh   )r   r   r   partialr!   r   )r'   r   r   fr+   s        r   test_context_run_2zContextTest.test_context_run_2s   s   !!#	 
 	))$/0A SWWQZ(VUO)DESWWQ]Z&%,IJQE235 2#Au568 A2##vuo.0 Q#% 1r   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@   ri   s     r   r   z,ContextTest.test_context_run_3.<locals>.func   s	    Er   r   rj   r,   rL   )r   r   r#   ZeroDivisionErrorr   )r'   r   r   s      r   test_context_run_3zContextTest.test_context_run_3   s    !!#	 01GGDM 201GGD!Q 201GGD!Q#G& 21	 211111s#   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	   )assertIsNonerZ   r'   rt   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 )Nrf   r   )rv   rZ   r3   r   r!   r   r^   len)curctx2rx   r'   rt   s    r   func1z-ContextTest.test_context_run_4.<locals>.func1   s    cggdm,GGFOHHUOSWWT]F3**,CSXq)SXv.Jr   rf   )r   r   r    r   r!   r0   )r'   ctx1r}   returned_ctxr|   rx   rt   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)Nrt   c                  r     j                  j                  d              j                  d       ddz   y )Nrf   r   r   )rv   rZ   r3   rw   s   r   r   z,ContextTest.test_context_run_5.<locals>.func   s+    cggdm,GGFOEr   )r   r   r    r#   rq   r   rv   rZ   )r'   r   r   rt   s   `  @r   test_context_run_5zContextTest.test_context_run_5   sh    !!#$$U+	
 01GGDM 2 	#''$-( 21s   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!   rZ   rv   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   s,    ''6JK LKKs   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   rf   spam2zhas already been usedaar   r   )r   r    r#   LookupErrorrZ   rv   r3   r!   assertIs	old_valueMISSINGrI   rt   r5   r   r   r^   r0   rz   listitemsvalueskeysr4   KeyError)r'   r(   t0r7   r~   r|   s         r   test_context_getset_1z!ContextTest.test_context_getset_1   sU   ""3'{+EEG , 	!%%+&UU2Y"%tb)bllBJJ/bllK$5$5$=$=>bffa EE&M&)tf-b)	
"%tb)	g##L2IJGGAJ K'*'')a	##L2IJGGBK K!%%+&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 ,+, KJ KJ )(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  sX    ##D)##D)VVBZ##J0@AHHRL BAAs   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   rf   r   )
r!   rZ   r#   r   rv   r4   r   r   r3   r5   )r7   r(   r   r'   s    r   r   z.ContextTest.test_context_getset_3.<locals>.fun  s"   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_42  s_    ""33!!#ggaeeQ##J0CDGGCL EDDs   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   rZ   r2   r!   r(   r'   s   r   r   z.ContextTest.test_context_getset_5.<locals>.funA  s8    EE"IEEGNN2QUUWrd+r   )r   r    r3   r^   r   r!   rZ   )r'   r   r(   s   ` @r   test_context_getset_5z!ContextTest.test_context_getset_5<  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   )r|   r(   r~   ctx2_funr'   s    r   ctx1_funz1ContextTest.test_context_copy_1.<locals>.ctx1_funM  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!   rZ   r3   r   s   r   r   z1ContextTest.test_context_copy_1.<locals>.ctx2_fun[  s:    QUUWb)EE"IQUUWb)r   r   )r'   r   r(   r~   r   s   ` @@@r   test_context_copy_1zContextTest.test_context_copy_1I  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!   rZ   )numir   r'   s     r   subz/ContextTest.test_context_threads_1.<locals>.subg  sY    2Yq!

6>>%67  S1W5  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_1b  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   rX   r\   r`   rb   rn   rr   r   r   r   r   r   r   r   r   r   r   r   requires_working_threadingr   r@   r   r   r   r      s    2 ) )&"0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$    rzz		,r   c                 <    d| j                    d| j                   dS )Nz
<Key name:z hash:>)r"   r&   rM   s    r   __repr__zHashKey.__repr__  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&   rS   s     r   rU   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   rU   r@   r   r   r   r   y  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   rU   )r'   rT   r   s     r   rU   zKeyStr.__eq__  s1    'G,<,<,H,HMw~e$$r   )r=   r>   r?   r   rU   __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   rj   )r   r!   rz   r3   assertIsNotrv   rZ   )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!   rz   rZ   )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   rj      )r   r   r3   r!   rZ   rz   )	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* 	!&&(3(Q!&&(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   rk   r  Tr   r   z	not foundrj   r   )r   r   r   r   r   r#   r   r3   r   rZ   r!   rz   r   r   r   shuffle	enumeratedeleter   r   rW   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_stressG  s   
z"AAA?+Qi,,'d;!..|<EE#qM = < EE#qMN*'D9!..w7EE&), 8 : #  QQ0,,$$S^S^D$$S^S^D) ,, SV_5_-  vc{K!@#F . "%"89NNN>*&~6	Qi!11'd;!..|<HHSM = < /'D9!..w7HHVAY/ 8 : HHSM  sK!8+FcF  QQ0_11BB!11$$S]CMB$$S]CMB1 74 SVQ'SVQ'   C!12c7; SWc"g.#N33YYs3x(  C+!>Ls3x&  QQ0,,$$S_c!((*oF$$S_c!((*oF 4 SVQ'SVQ'T!'')_b1a # =< <; 87 :9. =< <; 87 :9s   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 comparerj   r  r   )
r   r   r3   rz   r#  r!   r   r   r   rZ   )r'   r2  r4  r  r  r  r9  r:  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 B HHQKQA.XXa[b!HHQKQA.q"r*q3'q3' BAs   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)Nr1  r2  ) r4  鉊 r  r6  r  r7  r  r8  r9  r:  r   r+   r   r(   r   r;  r<  r   rj   r  r   )	r   r   r3   rz   r   r   r#  r!   rZ   )
r'   r2  r4  r  r  r  r9  r:  r   r=  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 B HHQKQ*HHQKQA.HHQKQA.HHQKQA.q3'q3'HHQKHHQKHHQKHHQKQ#- BAs   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 )Nr1  r2  r3  r4   r  r  r7  r  r+   r   r(   r   r;  r   rj   )r   r   r3   rz   r#  r!   rZ   r'   r2  r4  r  r  r  r   r=  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 )Nr1  r2  r3  r4  rD  r  r  r  r+   r   r(   r   r;  r   rj   r     r   )r   r   r3   rz   r#  r!   rE  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   rj      r      r   )	r   r   r   rW   r2   r3   r!   rz   r#  )r'   r   r   r   r  collision_key16s         r   test_hamt_delete_5zHamtTest.test_hamt_delete_5P  sg   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 )Nr1  r2  r@  r4  rA  r  r6  r  r7  r  n   Fr+   r   r(   r   r;  rm   r   r   r3   r   r!   r   	r'   r2  r4  r  r  r  rV  r   its	            r   test_hamt_items_1zHamtTest.test_hamt_items_1  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 Nr1  r2  r3  r4  rD  r  r  r  rU  rV  r+   r   r(   r   r;  rm   rW  rX  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 r\  )r   r   r3   r!   r   r   )r'   r2  r4  r  r  r  rV  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!   rz   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 )Nr1  r2  r3  r4  rD  r  r  x   r  r+   r   r(   r   d2r;  )r   r   r3   assertFalse
assertTruer#  )r'   r2  r4  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)Nr1  r2  r:  r   r+   r<  )r   r   r3   r   r   )r'   r2  r:  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 B ##J0@A"H BA BA BAs   )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 )Nr1  r2  r   )	r   r   r3   weakrefrefr2   gccollectrv   )r'   r2  r   rl  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 )Nr1  r2  r3  r4  r+   )
r   r   r3   rk  rl  r   nextrm  rn  rv   )r'   r2  r4  r   rl  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	Nr1  r2  r3  r4  r   Tr   r  )	r   r   r3   rf  re  r#   r   r   r   r'   r2  AAr4  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 2 ( |,d3a 4 -, 21 ('
 43 -,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ru  )	r   r   r3   r!   r#   r   r   r   r   rv  s        r   test_hamt_getitem_1zHamtTest.test_hamt_getitem_1A  s    CS#CFEE!QK1q!2"x(aD ) w'D1" 2 ( |,d3" 4 -, )( 21 ('
 4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/  r>  rB  rF  rI  rS  rZ  r]  r_  ra  rg  ri  ro  rs  rx  rz  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   rm  r   r   unittestrk  testr   test.supportr   	_testcapir   ImportErrorr   TestCaser   r   rW   r   r   	Exceptionr   r   skipIfr   r=   mainr@   r   r   <module>r     s       	      )
X3(## X3|
B BB	%S 	%   	9 		i 	 BCY
x   Y
 DY
x zHMMO W"  Ds   C CC