Your IP : 216.73.216.85


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_marshal.cpython-310.pyc

o

0�i�Q�@s�ddlmZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
zddlZWney9dZYnwGdd�d�Z
Gdd�deje
�ZGdd	�d	eje
�ZGd
d�deje
�ZGdd
�d
ej�ZGdd�dej�ZGdd�deje
�ZGdd�deje
�ZGdd�dej�ZdZejdkr�dndZGdd�d�Ze�eejkd�Gdd�dej��Zdd �ZGd!d"�d"eje
�ZGd#d$�d$ej�ZGd%d&�d&eje
�Z ej!e�"ed'�Gd(d)�d)eje
���Z#e$d*kr�e�%�dSdS)+�)�support)�	os_helperNc@�eZdZdd�ZdS)�HelperMixinc	Gs�t�tj|g|�R��}|�||�zJttjd��}tj||g|�R�Wd�n1s.wYttjd��
}t�|�}Wd�n1sIwY|�||�Wt�	tj�dSt�	tj�w)N�wb�rb)
�marshal�loads�dumps�assertEqual�openr�TESTFN�dump�load�unlink)�self�sampleZextra�new�f�r�8/opt/alt/python310/lib64/python3.10/test/test_marshal.py�helpers��zHelperMixin.helperN)�__name__�
__module__�__qualname__rrrrrr�rc@�$eZdZdd�Zdd�Zdd�ZdS)�IntTestCasecCs<tjd}|r||fD]}|�|�q|d?}|sdSdS)N��)�sys�maxsizer)r�n�expectedrrr�	test_intss
�zIntTestCase.test_intscCs�d}|d}||||d?fD]'}|r8dtj|dddd�}t�|�}|�||�|dkr2d	}n|dL}|sqt�d
�}|�|d�t�d�}|�|d
�t�d�}|�|d�t�d�}|�|d�dS)Nl����r�I��littleT)Zsigned���rs	I�ܺ�vT2l�\u1�Q�s	I#Eg����l�����\u1�Q�s	I*;L]nlTv0ur{s	I���ij���l����	Tv0ur{)�int�to_bytesrr	r)rZmaxint64Zminint64�base�s�gotrrr�
test_int64&s(

��
	


zIntTestCase.test_int64cCsdD]}|�|�qdS)N)TF�r)r�brrr�	test_bool=s�zIntTestCase.test_boolN)rrrr$r.r1rrrrrsrc@r)�
FloatTestCasecCs�d}tjd}||kr"||fD]	}|�t|��q|d}||ksd}t�|d�}t�|�}|�||�t�|d�}t�|�}|�||�tjd}||krp||fD]}t|�}|�|�|�|d�qT|d9}||ksOdSdS)Ng�}���:g�6�ҫ�sgS��:�^@grrg��Z1%)r r!r�floatrr
r	r)rZsmallr"r#rr,r-rrr�test_floatsBs,
�



