HEX
Server: Apache
System: Linux opal14.opalstack.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User: curbgloabal_opal (1234)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/python3.6/test/__pycache__/test_hash.cpython-36.pyc
3


 \�-�@s�ddlZddlZddlZddlZddlmZddlmZejd9kZ	d:dd�Z
d	d
�Zdd�ZGd
d�dej
�ZejZGdd�de�ZdZGdd�de�ZGdd�de�ZGdd�de�ZGdd�dee�ZGdd�dee�ZGdd�de�ZGdd�dej
�ZGd d!�d!e�ZGd"d#�d#ej
�ZGd$d%�d%�ZGd&d'�d'e�ZGd(d)�d)eej
�ZGd*d+�d+eej
�Z Gd,d-�d-eej
�Z!Gd.d/�d/e�Z"Gd0d1�d1e"ej
�Z#Gd2d3�d3e"ej
�Z$Gd4d5�d5e"ej
�Z%Gd6d7�d7ej
�Z&e'd8k�r�ej(�dS);�N)�assert_python_ok)�Hashable�� �cCsR|dkrt|�St|�}x0t|�D]$}d|dd@}|d?d@||<q"Wt|�S)zLinear congruential generatorri�CiÞ&i���r�)�bytes�	bytearray�range)�x�length�out�i�r�!/usr/lib64/python3.6/test_hash.py�lcgsrcCs`d|kodknst�|d
kr.|d}n|}||d?Ad@}|d
krT|d}n|}||fS)z*Convert SipHash24 output to Py_hash_t
    r��@�?rl���lll����lli���l)�AssertionError)Zuint64Zint64Zuint32Zint32rrr�	pysiphashs

