Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_marshal.cpython-34.pyo

�
f f�F�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZyddl	Z	Wne
k
r�dZ	YnXGdd�d�ZGdd�deje�Z
Gdd�deje�ZGd	d
�d
eje�ZGdd�dej�ZGd
d�dej�ZGdd�deje�ZGdd�deje�ZGdd�dej�Zd+Zejdkr�dndZGdd�d�Zejeejkd�Gdd�dej��Zdd �ZGd!d"�d"eje�ZGd#d$�d$ej�ZGd%d&�d&eje�Zejej e	d'�Gd(d)�d)eje���Z!e"d*kr�ej#�ndS),�)�supportNc@seZdZdd�ZdS)�HelperMixincGs�tjtj||��}|j||�zlttjd��}tj|||�WdQXttjd��}tj|�}WdQX|j||�Wdtj	tj�XdS)N�wb�rb)
�marshal�loads�dumps�assertEqual�openr�TESTFN�dump�load�unlink)�self�sampleZextra�new�f�r�6/opt/alt/python34/lib64/python3.4/test/test_marshal.py�helperszHelperMixin.helperN)�__name__�
__module__�__qualname__rrrrrrsrc@s(eZdZdd�Zdd�ZdS)�IntTestCasecCsMtjd}x9|rHx"||fD]}|j|�q$W|d?}qWdS)N��)�sys�maxsizer)r�n�expectedrrr�	test_intss

	zIntTestCase.test_intscCs"xdD]}|j|�qWdS)NTF)TF)r)r�brrr�	test_bool%s
zIntTestCase.test_boolN)rrrr r"rrrrrsrc@seZdZdd�ZdS)�
FloatTestCasecCs2d}tjd}xE||krZx(||fD]}|jt|��q0W|d}qWd}tj|d�}tj|�}|j||�tj|d�}tj|�}|j||�tjd}x[||kr-x>||fD]/}t|�}|j|�|j|d�q�W|d9}q�WdS)Ng�}���:g�6�ҫ�sgS��:�^@grrg��Z1%)rrr�floatrrrr	)rZsmallrrr�sZgotrrr�test_floats*s(


zFloatTestCase.test_floatsN)rrrr&rrrrr#)sr#c@s4eZdZdd�Zdd�Zdd�ZdS)�StringTestCasecCsDx=dddddgD]%}|jtjtj|���qWdS)N�u
Andrè Previn�abc� i')rrrr)rr%rrr�test_unicodeEszStringTestCase.test_unicodecCs2x+dddddgD]}|j|�qWdS)Nr(u
Andrè Previnr)r*i')r)rr%rrr�test_stringIszStringTestCase.test_stringcCs2x+dddddgD]}|j|�qWdS)N�sAndr� Previnsabc� i')r)rr%rrr�
test_bytesMszStringTestCase.test_bytesN)rrrr+r,r/rrrrr'Dsr'c@seZdZdd�ZdS)�ExceptionTestCasecCs,tjtjt��}|jt|�dS)N)rrr�
StopIterationr	)rrrrr�test_exceptionsRsz!ExceptionTestCase.test_exceptionsN)rrrr2rrrrr0Qsr0c@sIeZdZdd�Zdd�Zdd�Zejdd��Zd	S)
�CodeTestCasecCs8tjj}tjtj|��}|j||�dS)N)r0r2�__code__rrrr	)r�corrrr�	test_codeWszCodeTestCase.test_codecCs3d}tjjf|}tjtj|��dS)Ni�)r0r2r4rrr)r�countZcodesrrr�test_many_codeobjects\sz"CodeTestCase.test_many_codeobjectscCsrtddd�}tddd�}tjtj||f��\}}|j|jd�|j|jd�dS)N�x�f1�exec�y�f2)�compilerrrr	�co_filename)rZco1Zco2rrr�test_different_filenamesbs
$z%CodeTestCase.test_different_filenamescCssd}t|dd�}tjtj|��}x<|jD]1}t|tj�r:|j|j	|j	�q:q:WdS)Nzdef f(): pass
def g(): passZmyfiler;)
r>rrr�	co_consts�
isinstance�types�CodeTypeZassertIsr?)rr%r5�objrrr�test_same_filename_usedisz$CodeTestCase.test_same_filename_usedN)	rrrr6r8r@r�cpython_onlyrFrrrrr3Vsr3c@s�eZdZidd6dd6dd6dd6d	gd
6dd6d
d6dd6Zdd�Zdd�Zdd�Zdd�ZdS)�ContainerTestCasezfoo@bar.baz.spamZastringgH�zns�@Zafloatr�ZanintZ
ashortlong�.zyx.41Zalist�
ZatupleFZabooleanu
Andrè PrevinZaunicodecCs|j|j�dS)N)r�d)rrrr�	test_dict}szContainerTestCase.test_dictcCs |jt|jj���dS)N)r�listrL�items)rrrr�	test_list�szContainerTestCase.test_listcCs |jt|jj���dS)N)r�tuplerL�keys)rrrr�
test_tuple�szContainerTestCase.test_tuplecCs7x0ttfD]"}|j||jj���q
WdS)N)�set�	frozensetrrLrR)r�constructorrrr�	test_sets�szContainerTestCase.test_setsNi)rJ)
rJrJrJrJrJrJrJrJrJrJ)rrrrLrMrPrSrWrrrrrHrs


