HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_sort.cpython-310.pyc
o

�i�5�@s�ddlmZddlZddlZddlmZejZdaddd�ZGdd�dej	�Z
Gdd	�d	ej	�ZGd
d�dej	�Zdd
�Z
Gdd�dej	�ZedkrPe��dSdS)�)�supportN��
cmp_to_keycCs�trtd|�|dd�}|r|jt|�d�n|��t|�t|�krEtd|�tdt|�t|��t|�t|�t|�td7adSt|�D]+\}}||}||urttd|�td|||�t|�t|�t|�td7adSqIdS)Nz    checking��keyzerror inzlength mismatch;�zout of order at index)�verbose�print�sortr�len�nerrors�	enumerate)�tagZexpected�rawZcompareZorig�iZgood�maybe�r�+/usr/local/lib/python3.10/test/test_sort.py�check
s4


��rc@�eZdZdd�ZdS)�TestBasec
	s@dg}tdd�D]}d|}|�t|d|d��q|�gd��G�fdd�dt��Gdd	�d	t��|D]�}tt|��}trEtd
|�|dd�}td||�|dd�}|��td||�|dd�}t�	|�td
||�|dd�}|��|dd�}td||dd��tr�td�td�|dd�}|j
tdd��d�td||�t|�dkr�dd�}|dd�}|j
t|j
|d��fdd�|D�}|dd�}t�	|�d�_d}z|�
�Wnty�d}Ynw|r�d�_td||��fdd�t|�D�}dd�|D�}	|	�
�dd�|	D�}td ||�q6dS)!Nrr�
�)r�di�cs,eZdZdZdd�Z�fdd�Zdd�ZdS)	z+TestBase.testStressfully.<locals>.ComplainsTcSs
||_dS�N�r)�selfrrrr�__init__6�
z4TestBase.testStressfully.<locals>.Complains.__init__cs2�jrt��dkrtrtd||�t�|j|jkS)Ng����MbP?z        complaining at)�maybe_complain�randomrr	�RuntimeErrorr�r�other��	Complainsrr�__lt__9s
z2TestBase.testStressfully.<locals>.Complains.__lt__cSs
d|jS)Nz
Complains(%d)r�rrrr�__repr__@rz4TestBase.testStressfully.<locals>.Complains.__repr__N)�__name__�
__module__�__qualname__rrr&r(rr$rrr%3s
r%c@s$eZdZdd�Zdd�Zdd�ZdS)z(TestBase.testStressfully.<locals>.StablecSs||_||_dSr�r�index)rrrrrrrDs
z1TestBase.testStressfully.<locals>.Stable.__init__cSs|j|jkSrrr"rrrr&Hsz/TestBase.testStressfully.<locals>.Stable.__lt__cSsd|j|jfS)NzStable(%d, %d)r,r'rrrr(K�z1TestBase.testStressfully.<locals>.Stable.__repr__N)r)r*r+rr&r(rrrr�StableCsr/zTesting size�identity�reversedzrandom permutationzreversed via functioncSs||k||kSrr��a�brrr�<lambda>asz*TestBase.testStressfully.<locals>.<lambda>z3    Checking against an insane comparison function.z?        If the implementation isn't careful, this may segfault.cSstt��d�dS)N�r)�intr r2rrrr5g�rz(an insane function left some permutationcS�t�r�r!��xrrr�bad_keyk�z)TestBase.testStressfully.<locals>.bad_keycsg|]}�|��qSrr��.0rr$rr�
<listcomp>pr8z,TestBase.testStressfully.<locals>.<listcomp>TFz+exception during sort left some permutationcsg|]
}�t�d�|��qS)r�r �	randranger?)r/rrrA}�cSsg|]}||jf�qSr)r-)r@�errrrA~scSsg|]\}}|�qSrr)r@rErrrrrA�r8Z	stability)�range�extend�object�listrr	r�reverser �shuffler
rr�assertRaisesr!r)
rZsizesZpower�nr<�s�yr=Z
it_complainedZ	augmentedr)r%r/r�testStressfully+sh


