
    ;eB                     j    	 d dl Z d dlZd dlmZ d dlmZmZ d dlmZm	Z	  G d dej
                  Z
dS )    N)
cmp_to_key)support	seq_tests)	ALWAYS_EQNEVER_EQc                        e 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d Zd Z fdZd Zd Zd Zd Zd Z fdZ fdZd Zd Zd Z xZS )
CommonTestc                    |                      |                     g           |                                            |                     g d          }|                                 |                      ||                     g                      |                     g d          }|                    g d           |                      ||                     g d                     |                     |          }|                     t	          |          t	          |                     |                      ||           d S )N         )         )assertEqual	type2test__init__assertNotEqualidselfabs      &/usr/lib/python3.11/test/list_tests.py	test_initzCommonTest.test_init   s   ++T^^-=-=>>> NN999%%	

DNN2../// NN999%%	

999DNN99955666 NN1BqEE2a55)))A    c                     g }d}|                      t          |          5  |d          d d d            d S # 1 swxY w Y   d S )N'list indices must be integers or slicesr   assertRaisesRegex	TypeErrorr   r   msgs      r   test_getitem_errorzCommonTest.test_getitem_error"   s    7##Is33 	 	cFF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   	6::c                     g }d}|                      t          |          5  d|d<   d d d            d S # 1 swxY w Y   d S )Nr   pythonr   r    r#   s      r   test_setitem_errorzCommonTest.test_setitem_error(   s    7##Is33 	 	AcF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   377c                    g }g d}|                      |          }|                      |          }|                     t          |          t          |                     |                     t          |          t          |                     |                     t          |          t          |                     |                     t          |          d           |                     t          |          d           |                    |           |                    d           |                     t          |          d           |                     t          |          d           d S )Nr   r   r   z	[0, 1, 2]r   z[0, 1, 2, [...], 3])r   r   strreprappend)r   l0l2a0a2s        r   	test_reprzCommonTest.test_repr.   s.   YY^^B^^BR#b''***b488,,,b488,,,R+...b;///
		"
		!R"7888b#899999r   c                     |                      g           }t          t          j                    dz             D ]}|                      |g          }|                     t
          t          |           d S )Nd   )r   rangesysgetrecursionlimitassertRaisesRecursionErrorr,   )r   r   is      r   test_repr_deepzCommonTest.test_repr_deep?   sk    NN2s,..455 	$ 	$As##AA.$22222r   c           	      <   |                      t          d                    }|                     t          |j        t          ddd          g d           |                     t          |j        t          dd          d           |                     t          |j        t          ddd          ddg           |                     t          |j        dd           g d|t          ddd          <   |                     ||                      g d	                     d S )
N   r   
   r   r   r   xr   )r   r   r   r   r   r   r      r   	   r>                              )	r   r5   r8   
ValueError__setitem__slicer"   __getitem__r   r   r   s     r   test_set_subscriptzCommonTest.test_set_subscriptE   s   NN599%%*amU1b!__gggNNN)Q]E!RLL!DDD*amU1b!__qeLLL)Q]C;;;"77%"Q--DNN ,< ,< ,< = = 	> 	> 	> 	> 	>r   c           
      <   |                      t          d                    }t          |          }|                     t	          |          |                      t          ddd                               |                     t          t          |           |                     t	          t          |                                                      |                                             |                     t          t          t          g d                     d S )Nr=   rJ   r   )
r   r5   reversedr   listr8   StopIterationnextr"   len)r   r   rs      r   test_reversedzCommonTest.test_reversedP   s    NN599%%QKKa$..r2r1B1B"C"CDDD-q111ht~~'7'78899))	+ 	+ 	+ 	)S(777*;*;<<<<<r   c                 8   |                      ddg          }d|d<   d|d<   |                     ||                      ddg                     d|d<   |                     ||                      ddg                     d|d<   |                     ||                      ddg                     |                     t          |j        dd           |                     t          |j        dd           |                      g           }|                     t          |j        dd           |                     t          |j        dd           |                     t
          |j                   |                      g d	          }d|d<   d|d<   d
|d<   |                     ||                      g d                     d|d<   d|d<   d|d<   |                     ||                      g d                     d|d<   d|d<   |                     ||                      g d                     d|d<   d|d<   |                     ||                      g d                     d}|                     t
          |          5  d|d<   d d d            d S # 1 swxY w Y   d S )Nr   r   r4      rR   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r@   )r   r   r@   r   r   X   c   )r   r   r@   r_   r`      rA   )r   r   r@   ra   rA   r   r'   r   )r   r   r8   