rHc@s4eZdZdd�Zdd�Zdd�ZdS)�BufferTestCasecCsKtd�}|j|�tjtj|��}|jt|�t�dS)Nsabc)�	bytearrayrrrrr	�type�bytes)rr!rrrr�test_bytearray�s
zBufferTestCase.test_bytearraycCsKtd�}|j|�tjtj|��}|jt|�t�dS)Nsabc)�
memoryviewrrrrr	rZr[)rr!rrrr�test_memoryview�s
zBufferTestCase.test_memoryviewcCs>tjdd�}tjtj|��}|j|d�dS)N�Bsabc)�arrayrrrr	)r�arrrr�
test_array�szBufferTestCase.test_arrayN)rrrr\r^rbrrrrrX�srXc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�BugsTestCasecCstjdgd�dS)N�i�)rr)rrrr�test_bug_5888452�szBugsTestCase.test_bug_5888452cCsY|jttjd�|jttjd�|jttjtjd�dd��dS)N�0rr�Arl ���)�assertRaises�	Exceptionrrr)rrrr�test_patch_873224�szBugsTestCase.test_patch_873224cCsN|jtjtjdd��d�|jtjtjdd��d�dS)N�rr)r	rrr)rrrr�test_version_argument�s%z"BugsTestCase.test_version_argumentcCsNxGdd�td�D�D],}ytj|�Wqtk
rEYqXqWdS)NcSsg|]}t|��qSr)�chr)�.0�irrr�
<listcomp>�s	z*BugsTestCase.test_fuzz.<locals>.<listcomp>�)�rangerrrj)r�crrr�	test_fuzz�s
 
zBugsTestCase.test_fuzzcCs(d	dd
}|jttj|�dS)N�c�X��{rrIsXXXXsXXXXXXXXXXXXXXXXscXXXXXXXXXXXXXXXXi)ri�
ValueErrorrr)rr%rrr�test_loads_2x_code�szBugsTestCase.test_loads_2x_codecCs,dd	dd
}|jttj|�dS)NrvrwrxrlryrrIsXXXXsXXXXXXXXXXXXXXXXXXXXi)rirzrr)rr%rrr�test_loads_recursion�sz!BugsTestCase.test_loads_recursioncCsg}}tjdkr1ttd�r1d}nd}x2t|d�D] }|jdg�|d}qHWtj|�}tj|�}|j	t
|�t
|��|j	t
|d�t
|d��|j	t
|d	�t
|d
��|jdg�|jttj|�dS)N�nt�gettotalrefcounti�i�rrrrhrhrh)
�os�name�hasattrrrs�appendrrrr	�lenrirz)r�head�lastZMAX_MARSHAL_STACK_DEPTHrp�dataZnew_headrrr�test_recursion_limit�s
	$$z!BugsTestCase.test_recursion_limitcCs[xTttttttttfD]4}td|fi�}|j	t
tj|��qWdS)N�subtyp)
�intr$�complexrQrN�dictrTrUrZrirzrr)r�typr�rrr�test_exact_type_match�s%z"BugsTestCase.test_exact_type_matchcCs'td�}d|}tj|�dS)Ng��.Ar))r�rr)r�sizeZ
testStringrrr�test_large_marshal�s
zBugsTestCase.test_large_marshalcCs d}|jttj|�dS)Ns	l)rirzrr)rZinvalid_stringrrr�test_invalid_longs�szBugsTestCase.test_invalid_longscCsIddddddddgff}xd
D]}t|�}g}z�ttjd��Q}xG|D]?}tj||�|r�|j|�n|j|j��qbWWdQXttjd��m}xct	|�D]U\}}|j
|tj|��|r|j|�n|j
|||j��q�WWdQXWdtj
tj�Xq+WdS)Nrr)sdefg�?rrar!rvr-�0123rr)r-r�)r�r
rrrr�writer��tell�	enumerater	r
�readr)rr�ZinterleavedZilenZ	positionsrrLrprrr�test_multiple_dumps_and_loads�s$$