�zFloatTestCase.test_floatsN)rrrr4rrrrr2Arr2c@r)�StringTestCasecCs0dddddfD]
}|�t�t�|���qdS�N��
Andrè Previn�abc� �')rrr	r
�rr,rrr�test_unicode]s�zStringTestCase.test_unicodecC�$dddddfD]}|�|�qdSr6r/r<rrr�test_stringa��zStringTestCase.test_stringcCr>)N�sAndr� Previn�abc� r;r/r<rrr�
test_byteser@zStringTestCase.test_bytesN)rrrr=r?rDrrrrr5\sr5c@r)�ExceptionTestCasecCs t�t�t��}|�t|�dS�N)rr	r
�
StopIterationr)rrrrr�test_exceptionsjsz!ExceptionTestCase.test_exceptionsN)rrrrHrrrrrEirrEc@s2eZdZdd�Zdd�Zdd�Zejdd��Zd	S)
�CodeTestCasecCs(tjj}t�t�|��}|�||�dSrF)rErH�__code__rr	r
r)r�corrrr�	test_codeoszCodeTestCase.test_codecCs&d}tjjf|}t�t�|��dS)Ni�)rErHrJrr	r
)r�countZcodesrrr�test_many_codeobjectstsz"CodeTestCase.test_many_codeobjectscCsPtddd�}tddd�}t�t�||f��\}}|�|jd�|�|jd�dS)N�x�f1�exec�y�f2)�compilerr	r
r�co_filename)rZco1Zco2rrr�test_different_filenameszs
z%CodeTestCase.test_different_filenamescCsLd}t|dd�}t�t�|��}|jD]}t|tj�r#|�|j	|j	�qdS)Nzdef f(): pass
def g(): passZmyfilerQ)
rTrr	r
�	co_consts�
isinstance�types�CodeTypeZassertIsrU)rr,rK�objrrr�test_same_filename_used�s
��z$CodeTestCase.test_same_filename_usedN)	rrrrLrNrVr�cpython_onlyr\rrrrrInsrIc	@sDeZdZdddddgdddd	�Zd
d�Zdd
�Zdd�Zdd�ZdS)�ContainerTestCasezfoo@bar.baz.spamgH�zns�@�r�.zyx.41)
r`r`r`r`r`r`r`r`r`r`Fr8)ZastringZafloatZanintZ
ashortlongZalistZatupleZabooleanZaunicodecCs|�|j�dSrF)r�d�rrrr�	test_dict�szContainerTestCase.test_dictcC�|�t|j����dSrF)r�listra�itemsrbrrr�	test_list��zContainerTestCase.test_listcCrdrF)r�tuplera�keysrbrrr�
test_tuple�rhzContainerTestCase.test_tuplecCs&ttfD]}|�||j����qdSrF)�set�	frozensetrrarj)r�constructorrrr�	test_sets�s�zContainerTestCase.test_setsN)rrrrarcrgrkrorrrrr^�s�
r^c@r)�BufferTestCasecC�6td�}|�|�t�t�|��}|�t|�t�dS�NrB)�	bytearrayrrr	r
r�type�bytes�rr0rrrr�test_bytearray��
zBufferTestCase.test_bytearraycCrqrr)�
memoryviewrrr	r
rrtrurvrrr�test_memoryview�rxzBufferTestCase.test_memoryviewcCs,t�dd�}t�t�|��}|�|d�dS)N�BrB)�arrayrr	r
r)r�arrrr�
test_array�szBufferTestCase.test_arrayN)rrrrwrzr~rrrrrp�srpc@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�BugsTestCasecCst�dgd�dS)N���)rr
rbrrr�test_bug_5888452��zBugsTestCase.test_bug_5888452cCsF|�ttjd�|�ttjd�|�ttjt�dd�dd��dS)N�0�fr�Ar()�assertRaises�	Exceptionrr	r
rbrrr�test_patch_873224�s&zBugsTestCase.test_patch_873224cCs8|�t�t�dd��d�|�t�t�dd��d�dS)N�rr)rrr	r
rbrrr�test_version_argument�sz"BugsTestCase.test_version_argumentc	Cs<td�D]}t|g�}zt�|�WqtyYqwdS)N�)�rangerurr	r�)r�i�crrr�	test_fuzz�s
��zBugsTestCase.test_fuzzcs.dd�}|dtj��fdd�}|d|�dS)NcSs\|d|d�|d|d�|d|d�|d|dd|�|d|d�dS)Ns)�Ns(s[s{Nr�s>r)�N�checkrrr�	run_tests�s
z4BugsTestCase.test_loads_recursion.<locals>.run_tests�dcs��ttj|�dSrF�r��
ValueErrorrr	)r,rbrrr��sz0BugsTestCase.test_loads_recursion.<locals>.checkr_)rr	)rr�r�rrbr�test_loads_recursion�sz!BugsTestCase.test_loads_recursioncCs�g}}tjdkrd}nd}t|d�D]}|�dg�|d}qt�|�}t�|�}|�t|�t|��|�t|d�t|d��|�t|d�t|d��|�dg�|�	t
tj|�dS)N�ntr�i�rrr()�os�namer��appendrr
r	r�lenr�r�)r�headZlastZMAX_MARSHAL_STACK_DEPTHr��dataZnew_headrrr�test_recursion_limit�s