IndexErrorrL   r"   r!   r#   s      r   test_setitemzCommonTest.test_setitemZ   s   NNAq6""!!DNNAs844555"DNNAs844555"DNNC:66777*amR===*amQ<<<NN2*amQ<<<*amR===)Q]333NN;;;''!!!DNN;;;77888!!!DNN;;;77888""DNN===99:::""DNN;;;778887##Is33 	 	AcF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   <JJJc                    |                      ddg          }|d= |                     |dg           |d= |                     |g            |                      ddg          }|d= |                     |dg           |d= |                     |g            |                      ddg          }|                     t          |j        d           |                     t          |j        d           |                      g           }|                     t          |j        d           |                     t
          |j                   d S )Nr   r   r\   rR   r]   r   )r   r   r8   rb   __delitem__r"   rO   s     r   test_delitemzCommonTest.test_delitem   s6   NNAq6""aDQC   aDBNNAq6""bEQC   bEBNNAq6""*amR888*amQ777NN2*amQ777)Q]33333r   c           	      >   ddg}|                      |          }t          dd          D ]}|d |         |d |<   |                     ||           |d d          }|d |         |d |<   |                     ||           ||d          ||d <   |                     ||           |d d          }||d          ||d <   |                     ||           t          dd          D ]V}|||         |||<   |                     ||           |d d          }|||         |||<   |                     ||           W|d d          }ddg|d d<   |                     |g d           g |dd <   |                     |g            |                      g d          }||d d<   |                     ||                      g d	                     |                      g d          }||dd <   |                     ||                      g d
                     |                      g d          }||dd<   |                     ||                      g d                     |                      g           }t          t          d                    |d d <   |                     ||                      t          d                               |                     t
          |j        t          ddd                     |                     t
          |j                   d S )Nr   r   r]   r   r\   rR   )r\   rR   r   r   )r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   r   r>   r   )r   r5   r   tupler8   r"   rL   rM   )r   lr   r:   r1   jaa2s          r   test_setslicezCommonTest.test_setslice   sO   FNN1r1 	( 	(AbqbEAbqbEQ"""111BrrUBrrFR###abbEAabbEQ"""111BqrrUBqrrFR###2q\\ ( (1Q3!A#  A&&&qqqTAaC&1Q3  Q''''( er(BQBnnn---ABBb!!!NN???++#2#DNN+=+=+=>>???NN???++!""DNN+=+=+=>>???NN???++!B$DNN+@+@+@AABBBNN2U2YY!!!DNN59955666)Q]E!QNNCCC)Q]33333r   c                    |                      ddg          }|dd= |dd= |                     ||                      g                      |                      ddg          }|dd= |dd= |                     ||                      g                      |                      ddg          }|dd= |                     ||                      dg                     |                      ddg          }|dd= |                     ||                      dg                     |                      ddg          }|dd = |d d= |                     ||                      g                      |                      ddg          }|dd = |d d= |                     ||                      g                      |                      ddg          }|dd = |                     ||                      dg                     |                      ddg          }|dd = |                     ||                      dg                     |                      ddg          }|d d = |                     ||                      g                      d S )Nr   r   r   r\   rR   )r   r   rO   s     r   test_delslicezCommonTest.test_delslice   s   NNAq6""acFacFDNN2..///NNAq6""acFacFDNN2..///NNAq6""beHDNNA3//000NNAq6""beHDNNA3//000NNAq6""abbEbqbEDNN2..///NNAq6""abbEbqbEDNN2..///NNAq6""bccFDNNA3//000NNAq6""bccFDNNA3//000NNAq6""aaaDDNN2../////r   c                 D   |                      g           }|                    d           |                    d           |                    d           |                     ||                      g d                     |                     t          |j                   d S )Nr   r   r   r*   )r   r-   r   r8   r"   rO   s     r   test_appendzCommonTest.test_append   s    NN2			DNN99955666)QX.....r   c                    |                      dg          }|                      d          }|d d          }|                    |           |                     |||z              |                    |                      g                      |                     |||z              |                    |           |                     ||                      g d                     |                      d          }|                    d           |                     |t          d                     |                     t
          |j        d            |                     t
          |j                    G d d          }|                      g d	          }|                     |                       |                     |g d	           d S )