rcCs&tjjdk}d}|r|Stj|�|�S)z8Skip decorator for tests that depend on SipHash24 or FNV�fnv�	siphash24zRequires SipHash24 or FNV>rr)�sys�	hash_info�	algorithm�unittest�skip)Ztest�ok�msgrrr�skip_unless_internalhash+sr!c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�HashEqualityTestCasecGsDttt|��}x0|dd�D] }||dkr|jd|f�qWdS)Nrrzhashed values differ: %r)�list�map�hashZfail)�selfZobjlistZhashed�hrrr�	same_hash4szHashEqualityTestCase.same_hashcCs>|jdddd�|jddd	�|jd
dd
�|jddd�dS)Nrg�?yrgrg@y�?y���g�g�y����g�g�y�)r()r&rrr�test_numeric_literals<sz*HashEqualityTestCase.test_numeric_literalscCs�|jtd�td�td�td�td�td��|jtd�td
��|jtd�td��|jtd�td��|jtd�td��|jtd�td��|jtd�td��dS)Nr�1z1.0rrrli�li�li�li�li���li���llll����ll����ll)r(�int�float�complex)r&rrr�test_coerced_integersBsz*HashEqualityTestCase.test_coerced_integerscCs.|jtd�td��|jtd�tdd��dS)Ng�쏈�b=~g�?g)r(r-r.r/)r&rrr�test_coerced_floatsMsz(HashEqualityTestCase.test_coerced_floatscCshdd}xZtd�D]N}xHtd�D]<}||d|�}t|�|d|�}|jt|�t|��q WqWdS)Ns#123456789abcdefghijklmnopqrstuvwxyz�r)r
�
memoryview�assertEqualr%)r&�br�jZalignedZ	unalignedrrr�test_unaligned_buffersQsz+HashEqualityTestCase.test_unaligned_buffersN)�__name__�
__module__�__qualname__r(r+r0r1r7rrrrr"2s
r"c@seZdZdS)�DefaultHashN)r8r9r:rrrrr;]sr;�*c@seZdZdd�ZdS)�	FixedHashcCstS)N)�_FIXED_HASH_VALUE)r&rrr�__hash__aszFixedHash.__hash__N)r8r9r:r?rrrrr=`sr=c@seZdZdd�ZdS)�OnlyEqualitycCs||kS)Nr)r&�otherrrr�__eq__eszOnlyEquality.__eq__N)r8r9r:rBrrrrr@dsr@c@seZdZdd�ZdS)�OnlyInequalitycCs||k	S)Nr)r&rArrr�__ne__iszOnlyInequality.__ne__N)r8r9r:rDrrrrrChsrCc@seZdZdS)�InheritedHashWithEqualityN)r8r9r:rrrrrElsrEc@seZdZdS)�InheritedHashWithInequalityN)r8r9r:rrrrrFmsrFc@seZdZdZdS)�NoHashN)r8r9r:r?rrrrrGosrGc@s`eZdZe�e�e�gZe�e�e	�gZ
e�e�gZ
dd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�HashInheritanceTestCasecCs(x"|jD]}|jt|�t|��qWdS)N)�default_expectedr4r%�
_default_hash)r&�objrrr�test_default_hashsz)HashInheritanceTestCase.test_default_hashcCs$x|jD]}|jt|�t�qWdS)N)�fixed_expectedr4r%r>)r&rKrrr�test_fixed_hash�sz'HashInheritanceTestCase.test_fixed_hashcCs"x|jD]}|jtt|�qWdS)N)�error_expectedZassertRaises�	TypeErrorr%)r&rKrrr�test_error_hash�sz'HashInheritanceTestCase.test_error_hashcCs*|j|j}x|D]}|j|t�qWdS)N)rIrMZassertIsInstancer)r&ZobjectsrKrrr�
test_hashable�s
z%HashInheritanceTestCase.test_hashablecCs x|jD]}|j|t�qWdS)N)rOZassertNotIsInstancer)r&rKrrr�test_not_hashable�sz)HashInheritanceTestCase.test_not_hashableN)r8r9r:�objectr;rCrIr=rErFrMrGr@rOrLrNrQrRrSrrrrrHrsrHc@s$eZdZed�Zdd�Zdd�ZdS)�DefaultIterSeq�
cCs
t|j�S)N)�len�seq)r&rrr�__len__�szDefaultIterSeq.__len__cCs
|j|S)N)rX)r&�indexrrr�__getitem__�szDefaultIterSeq.__getitem__N)r8r9r:r
rXrYr[rrrrrU�srUc@s6eZdZeed��ee��edd�d�gZdd�ZdS)�HashBuiltinsTestCaserVcCsdS)Nrrrrrr�<lambda>�szHashBuiltinsTestCase.<lambda>rcCs.tj}x"|jD]}|jt|�||��qWdS)N)rTr?�hashes_to_checkr4r%)r&rJrKrrr�test_hashes�sz HashBuiltinsTestCase.test_hashesN)	r8r9r:�	enumerater
�iterrUr^r_rrrrr\�s
r\c@s&eZdZdd�Zddd�Zdd�ZdS)	�HashRandomizationTestscCsd|S)Nzprint(hash(eval(%a)))r)r&�repr_rrr�get_hash_command�sz'HashRandomizationTests.get_hash_commandNcCs\tjj�}d|d<|dk	r(t|�|d<n|jdd�td|j|�f|�}|dj�}t|�S)NTZ
__cleanenvZPYTHONHASHSEEDz-cr)	�os�environ�copy�str�poprrd�stripr-)r&rc�seed�envr
�stdoutrrr�get_hash�s
zHashRandomizationTests.get_hashcCs0|j|jdd�}|j|jdd�}|j||�dS)NZrandom)rk)rnrc�assertNotEqual)r&Zrun1Zrun2rrr�test_randomized_hash�sz+HashRandomizationTests.test_randomized_hash)N)r8r9r:rdrnrprrrrrb�s
rbc
@s�eZdZdZdZddddgd0dd1d2ggddddgd	d3d	d4gd5dd6dgd
dd7d8gd9d:d;d<ggd=dd>dgd?d@dAdBgddCdDdEgdd dFdGgdHdIdJdKggd'�Zd(d)�Zd*d+�Zed,d-��Z	ed.d/��Z
dS)L� StringlikeHashRandomizationTestsNi�\�i�3x(lLL//+�?i���0lqU:~�@[i��pGl�n�YD~i�SljxY_oW�siQ�hl� �/��li�Jkl�J�:�8`~i�)�;l�)�wJ�i ��cl .�G�UJGi���nl��]�D]i]/l_l�P'ABS!i{Hlm]]�R�iiy8	=l�T�e]i�X0l�'�W�=>0i��l�;u�i���lg,��gi�ۙtl�`�bTN�Vi�?�l�9�\R>|i�m4l�kT<�h4)�djba33xrrcCs^|tjjkrd}ntjj}tjdkr2tr,dnd}ntjdks@t�trHdnd}|j|||S)Nrr�littlerrZbig�r)rr�cutoffr�	byteorder�IS_64BITr�known_hashes)r&Zpositionrr�platformrrr�get_expected_hash�s
z2StringlikeHashRandomizationTests.get_expected_hashcCs<|jdd�}|j|j|j�|�|j|j|jdd�|�dS)Nrrt)rk)rzrornrcr4)r&Zknown_hash_of_objrrr�test_null_hash�sz/StringlikeHashRandomizationTests.test_null_hashcCs(|jdd�}|j|j|jdd�|�dS)Nrrtr<)rk)rzr4rnrc)r&r'rrrrNsz0StringlikeHashRandomizationTests.test_fixed_hashcCs6|jdkrdS|jdd�}|j|j|jdd�|�dS)Nr�r<)rk)�	repr_longrzr4rn)r&r'rrr�test_long_fixed_hashs
z5StringlikeHashRandomizationTests.test_long_fixed_hashiL̇�iTS�l����qU:~�@[l����jxY_oW�sl����jxY_oW�si� ��i� ��i��l�����)�wJ�i�Q	�l���� .�G�UJGiO{�l������]�D]i�Г�i�Г�i����l����m]]�R�ii���l�����T�e]l�����'�W�=>0i�e�l�����;u�i5$f�l�����`�bTN�Vi� �l�����9�\R>|iQ���l�����kT<�h4)r8r9r:rcr}rxrzr{r!rNr~rrrrrq�s.