z!BugsTestCase.test_recursion_limitcCs>ttttttttfD]}td|fi�}|�	t
tj|��q
dS)N�subtyp)
r)r3�complexrire�dictrlrmrtr�r�rr
)r�typr�rrr�test_exact_type_match�s�z"BugsTestCase.test_exact_type_matchcCstd�}d|}t�|�dS)Ng��.Ar9)r)rr
)r�sizeZ
testStringrrr�test_large_marshal
szBugsTestCase.test_large_marshalcC�d}|�ttj|�dS)Ns	lr�)rZinvalid_stringrrr�test_invalid_longs�zBugsTestCase.test_invalid_longsc
Cs ddddddddgff}d	D]}t|�}g}zpttjd
��!}|D]}t�||�|r/|�|�|�|���q Wd�n1sAwYttjd��+}t	|�D]\}}|�
|t�|��|re|�|�|�
|||���qQWd�n1szwYWt�
tj�qt�
tj�wdS)Nrr9sdef��?rr}r0�c)rAs0123rr)r�rrr
rr�writer��tell�	enumeraterr�readr)rr�ZinterleavedZilenZ	positionsrrar�rrr�test_multiple_dumps_and_loadss0
��
����z*BugsTestCase.test_multiple_dumps_and_loadscCr�)N�T)r��	TypeErrorrr	)rZunicode_stringrrr�!test_loads_reject_unicode_strings,r�z.BugsTestCase.test_loads_reject_unicode_stringsc	Cs:Gdd�dtj�}dD]}|�ttj|t�|���qdS)NcseZdZ�fdd�Z�ZS)z/BugsTestCase.test_bad_reader.<locals>.BadReadercs(t��|�}|dur|dkr|d7}|S)N�i@B)�super�readinto)rZbufr"��	__class__rrr�3sz8BugsTestCase.test_bad_reader.<locals>.BadReader.readinto)rrrr��
__classcell__rrr�r�	BadReader2sr�)r�y�?s
0123456789�
0123456789)�io�BytesIOr�r�rrr
)rr��valuerrr�test_bad_reader1s
��zBugsTestCase.test_bad_readercCs8t�d�}tt|��D]}|�ttj|d|��qdS)N)�helloZdollyNr)rr
r�r�r��EOFErrorr	)rr�r�rrr�test_eof<s
�zBugsTestCase.test_eofN)rrrr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�s

rll��r&r�c@r)�
NullWritercCsdSrFrr<rrrr�EszNullWriter.writeN)rrrr�rrrrr�Drr�z!test cannot run on 32-bit systemsc@s�eZdZdd�Zejeddd�dd��Zejeddd�dd	��Zejee	d
dd�dd��Z
ejee	d
dd�d
d��Zejee	de�
ed
�dd�dd��Zejee	de�
ed
�dd�dd��Zejeddd�dd��ZdS)�LargeValuesTestCasecCs|�ttj|t��dSrF)r�r�rrr�)rr�rrr�check_unmarshallableJrhz(LargeValuesTestCase.check_unmarshallablerF)r�ZmemuseZdry_runcC�|�d|�dS)N�x�r��rr�rrrrDM�zLargeValuesTestCase.test_bytescCr�)NrOr�r�rrr�test_strQr�zLargeValuesTestCase.test_strrcCr�)NrFr�r�rrrrkUr�zLargeValuesTestCase.test_tuplecCs|�dg|�dSrFr�r�rrrrgYr�zLargeValuesTestCase.test_list�cC�|�tt|���dSrF)r�rlr�r�rrr�test_set]�zLargeValuesTestCase.test_setcCr�rF)r�rmr�r�rrr�test_frozensetcr�z"LargeValuesTestCase.test_frozensetcCs|�t|��dSrF)r�rsr�rrrrwir�z"LargeValuesTestCase.test_bytearrayN)rrrr�rZ
bigmemtest�
LARGE_SIZErDr��pointer_sizerkrgr �	getsizeofr�r�rwrrrrr�Hs,