(z*BugsTestCase.test_multiple_dumps_and_loadscCs d}|jttj|�dS)N�T)ri�	TypeErrorrr)rZunicode_stringrrr�!test_loads_reject_unicode_stringssz.BugsTestCase.test_loads_reject_unicode_stringscCsSGdd�dtj�}x3dD]+}|jttj|tj|���q WdS)Ncs"eZdZ�fdd�Z�S)z/BugsTestCase.test_bad_reader.<locals>.BadReadercs;t�j|�}|dk	r7|dkr7|d7}n|S)NrxrK�i@B)�super�readinto)rZbufr)�	__class__rrr�s
z8BugsTestCase.test_bad_reader.<locals>.BadReader.readinto)rrrr�rr)r�r�	BadReadersr���?��?�
0123456789�
0123456789)r�r�r�z
0123456789)�io�BytesIOrirzrr
r)rr��valuerrr�test_bad_reader
s
zBugsTestCase.test_bad_readercCsPtjd�}x:tt|��D]&}|jttj|d|��q"WdS)N�hello�dollyr)r�r�N)rrrsr�ri�EOFErrorr)rr�rprrr�	_test_eofszBugsTestCase._test_eofN)rrrrerkrmrur{r|r�r�r�r�r�r�r�r�rrrrrc�s	
rcr�l���rxc@seZdZdd�ZdS)�
NullWritercCsdS)Nr)rr%rrrr�szNullWriter.writeN)rrrr�rrrrr�sr�z!test cannot run on 32-bit systemsc@steZdZdd�Zejdedddd�dd	��Zejdedddd�d
d��Zejdede	ddd�d
d��Z
ejdede	ddd�dd��Zejdede	dej
ed�dd�dd��Zejdede	dej
ed�dd�dd��Zejdedddd�dd��ZdS)�LargeValuesTestCasecCs |jttj|t��dS)N)rirzrrr�)rr�rrr�check_unmarshallable#sz(LargeValuesTestCase.check_unmarshallabler�ZmemuserZdry_runFcCs|jd|�dS)N�x)r�)rr�rrrr/&szLargeValuesTestCase.test_bytescCs|jd|�dS)Nr9)r�)rr�rrr�test_str*szLargeValuesTestCase.test_strrcCs|jd|�dS)N)N)r�)rr�rrrrS.szLargeValuesTestCase.test_tuplecCs|jdg|�dS)N)r�)rr�rrrrP2szLargeValuesTestCase.test_list�cCs|jtt|���dS)N)r�rTrs)rr�rrr�test_set6szLargeValuesTestCase.test_setcCs|jtt|���dS)N)r�rUrs)rr�rrr�test_frozenset<sz"LargeValuesTestCase.test_frozensetcCs|jt|��dS)N)r�rY)rr�rrrr\Bsz"LargeValuesTestCase.test_bytearrayN)rrrr�rZ
bigmemtest�
LARGE_SIZEr/r��pointer_sizerSrPr�	getsizeofr�r�r\rrrrr�!s**..r�cCs�t|�|krdS|jt|��t|ttttf�rexg|D]}t||�qKWnIt|t�r�x7|j	�D]&\}}t||�t||�q�Wnt
|�S)z&Collect object ids seen in a structureN)�id�addrBrNrQrTrU�CollectObjectIDsr�rOr�)ZidsrE�e�k�vrrrr�Fs

r�c@s�eZdZdZdZdZied6ed6de6Zdddd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�InstancingTestCasei��g��n���?Zabcde�r�ZgoodbyeFc
Cs�||f}tt�|�}tj|d�}tt�tj|��}|j||�|s�tj|d�}tt�tj|��}	|j|	|�|s�|jt|�t|��q�|jt|�t|��ndS)Nr�r)	r�rTrrrr	Z
assertGreaterr�ZassertGreaterEqual)
rZrsample�	recursive�simplerZn0Zs3Zn3�s2Zn2rrr�helper3ZszInstancingTestCase.helper3cCs*|j|j�|j|jdd�dS)Nr�T)r�intobjr�)rrrr�testIntsszInstancingTestCase.testIntcCs$|j|j�|j|j�dS)N)r�floatobjr�)rrrr�	testFloatwszInstancingTestCase.testFloatcCs$|j|j�|j|j�dS)N)r�strobjr�)rrrr�testStr{szInstancingTestCase.testStrcCs$|j|j�|j|j�dS)N)r�dictobjr�)rrrr�testDictszInstancingTestCase.testDictc
Csfttd��}|j�}WdQXtjd�rHt|td�}n|j|�|j|�dS)Nrz.pyr;)r
�__file__r��endswithr>rr�)rr�coderrr�
testModule�s
zInstancingTestCase.testModulecCs\t|j�}||d<|j|dd�|jg}|j|�|j|dd�dS)Nrr�T)r�r�r�r�)rrL�lrrr�
testRecursion�s