Nr   )r   r   )r   r   r   r   r   r   spameggsspameggsc                        e Zd Zd Zd Zd ZdS )*CommonTest.test_extend.<locals>.CustomIterc                     | S N r   s    r   __iter__z3CommonTest.test_extend.<locals>.CustomIter.__iter__  s    r   c                     t           rx   )rU   rz   s    r   __next__z3CommonTest.test_extend.<locals>.CustomIter.__next__  s    ##r   c                     t           j        S rx   )r6   maxsizerz   s    r   __length_hint__z:CommonTest.test_extend.<locals>.CustomIter.__length_hint__  s
    {"r   N)__name__
__module____qualname__r{   r}   r   ry   r   r   
CustomIterrv   
  sA          $ $ $# # # # #r   r   )r   r   r   r   )r   extendr   rT   r8   r"   )r   a1r1   r   r   s        r   test_extendzCommonTest.test_extend   s   ^^QC  ^^F##qqqE	BG$$$	##$$$BG$$$	DNN+=+=+=>>???NN6""	D,,---)QXt444)QX...	# 	# 	# 	# 	# 	# 	# 	# NN999%%	III&&&&&r   c                    |                      g d          }|                    dd           |                    dd           |                    dd           |                     |g d           |d d          }|                    dd           |                    d	d
           |                    dd           |                     ||                      g d                     |                     t          |j                   d S )Nr*   r   r\   r   rR   r   r\   rR   r   r   r   r   fooi8leftr[   right)	r   r\   rR   r   r   r   r   r   r   )r   insertr   r8   r"   r   s      r   test_insertzCommonTest.test_insert  s    NN999%%	B	B	A000111aaaD	U	v	gDNN+O+O+OPPQQQ)QX.....r   c                 .   |                      g d          }|                                 |                     |ddg           |                    d           |                     |dg           |                     t          |j        d           |                    d           |                     |g            |                     t          |j                   |                     t
          |j        dd           |                      g d          }d S )N)rR   r   r   rR   r   r   *   )r   r>   r=      (   )r   popr   r8   rb   r"   rO   s     r   test_popzCommonTest.test_pop%  s    NN:::&&	RG$$$	aQC   *aeQ///	aB*ae,,,)QUB333NN...//r   c                    |                      g d          }|                    d           |                     |ddg           |                    d           |                     |dg           |                    d           |                     |g            |                     t          |j        d           |                     t
          |j                   |                      ddg          }|                     t          |j        t                     |                     |ddg           |                    t                     |                     |dg           |                      t          g          }|                    d           |                     |g            |                      t          g          }|                    t                     |                     |g            |                      t          g          }|                     t          |j        t                      G d dt                     G fdd          }|                      g d	          }|                     |j         |                        G fd
d          }|                      d          }|                    d           |                     ||                      d                     |                    d           |                     ||                      d                     |                     t          |j        d           |                     ||                      d                     |                      dd |            dg          }|                      |          }|                     |j        d           t          ||          D ]\  }}| 
                    ||           d S )N)r   r   r   r   r   r   c                       e Zd ZdS )&CommonTest.test_remove.<locals>.BadExcN)r   r   r   ry   r   r   BadExcr   M  s        Dr   r   c                       e Zd Z fdZdS )&CommonTest.test_remove.<locals>.BadCmpc                 (    |dk    r
             dS )Nr   Fry   r   otherr   s     r   __eq__z-CommonTest.test_remove.<locals>.BadCmp.__eq__Q  s    A:: &((Nur   Nr   r   r   r   r   s   r   BadCmpr   P  s.              r   r   )r   r   r   r   c                       e Zd Z fdZdS )'CommonTest.test_remove.<locals>.BadCmp2c                                  rx   ry   r   s     r   r   z.CommonTest.test_remove.<locals>.BadCmp2.__eq__Z  s    fhhr   Nr   r   s   r   BadCmp2r   Y  s.              r   r   abcdefghcijc
abdefghcij	abdefghijr   r   )r   remover   r8   rK   r"   r   r   	ExceptionzipassertIs)	r   r   r   r   der?   yr   s	           @r   test_removezCommonTest.test_remove2  s   NN999%%	QF###	QC   	B*ah222)QX...NNAq6""*ah999QF###	QC   NNI;''	BNNI;''	BNNH:&&*ah	:::	 	 	 	 	Y 	 	 		 	 	 	 	 	 	 	 	 	 NN<<<((&!(FFHH555	 	 	 	 	 	 	 	 	 	 NN=))	DNN<88999	DNN;77888*ah444DNN;77888 NNCggii566NN1&!(C0001II 	  	 DAqMM!Q	  	 r   c                    t                                                       |                     g d                              d           |                     t
          j        ddd           |                     |                     g d                      G d d          |                                 fdt          d	          D             d d <   |                     t
          j        d            d S )