rqc@s<eZdZed�Zed�Zed�Zedd��Zedd��Z	dS)	�StrHashRandomizationTests�abcZabcdefghijku
äú∑ℇcCs|jtd�d�dS)N�r)r4r%)r&rrr�test_empty_stringsz+StrHashRandomizationTests.test_empty_stringcCsL|jdd�}|j|j|jdd�|�|jdd�}|j|j|jdd�|�dS)Nrt�r)rk�r<)rzr4rn�	repr_ucs2)r&r'rrr�test_ucs2_string sz*StrHashRandomizationTests.test_ucs2_stringN)
r8r9r:�reprrcr}r�r!r�r�rrrrrs
rc@s(eZdZed�Zed�Zedd��ZdS)�BytesHashRandomizationTestssabcsabcdefghijkcCs|jtd�d�dS)N�r)r4r%)r&rrrr�,sz-BytesHashRandomizationTests.test_empty_stringN)r8r9r:r�rcr}r!r�rrrrr�'sr�c@s eZdZdZdZedd��ZdS)� MemoryviewHashRandomizationTestszmemoryview(b'abc')zmemoryview(b'abcdefghijk')cCs|jttd��d�dS)Nr�r)r4r%r3)r&rrrr�5sz2MemoryviewHashRandomizationTests.test_empty_stringN)r8r9r:rcr}r!r�rrrrr�0sr�c@seZdZdd�ZdS)�
DatetimeTestscCsd|S)Nz import datetime; print(hash(%s))r)r&rcrrrrd:szDatetimeTests.get_hash_commandN)r8r9r:rdrrrrr�9sr�c@seZdZeejddd��ZdS)�DatetimeDateTestsi*rV�N)r8r9r:r��datetimeZdatercrrrrr�=sr�c	@s&eZdZeejddddddd��ZdS)	�DatetimeDatetimeTestsrrrtr��r��N)r8r9r:r�r�rcrrrrr�@sr�c@seZdZeejd��ZdS)�DatetimeTimeTestsrN)r8r9r:r�r�Ztimercrrrrr�Csr�c@seZdZdd�ZdS)�HashDistributionTestCasec
Cs�d}x�tdt|��D]�}|d|�}|j|d��tt�}t�}x<td�D]0}t|t|��}|j|d@�|j|d@�qHW|jt|�d|�|jt|�d|�WdQRXqWdS)	NZabcdefghabcdefgr)�prefix��r�r2)r
rWZsubTest�setr%�chr�addZ
assertGreater)r&�baserr�Zs15Zs255�cr'rrr�test_hash_distributionIsz/HashDistributionTestCase.test_hash_distributionN)r8r9r:r�rrrrr�Gsr��__main__l)r))r�rerrZtest.support.script_helperr�collectionsr�maxsizerwrrr!ZTestCaser"rTr?rJr;r>r=r@rCrErFrGrHrUr\rbrqrr�r�r�r�r�r�r�r8�mainrrrr�<module>sJ


*%Q