��zTestBase.testStressfullyN)r)r*r+rPrrrrr*�rc@seZdZdd�Zdd�ZdS)�TestBugscs:G�fdd�d���fdd�td�D��|�t�j�dS)NcseZdZ�fdd�ZdS)z"TestBugs.test_bug453523.<locals>.Ccs0�r
t��dkr
���n��d�t��dkS)Ng�?r6g�?)r �pop�appendr"��Lrrr&�s

z)TestBugs.test_bug453523.<locals>.C.__lt__N�r)r*r+r&rrUrr�C�srXcsg|]}���qSrrr?)rXrrrA��z+TestBugs.test_bug453523.<locals>.<listcomp>�2)rFrL�
ValueErrorr
r'r)rXrVr�test_bug453523�szTestBugs.test_bug453523cshg}td�D]+}�fdd�}ddg�|jt�jt|�d��fdd�}|jt�jt|�d�|g}qdS)N�cs"��d����||k||kS�Nr6)rTrS�r<rOrUrr�mutating_cmp�s
z7TestBugs.test_undetected_mutation.<locals>.mutating_cmprrrcs$��d��dd�=||k||kSr^)rTr_rUrrr`�s

)rFrLr[r
r)rZmemorywasterrr`rrUr�test_undetected_mutation�s�z!TestBugs.test_undetected_mutationN)r)r*r+r\rarrrrrR�srRc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�TestDecorateSortUndecoratecCsHd��}|dd�}t�|�|jtjd�dd�}|jt|�d�dS)N�,The quick Brown fox Jumped over The lazy DogrcSs"|��|��}}||k||kSr)�lower)r<rOZxlowerZylowerrrr�my_cmp��z9TestDecorateSortUndecorate.test_decorated.<locals>.my_cmp)�splitr rKr
�strrdr)r�data�copyrerrr�test_decorated�s
z)TestDecorateSortUndecorate.test_decoratedcCs"d��}|jt|jdd�d�dS)NrccSsdS�Nrrr_rrrr5�sz>TestDecorateSortUndecorate.test_baddecorator.<locals>.<lambda>r)rgrL�	TypeErrorr
�rrirrr�test_baddecorator�sz,TestDecorateSortUndecorate.test_baddecoratorcCsFdd�td�D�}|dd�}|jdd�d�|��|�||�dS)NcS�g|]	}t�d�|f�qS�rrBr?rrrrA��z=TestDecorateSortUndecorate.test_stability.<locals>.<listcomp>��cS�|dSrlr)�trrrr5��z;TestDecorateSortUndecorate.test_stability.<locals>.<lambda>r)rFr
�assertEqual)rrirjrrr�test_stability�s
z)TestDecorateSortUndecorate.test_stabilitycCs@ttdd��}|dd�}|jt|jdd�d�|�||�dS)N���rcSsd|S)Nrrr;rrrr5�rvzDTestDecorateSortUndecorate.test_key_with_exception.<locals>.<lambda>r)rIrFrL�ZeroDivisionErrorr
rw)rri�duprrr�test_key_with_exception�sz2TestDecorateSortUndecorate.test_key_with_exceptioncs.ttd����fdd�}|jt�j|d�dS)Nrcs�dd�=td��dd�<|S�Nr]�rFr;�rirr�k�s
z<TestDecorateSortUndecorate.test_key_with_mutation.<locals>.kr)rIrFrLr[r
)rr�rrr�test_key_with_mutation�sz1TestDecorateSortUndecorate.test_key_with_mutationc�6ttd���G�fdd�dt�}|jt�j|d�dS)Nrcs(eZdZdd�Z�fdd�Zdd�ZdS)zITestDecorateSortUndecorate.test_key_with_mutating_del.<locals>.SortKillercSsdSrr�rr<rrrr�r>zRTestDecorateSortUndecorate.test_key_with_mutating_del.<locals>.SortKiller.__init__cs�dd�=td��dd�<dSr}r~r'rrr�__del__�s
zQTestDecorateSortUndecorate.test_key_with_mutating_del.<locals>.SortKiller.__del__cSst|�t|�kSr)�idr"rrrr&�r.zPTestDecorateSortUndecorate.test_key_with_mutating_del.<locals>.SortKiller.__lt__N)r)r*r+rr�r&rrrr�
SortKiller�sr�r)rIrFrHrLr[r
�rr�rrr�test_key_with_mutating_del�sz5TestDecorateSortUndecorate.test_key_with_mutating_delcr�)Nrcs eZdZdd�Z�fdd�ZdS)zWTestDecorateSortUndecorate.test_key_with_mutating_del_and_exception.<locals>.SortKillercSs|dkrt�dS)Nrr:r�rrrr�s�z`TestDecorateSortUndecorate.test_key_with_mutating_del_and_exception.<locals>.SortKiller.__init__cs"�dd�=ttd���dd�<dSr})rIrFr'rrrr��s
z_TestDecorateSortUndecorate.test_key_with_mutating_del_and_exception.<locals>.SortKiller.__del__N)r)r*r+rr�rrrrr��sr�r)rIrFrHrLr!r
r�rrr�(test_key_with_mutating_del_and_exception�szCTestDecorateSortUndecorate.test_key_with_mutating_del_and_exceptioncCs>ttd��}t�|�|jdd�|�|ttddd���dS)NrT)rJ�c���)rIrFr rKr
rwrnrrr�test_reverse�s
z'TestDecorateSortUndecorate.test_reversecCs�dd�td�D�}|dd�}|dd�}dd�}dd�}|jt|�dd	�|jt|�d
�|�||�|jdd�dd	�|�||�dS)
NcSrprqrBr?rrrrA�rrzETestDecorateSortUndecorate.test_reverse_stability.<locals>.<listcomp>rscSs"|d|d}}||k||kSrlr�r<rOZx0Zy0rrrre�rfzATestDecorateSortUndecorate.test_reverse_stability.<locals>.my_cmpcSs"|d|d}}||k||kSrlrr�rrr�my_cmp_reversed�rfzJTestDecorateSortUndecorate.test_reverse_stability.<locals>.my_cmp_reversedT)rrJrcSrtrlrr;rrrr5rvzCTestDecorateSortUndecorate.test_reverse_stability.<locals>.<lambda>)rFr
rrw)rriZcopy1�copy2rer�rrr�test_reverse_stability�sz1TestDecorateSortUndecorate.test_reverse_stabilityN)r)r*r+rkrorxr|r�r�r�r�r�rrrrrb�s
rbc	Cs�t�d�t�|�|dd�}dd�|D�}dd�|D�}|||fD]$}t|�}dd�tdd�|D��D�}t||�D]
\}}|�||�q<q#dS)NrcS�g|]}|f�qSrr�r@r<rrrrArYz:check_against_PyObject_RichCompareBool.<locals>.<listcomp>cS�g|]}|ff�qSrrr�rrrrAr8cSsg|]}|d�qS)rr)r@rOrrrrAr8cSsg|]}d|f�qS)rrr�rrrrAr8)r �seedrK�sorted�zipZassertIs)	rrVZL_1ZL_2ZL_3Z	optimizedZ	reference�opt�refrrr�&check_against_PyObject_RichCompareBools

��r�c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�TestOptimizedComparescCs�ddgddgddgg}|D]!}|�t|j�|�tdd�|D�j�|�tdd�|D�j�q
dd	gd
d	gd	dgd	d
gg}|D]}t||�q?dS)Nr�foog)r�cSr�rrr�rrrrA*rYzBTestOptimizedCompares.test_safe_object_compare.<locals>.<listcomp>cSr�rrr�rrrrA+r8rg�������?�)rLrmr
r�)rZheterogeneous_listsrVZfloat_int_listsrrr�test_safe_object_compare$s ���z.TestOptimizedCompares.test_safe_object_comparecs�G��fdd�dt��Gdd�dt��Gdd�dt����fdd�td	�D�}|d
�|�t��|��Wd�n1s?wY��fdd�td	�D�}|d
�|�t��dd�|D���Wd�n1smwYGd
d�d�}|�|�g}|�t|j�|�tdd�|D�j�ttd��dgdd�td�D�dgdd�td�D�dd�td�D�g}|D]}t||�q�dS)NcseZdZ��fdd�ZdS)zITestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyComparatorcs��_t�||�Sr)�	__class__r7r&r"��
WackyList2�elemrrr&:szPTestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyComparator.__lt__NrWrr�rr�WackyComparator9sr�c@seZdZdS)zDTestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyList1N)r)r*r+rrrr�
WackyList1>sr�c@r)zDTestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyList2cSr9r)r[r"rrrr&Br>zKTestOptimizedCompares.test_unsafe_object_compare.<locals>.WackyList2.__lt__NrWrrrrr�ArQr�c�g|]
}��|�|g��qSrrr?�r�r�rrrAErDzDTestOptimizedCompares.test_unsafe_object_compare.<locals>.<listcomp>rr�cr�rrr?r�rrrAJrDcSr�rrr�rrrrAMrYc@r)zMTestOptimizedCompares.test_unsafe_object_compare.<locals>.PointlessComparatorcSstSr)�NotImplementedr"rrrr&Rr>zTTestOptimizedCompares.test_unsafe_object_compare.<locals>.PointlessComparator.__lt__NrWrrrr�PointlessComparatorQrQr�cSr�rrr�rrrrAVrYrr�cS�g|]}t|��qSr�rhr�rrrrA[r8u￿cSr�r)�bytesr�rrrrA\r8cSsg|]
}tdd��|��qS)cSs||kSrrr_rrrr5]rvzMTestOptimizedCompares.test_unsafe_object_compare.<locals>.<listcomp>.<lambda>rr�rrrrA]rD)r7rIrFrLr[r
rmr�)rrVr�Zlistsr)r�r�r�r�r�test_unsafe_object_compare4s2
����z0TestOptimizedCompares.test_unsafe_object_comparecC�t|dd�td�D��dS)NcSr�rr�r�rrrrAb��zCTestOptimizedCompares.test_unsafe_latin_compare.<locals>.<listcomp>r�r�rFr'rrr�test_unsafe_latin_comparea�
�z/TestOptimizedCompares.test_unsafe_latin_comparecCr�)NcSsg|]}|�qSrrr�rrrrAfs�zBTestOptimizedCompares.test_unsafe_long_compare.<locals>.<listcomp>rr�r'rrr�test_unsafe_long_compareer�z.TestOptimizedCompares.test_unsafe_long_comparecCr�)NcSr�r��floatr�rrrrAjr�zCTestOptimizedCompares.test_unsafe_float_compare.<locals>.<listcomp>rr�r'rrr�test_unsafe_float_compareir�z/TestOptimizedCompares.test_unsafe_float_comparecCs0t|td�gd�t|dd�td�D��dS)N�nanrcSsg|]}td��qS)r�r�)r@�_rrrrAvr�zCTestOptimizedCompares.test_unsafe_tuple_compare.<locals>.<listcomp>)r�r�rFr'rrr�test_unsafe_tuple_comparems
�z/TestOptimizedCompares.test_unsafe_tuple_comparecCs:|�tgd�j�|�tddgj�|�tddgj�dS)N))��?r�)F�A�)r3r)rr3)rLrmr
r'rrr�test_not_all_tuplesysz)TestOptimizedCompares.test_not_all_tuplesN)
r)r*r+r�r�r�r�r�r�r�rrrrr�#s-r��__main__r)�testrr Zunittest�	functoolsrrrrZTestCaserrRrbr�r�r)�mainrrrr�<module>s
 [%]\