Nr   r   r   r   r\   rR   r   r   r   c                       e Zd Zd Zd ZdS )&CommonTest.test_index.<locals>.EvilCmpc                     || _         d S rx   victim)r   r   s     r   r   z/CommonTest.test_index.<locals>.EvilCmp.__init__v  s    $r   c                     | j         d d = dS )NFr   )r   r   s     r   r   z-CommonTest.test_index.<locals>.EvilCmp.__eq__x  s    KNur   N)r   r   r   r   r   ry   r   r   EvilCmpr   u  s2        % % %    r   r   c                 &    g | ]}           S ry   ry   ).0_r   r   s     r   
<listcomp>z)CommonTest.test_index.<locals>.<listcomp>|  s!    ///q

///r   r4   )	super
test_indexr   r   r8   rK   indexr   r5   )r   r   r   	__class__s    @@r   r   zCommonTest.test_indexm  s   NN///00	*agq!Q777DNN+<+<+<==>>>	 	 	 	 	 	 	 	 NN/////E#JJ///!!!*agt44444r   c                 6   |                      g d          }|d d          }|                                 |                     |g d           |                                 |                     ||           |                     t          |j        d           d S )Nr   r   r   r   rR   r\   r   )r   reverser   r8   r"   )r   uu2s      r   test_reversezCommonTest.test_reverse  s    NN,,,--qqqT			---...			B)QY33333r   c                    |                      g d          }|                                 |                     |g            |                      g           }|                                 |                     |g            |                      g           }|                    d           |                                 |                    d           |                     |dg           |                     t
          |j        d            d S )N)r   r   r   r   r   )r   clearr   r-   r8   r"   r   r   s     r   
test_clearzCommonTest.test_clear  s    NN999%%				BNN2				BNN2						QC   )QWd33333r   c                    |                      g d          }|                                }|                     |g d           |                      g           }|                                }|                     |g            |                      ddg          }|                                }|                    d           |                     |ddg           |                     ||dgz              |                      ddddgd	g          }|                                }|                     ||           |                     |d         |d                    |                     t          |j        d            d S )
Nr   r   r   r:   r   r   r   r   r   )r   copyr   r-   r   r8   r"   )r   r   vs      r   	test_copyzCommonTest.test_copy  sZ   NN999%%FFHHIII&&&NN2FFHHB NNC:&&FFHH	S#J'''AI&&& NNAq1a&!,--FFHHAadAaD!!!)QVT22222r   c                    |                      ddg          }|                                 |                     |ddg           |                      g d          }|                                 |                     ||                      g d                     |                     t          |j        dd           d }|                    t          |                     |                     ||                      g d                     d }|                      t          d	                                        t          |                     |                     t          j        d
           fd}|                     t          j        t          |                     |                     t          j        dddd           d S )Nr   r   r   r   r   c                 &    | |k    rdS | |k     rdS dS )Nr   r   rR   ry   )r   r   s     r   revcmpz$CommonTest.test_sort.<locals>.revcmp  s#    AvvqQqrr   )keyc                 :    | dz  |dz  }}||k    rdS ||k     rdS dS )Nr   r@   r   rR   r   ry   )r?   r   xmodymods       r   myComparisonz*CommonTest.test_sort.<locals>.myComparison  s4    1ac$Dt||qrqr   rC   r   c                 R                         d           | |k    rdS | |k     rdS dS )Nr   r   rR   )r-   )r?   r   zs     r   selfmodifyingComparisonz5CommonTest.test_sort.<locals>.selfmodifyingComparison  s3    HHQKKKAvvqQrqr   )r   sortr   r8   r"   r   r5   rK   )r   r   r   r   r   r   s        @r   	test_sortzCommonTest.test_sort  s   NNAq6""	QF###NN===))	DNN===99:::)QVR444	 	 	 	