�
�
r�cCs�t|�|vrdS|�t|��t|ttttf�r&|D]}t||�qt
|�St|t�r>|�	�D]\}}t||�t||�q/t
|�S)z&Collect object ids seen in a structureN)�id�addrXrerirlrm�CollectObjectIDsr�rfr�)Zidsr[�e�k�vrrrr�ms
�
r�c@s�eZdZddddeddh�fZddd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS) �InstancingTestCase�{獗n���?r9)r�r9FcCs�||f}tt�|�}tdtjd�D]}t�||�}tt�t�|��}|�||�q|s[t�|d�}	tt�t�|	��}
|�|
|�|sO|�t	|	�t	|��dS|�
t	|	�t	|��dSdS)N�rr)r�rlr�r�versionr
r	rZ
assertGreaterr�ZassertGreaterEqual)rZrsample�	recursive�simplerZn0r�Zs3Zn3�s2Zn2rrr�helper3~s�zInstancingTestCase.helper3cCs d}|�|�|j|dd�dS)Ni��T)r��rr�)rZintobjrrr�testInt�s
zInstancingTestCase.testIntcC�d}|�|�|�|�dS)Nr�r�)rZfloatobjrrr�	testFloat��
zInstancingTestCase.testFloatcCr�)NZabcdeabcdeabcder�)r�strobjrrr�testStr�r�zInstancingTestCase.testStrcCr�)Nsabcdeabcdeabcder�)rZbytesobjrrr�	testBytes�r�zInstancingTestCase.testBytescCs,|jD]}||g}|�|�|�|�qdSrF�rjrr�)rr[Zlistobjrrr�testList��


�zInstancingTestCase.testListcCs,|jD]}||f}|�|�|�|�qdSrFr�)rr[Ztupleobjrrr�	testTuple�r�zInstancingTestCase.testTuplecCs4|jD]}|df|dfh}|�|�|�|�qdS�Nrrr�)rr[Zsetobjrrr�testSet��


�zInstancingTestCase.testSetcCs8|jD]}t|df|dfh�}|�|�|�|�qdSr�)rjrmrr�)rr[Zfrozensetobjrrr�
testFrozenSet�s


�z InstancingTestCase.testFrozenSetcCs4|jD]}d|d||di}|�|�|�|�qdS)Nr��goodbyer�)rr[Zdictobjrrr�testDict�r�zInstancingTestCase.testDictcCs`ttd��}|��}Wd�n1swYt�d�r$t|td�}|�|�|�|�dS�Nrz.pyrQ)r�__file__r��endswithrTrr�)rr�coderrr�
testModule�s
�

zInstancingTestCase.testModulecCsNd}d|d||di}||d<|j|dd�||g}|�|�|j|dd�dS)Nr�r�r�rT)r�)r�r�)rr[ra�lrrr�
testRecursion�s
z InstancingTestCase.testRecursionN)FF)rrrrmrjr�r�r�r�r�r�r�r�r�r�r�r�rrrrr�{s
r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�CompatibilityTestCasecCsbttd��}|��}Wd�n1swYt�d�r$t|td�}t�||�}t�|�dSr�)rr�r�r�rTrr
r	)rr�rr�r�rrr�_test�s
�
zCompatibilityTestCase._testcC�|�d�dS)Nr�r�rbrrr�test0To3��zCompatibilityTestCase.test0To3cCr�)Nrrrbrrr�test1To3�rzCompatibilityTestCase.test1To3cCr��Nrrrbrrr�test2To3�rzCompatibilityTestCase.test2To3cCr�)Nr�rrbrrr�test3To3�rzCompatibilityTestCase.test3To3N)rrrr�rrrrrrrrr��sr�c@s*eZdZdZe�e�Zdd�Zdd�ZdS)�InterningTestCasezthis is an interned stringcCsXt�t�|j��}|�||j�|�t|�t|j��t�|�}|�t|�t|��dSrF)rr	r
r�rr�r �intern�rr,r�rrr�
testIntern�s

zInterningTestCase.testInterncCsZt�t�|jd��}|�||j�|�t|�t|j��t�|�}|�t|�t|��dSr)	rr	r
r�rZassertNotEqualr�r rr	rrr�testNoIntern�s

zInterningTestCase.testNoInternN)rrrr�r rr
rrrrrr�s

rzrequires _testcapic@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�
CAPI_TestCasec	Cstttjd�D]0}t�dtj|�ttjd��}|��}Wd�n1s&wYt�	tj�|�
|d�qdS)Nr�xV4rsxV4)r�rr��	_testcapiZpymarshal_write_long_to_filerr
rr�rr)rr�rr�rrr�test_write_long_to_files
��z%CAPI_TestCase.test_write_long_to_filec	Cs�dddddddf}ttjd�D]3}t�|tj|�ttjd	��}|��}Wd�n1s0wYt�	tj�|�
t�|�|�qdS)
N�€rBr��������F@�@ @z
long line r�rr)r�rr�rZpymarshal_write_object_to_filerr
rr�rrr	)rr[r�rr�rrr�test_write_object_to_files
��z'CAPI_TestCase.test_write_object_to_filecC��ttjd��
}|�d�Wd�n1swYt�tj�\}}t�tj�|�|d�|�|d�ttjd��
}|�d�Wd�n1sKwY|�t	��t�tj�Wd�n1sfwYt�tj�dS)Nrs4xxxxi4r�)
rrr
r�rZpymarshal_read_short_from_filerrr�r��rr�r�prrr�test_read_short_from_file����z'CAPI_TestCase.test_read_short_from_filecCr)NrsxV4xxxxr
r�sV4)
rrr
r�rZpymarshal_read_long_from_filerrr�r�rrrr�test_read_long_from_file%rz&CAPI_TestCase.test_read_long_from_filec	Cs
d}ttjd�D]y}t�||�}ttjd��}|�|d�Wd�n1s)wYt�	tj�\}}t�
tj�|�||�ttjd��}|�|dd��Wd�n1s\wY|�t
��t�	tj�Wd�n1swwYt�
tj�q	dS�N)rrBr�rrrrsxxxx)r�rr�r
rrr
r�rZ$pymarshal_read_last_object_from_filerrr�r��rr[r�r�rrrrrr�test_read_last_object_from_file3s"����z-CAPI_TestCase.test_read_last_object_from_filec	Csd}ttjd�D]�}t�||�}ttjd��}|�|d�Wd�n1s)wYt�	tj�\}}t�
tj�|�||�|�|t|��ttjd��}|�|dd��Wd�n1sdwY|�
t��t�	tj�Wd�n1swYt�
tj�q	dSr)r�rr�r
rrr
r�rZpymarshal_read_object_from_filerrr�r�r�rrrr�test_read_object_from_fileCs$����z(CAPI_TestCase.test_read_object_from_fileN)	rrrrrrrrrrrrrrs	r�__main__)&�testrZtest.supportrr|r�rr Zunittestr�rYr�ImportErrorrZTestCaserr2r5rErIr^rprr�r!r�r�ZskipIfr�r�r�r�rr]Z
skipUnlessrr�mainrrrr�<module>sN�
$
$`
Q