z InstancingTestCase.testRecursionNZabcdeabcdeabcde)rrrr�r�r�r�r�r�r�r�r�r�r�rrrrr�Tsr�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�CompatibilityTestCasec
Cskttd��}|j�}WdQXtjd�rHt|td�}ntj||�}tj|�dS)Nrz.pyr;)r
r�r�r�r>rrr)r�versionrr�r�rrr�_test�szCompatibilityTestCase._testcCs|jd�dS)Nr)r�)rrrr�test0To3�szCompatibilityTestCase.test0To3cCs|jd�dS)Nr)r�)rrrr�test1To3�szCompatibilityTestCase.test1To3cCs|jd�dS)Nr)r�)rrrr�test2To3�szCompatibilityTestCase.test2To3cCs|jd�dS)Nr�)r�)rrrr�test3To3�szCompatibilityTestCase.test3To3N)rrrr�r�r�r�r�rrrrr��s
r�c@s=eZdZdZeje�Zdd�Zdd�ZdS)�InterningTestCasezthis is an interned stringcCs|tjtj|j��}|j||j�|jt|�t|j��tj|�}|jt|�t|��dS)N)rrrr�r	r�r�intern)rr%r�rrr�
testIntern�s
zInterningTestCase.testInterncCstjtj|jd��}|j||j�|jt|�t|j��tj|�}|jt|�t|��dS)Nr)	rrrr�r	ZassertNotEqualr�rr�)rr%r�rrr�testNoIntern�s
zInterningTestCase.testNoInternN)rrrr�rr�r�r�rrrrr��sr�zrequires _testcapic@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�
CAPI_TestCasec
Csxxttjd�D]c}tjdtj|�ttjd��}|j�}WdQXtj	tj�|j
|d�qWdS)NrixV4rsxV4)rsrr��	_testcapiZpymarshal_write_long_to_filerrr
r�rr	)rr�rr�rrr�test_write_long_to_file�sz%CAPI_TestCase.test_write_long_to_filec
Cs�dddddddf}x�ttjd	�D]l}tj|tj|�ttjd
��}|j�}WdQXtj	tj�|j
tj|�|�q0WdS)Nu€sabc�{g������F@�y @z
long line i�rry@ @)rsrr�r�Zpymarshal_write_object_to_filerrr
r�rr	r)rrEr�rr�rrr�test_write_object_to_file�sz'CAPI_TestCase.test_write_object_to_filecCs�ttjd��}|jd�WdQXtjtj�\}}tjtj�|j|d�|j|d�ttjd��}|jd�WdQX|jt	��tjtj�WdQXtjtj�dS)Nrs4xxxxi4rs)
r
rrr�r�Zpymarshal_read_short_from_filerr	rir�)rr�r�prrr�test_read_short_from_file�sz'CAPI_TestCase.test_read_short_from_filecCs�ttjd��}|jd�WdQXtjtj�\}}tjtj�|j|d�|j|d�ttjd��}|jd�WdQX|jt	��tjtj�WdQXtjtj�dS)NrsxV4xxxxixV4rxsV4)
r
rrr�r�Zpymarshal_read_long_from_filerr	rir�)rrr�r�rrr�test_read_long_from_file�sz&CAPI_TestCase.test_read_long_from_filecCsd}x�ttjd�D]�}tj||�}ttjd��}|j|d	�WdQXtj	tj�\}}tj
tj�|j||�ttjd��}|j|dd��WdQX|jt
��tj	tj�WdQXtj
tj�qWdS)N�€�abcr��������F@r�y @rrsxxxx�@ @)r�r�r�r�r�)rsrr�rr
rrr�r�Z$pymarshal_read_last_object_from_filerr	rir�)rrEr�r�rr�r�rrr�test_read_last_object_from_file�sz-CAPI_TestCase.test_read_last_object_from_filecCsd}xttjd�D]�}tj||�}ttjd��}|j|d	�WdQXtj	tj�\}}tj
tj�|j||�|j|t|��ttjd��}|j|dd��WdQX|j
t��tj	tj�WdQXtj
tj�qWdS)N�€�abcr��������F@r�y @rrsxxxx�@ @)r�r�r�r�r�)rsrr�rr
rrr�r�Zpymarshal_read_object_from_filerr	r�rir�)rrEr�r�rr�r�rrr�test_read_object_from_file�sz(CAPI_TestCase.test_read_object_from_fileN)	rrrr�r�r�r�r�r�rrrrr��s	r��__main__l)$Ztestrr`r�rrZunittestrrCr��ImportErrorrZTestCaserr#r'r0r3rHrXrcr�rr�r�ZskipIfr�r�r�r�r�rGZ
skipUnlessr�r�mainrrrr�<module>sD



{%$?Q