:f%%&&&DNN===99:::	 	 	 NN599%%	:l++,,,)QVQ///	 	 	 	 	 	*af()@AA 	 	C 	C 	C 	)QVRR<<<<<r   c                     |                      d          }d|d d<   |                     |t          d                     d S )Nrr   hr   ham)r   r   rT   r   s     r   
test_slicezCommonTest.test_slice  sB    NN6"""1"DKK(((((r   c                 |   t                                                       |                     ddg          }|}|ddgz  }|                     ||           |                     d          }|dz  }|                     ||                     d                     |                     t          |j        d            d S )Nr   r   r   r   rr   rs   rt   )r   	test_iaddr   r   r   r8   r"   __iadd__)r   r   r   r   s      r   r   zCommonTest.test_iadd  s    NNAq6""	aVaNN6""	VDNN:66777)QZ66666r   c                     t                                                       |                     g           }t          |          }|dz  }|                     t          |          |           d S )Nr>   )r   	test_imulr   r   r   )r   soldidr   s      r   r   zCommonTest.test_imul  s`    NN21	RA&&&&&r   c                 N   |                      g d          }|d d d= |                     ||                      ddg                     |                      t          d                    }|dd d= |                     ||                      g d                     |                      t          d                    }|dd d= |                     ||                      g d                     |                      t          d	                    }|d d d
= |                     ||                      g d                     |                      t          d	                    }dgdz  |d d d<   |                     ||                      g d                     |                      t          d	                    }d	gdz  |d d d<   |                     ||                      g d                     |                      t          d                    }||d d d<   |                     ||                      g d                     |                      t          d	                    }|d d          }|d d          }|                      ddg          |dd<   |                      ddg          |t          dd          <   |                      ddg          |dd<   |                     ||           |                     ||           |                      t          d	                    }t	          t          d                    |d d d<   |                     ||                      g d                     |                      t          d	                    }|dd ddz  = d S )Nr^   r   r   r   r   )r   r   r   r\   )r   r   r   r   r>   i  )	r   r   r   r   r   r   r@   ra   rA   rR   )
rR   r   rR   r   rR   r   rR   r@   rR   rA   )
r   r>   r   r   r   r>   r   r@   ra   r>   r   )r   r   r   r   twoelements)
r   r   r   r   r   r   r   r@   r   rA   rA   iM  )r   r   r5   rM   rh   )r   r   r   r   s       r   test_extendedslicingzCommonTest.test_extendedslicing  se   NN;;;'' cccFDNNAa511222NN588$$addGDNN77733444NN588$$aeeHDNN99955666NN599%%fffIDNN+F+F+FGGHHHNN599%%a##A#DNN+N+N+NOOPPPNN599%%$q&$$B$DNN+L+L+LMMNNNNN588$$$$B$DNN<<<88999NN599%%aaaDaaaD
 344!A#z':;;%!**..%!455!A$AANN599%%uQxx##A#DNN+I+I+IJJKKKNN599%%aiCiLLLr   c                 ~     G d dt                     }|                     t          t           |                       d S )Nc                       e Zd Zd ZdS )9CommonTest.test_constructor_exception_handling.<locals>.Fc                     t           rx   )KeyboardInterruptrz   s    r   r{   zBCommonTest.test_constructor_exception_handling.<locals>.F.__iter__(  s    ''r   N)r   r   r   r{   ry   r   r   Fr   '  s#        ( ( ( ( (r   r   )objectr8   r   rT   )r   r   s     r   #test_constructor_exception_handlingz.CommonTest.test_constructor_exception_handling%  sS    	( 	( 	( 	( 	( 	( 	( 	( 	+T113377777r   c                    |                      g d          }t          |          }t          |          }|D ]}t          |           |                    d           |                     t          |          g            |                     t          |          dg           |                     ||                      g d                     d S )Nr   rA   )r   r   r   rA   )r   iterrV   r-   r   rT   )r   r   exhitempitr?   s        r   test_exhausted_iteratorz"CommonTest.test_exhausted_iterator,  s    NN999%%QQ 	 	AKKKK	eb)))eqc***DNN<<<8899999r   )r   r   r   r   r%   r(   r2   r;   rP   rY   rc   rf   rl   rn   rp   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__)r   s   @r   r	   r	      s         &    : : :"3 3 3	> 	> 	>= = =# # #J4 4 4,,4 ,4 ,4\'0 '0 '0R/ / /' ' 'B/ / /0 0 09  9  9 v5 5 5 5 5&4 4 44 4 4"3 3 30.= .= .=`) ) )
7 7 7 7 7' ' ' ' '' ' 'R8 8 8	: 	: 	: 	: 	: 	: 	:r   r	   )r6   os	functoolsr   testr   r   test.supportr   r   r	   ry   r   r   <module>r      s    


 				             # # # # # # # # , , , , , , , ,h: h: h: h: h:% h: h: h: h: h:r   