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_zlib.cpython-34.pyo

�
f f$k�@s�ddlZddlmZddlZddlZddlZddlZddlmZm	Z	m
Z
ejd�Zej
eej�d�d�Zej
eej�d�d�ZGdd	�d	ej�ZGd
d�dej�ZGdd
�d
ej�ZGdd�dej�ZGdd�de�ZGdd�deej�ZGdd�deej�Zdedd�Zdedd�ZdZdd�Ze dkr�ej!�ndS)�N)�support)�
bigmemtest�_1G�_4G�zlib�copyzrequires Compress.copy()zrequires Decompress.copy()c@seZdZdd�ZdS)�VersionTestCasecCs"|jtjdtjd�dS)Nr)�assertEqualrZZLIB_RUNTIME_VERSIONZZLIB_VERSION)�self�r�3/opt/alt/python34/lib64/python3.4/test/test_zlib.py�test_library_versionsz$VersionTestCase.test_library_versionN)�__name__�
__module__�__qualname__r
rrrrrsrc@speZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�ChecksumTestCasecCsB|jtjd�tjdd��|jtjdd��dS)N�rsabcl��)r	r�crc32�
assertTrue)r
rrr�test_crc32start s%z ChecksumTestCase.test_crc32startcCsX|jtjdd�d�|jtjdd�d�|jtjdd�d�dS)Nrr�i�)r	rr)r
rrr�test_crc32empty$sz ChecksumTestCase.test_crc32emptycCsB|jtjd�tjdd��|jtjdd��dS)Nrrsabcl��)r	r�adler32r)r
rrr�test_adler32start)s%z"ChecksumTestCase.test_adler32startcCsX|jtjdd�d�|jtjdd�d�|jtjdd�d�dS)Nrrri�)r	rr)r
rrr�test_adler32empty-sz"ChecksumTestCase.test_adler32emptycCs|j|d@|d@�dS)Nl��)r	)r
�seenZexpectedrrr�
assertEqual322szChecksumTestCase.assertEqual32cCs�|jtjdd�d�|jtjdd�d�|jtjdd�d�|jtjdd�d�|jtjd�tjdd��|jtjd�tjdd��dS)Nspenguinrl !�Kri���Ci��i��)rrrrr	)r
rrr�
test_penguins7s%zChecksumTestCase.test_penguinscCsrd}|jtj|�d�|jtjd�d�|jtj||�d�|jtjd�d�dS)Nsabcdefghijklmnopl�@u(sspami=��Cl
*i�O)r	rrr)r
�foorrr�test_crc32_adler32_unsigned@s
z,ChecksumTestCase.test_crc32_adler32_unsignedcCsdd}d}|jtj|�|�|jtj|�|�|jtjd�tjd��dS)Nsabcdefghijklmnopl�@u(sspam)r	�binasciirr)r
rZcrcrrr�test_same_as_binascii_crc32Hs
z,ChecksumTestCase.test_same_as_binascii_crc32N)rrrrrrrrrrr!rrrrrs	rc@s;eZdZededdddd�dd��Zd	S)
�ChecksumBigBufferTestCase�size��memuser�dry_runFcCsDdtd}|jtj|�d�|jtj|�d�dS)NsnyanriM"B>l�a
)rr	rrr)r
r#�datarrr�test_big_bufferSsz)ChecksumBigBufferTestCase.test_big_bufferN)rrrrrr(rrrrr"Qsr"c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ExceptionTestCasecCs |jtjtjdd�dS)NsERROR�
)�assertRaisesr�error�compress)r
rrr�
test_badlevel\szExceptionTestCase.test_badlevelcCs�|jttj�|jttj�|jttj�|jttj�xxddddfgfD]^}|jttj|�|jttj|�|jttj|�|jttj|�qeWdS)N�*��abc)r+�	TypeErrorrrrr-�
decompress)r
�argrrr�test_badargsbszExceptionTestCase.test_badargscCsI|jttjdtjd�|jttjdtjtjd�dS)Nrr)r+�
ValueErrorr�compressobj�DEFLATEDZ	MAX_WBITS)r
rrr�test_badcompressobjms	z%ExceptionTestCase.test_badcompressobjcCs|jttjd�dS)Nr���)r+r6r�
decompressobj)r
rrr�test_baddecompressobjtsz'ExceptionTestCase.test_baddecompressobjcCs<|jttj�jd�|jttj�jd�dS)Nrrr:)r+r6rr;�flush)r
rrr�test_decompressobj_badflushxsz-ExceptionTestCase.test_decompressobj_badflushN)rrrr.r5r9r<r>rrrrr)Zs
r)c@s(eZdZdd�Zdd�ZdS)�BaseCompressTestCasec
spd	�dd�}dj�fdd�td�D��}||t|�d}z||�Wdd}XdS)
Niz%%0%dx�rcs/g|]%}tjd��j�d��qS)��little)�randomZgetrandbits�to_bytes)�.0�i)�_1Mrr�
<listcomp>�s	zBBaseCompressTestCase.check_big_compress_buffer.<locals>.<listcomp>r*ri)�join�range�len)r
r#Z
compress_funcZfmtr'r)rGr�check_big_compress_buffersz.BaseCompressTestCase.check_big_compress_buffercCs}d|}ztj|d�}Wdd}X||�}z9|jt|�|�|jt|jd��d�Wdd}XdS)N�xrr)rr-r	rK�strip)r
r#Zdecompress_funcr'Z
compressedrrr�check_big_decompress_buffer�s
#z0BaseCompressTestCase.check_big_decompress_bufferN)rrrrLrOrrrrr?~sr?c@s�eZdZdd�Zdd�Zdd�Zededd	d
�dd��Zededd	d
�dd��Z	ede
dd	ddd�dd��ZdS)�CompressTestCasecCs,tjt�}|jtj|�t�dS)N)rr-�HAMLET_SCENEr	r3)r
�xrrr�test_speech�szCompressTestCase.test_speechcCsrtd}tj|�}|jtjt|��|�x3|t|�fD]}|jtj|�|�qKWdS)N�)rQrr-r	�	bytearrayr3)r
r'rR�obrrr�test_speech128�s

zCompressTestCase.test_speech128cCs9tjt�}|jtjdtj|dd��dS)NzAError -5 while decompressing data: incomplete or truncated streamrr:)rr-rQZassertRaisesRegexr,r3)r
rRrrr�test_incomplete_stream�sz'CompressTestCase.test_incomplete_streamr#ir%�cCs dd�}|j||�dS)NcSstj|d�S)Nr)rr-)�srrr�<lambda>�sz;CompressTestCase.test_big_compress_buffer.<locals>.<lambda>)rL)r
r#r-rrr�test_big_compress_buffer�sz)CompressTestCase.test_big_compress_bufferr@cCs|j|tj�dS)N)rOrr3)r
r#rrr�test_big_decompress_buffer�sz+CompressTestCase.test_big_decompress_buffer�drr&FcCsKd|}z3|jttj|d�|jttj|�Wdd}XdS)NrMr)r+�
OverflowErrorrr-r3)r
r#r'rrr�test_length_overflow�s

z%CompressTestCase.test_length_overflowNii)rrrrSrWrXrrr\r]rr`rrrrrP�s	%%rPc@seZdZdd�Zdd�Zdd�Zddd	d
dd�Zd
d�Zdd	d
dd�Zddd�Z	dd�Z
dd�Zdd�Zdd�Z
ejeed�d�dd��Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zed/d0��Zed1d2��Zed3d4��Zed5d6��Z d7d8�Z!d9d:�Z"e#d;e$dId=d>�d?d@��Z%e#d;e$dJd=dA�dBdC��Z&e#d;e'dDd=dEdFd�dGdH��Z(dS)K�CompressObjectTestCasecCs%td}tj|�}xk|t|�fD]W}tj�}|j|�}|j�}|jtj|j�|j|||�q,Wx�||ft|�t|�ffD]q\}}tj	�}	|	j
||�}
|	j�}|j||
|�|j|	jt
�|j|	jt
�q�WdS)NrT)rQrr-rUr7r=r+r,r	r;r3�assertIsInstance�unconsumed_tail�bytes�unused_data)r
ZdatasrcZdatazipr'�co�x1�x2Zv1Zv2�dco�y1�y2rrr�	test_pair�s
1z CompressObjectTestCase.test_pairc
Cs�d}tj}d}d}tj}tj|||||�}|jt�}|j�}tj|�}	|	j||�}
|	j�}|j	t|
|�tjd|d|d|d|d|d	d
�dS)Nr@��	�level�method�wbits�memLevel�strategy�zdictri�)
rr8Z
Z_FILTEREDr7r-rQr=r;r3r	)r
rorprqrrrsrfrgrhrirjrkrrr�test_compressoptions�s		z+CompressObjectTestCase.test_compressoptionsc	Cs�td}tj�}g}xDtdt|�d�D]*}|j|j|||d���q5W|j|j��dj|�}tj	�}|j
dj|��}|j�}|j|||�dS)NrTr�r)rQrr7rJrK�appendr-r=rIr;r3r	)	r
r'rf�bufsrF�combufrirjrkrrr�test_compressincremental�s
(z/CompressObjectTestCase.test_compressincrementalFNrv�@c
Cs�|p	t}|d}tj�}g}xDtdt|�|�D]*}|j|j||||���qAW|j|j��dj|�}	tj	|	�}
|j
|
t�|j||
�tj
�}g}xztdt|	�|�D]`}|j|j	|	|||���|jd|jdt|j��|jd|j�q�W|rk|j|j��n-x*|j	d�}|r�|j|�qnPqnW|jd|jdt|j��|jd|j�|j|dj|��dS)NrTrrz"(A) uct should be b'': not %d longz"(B) uct should be b'': not %d long)rQrr7rJrKrwr-r=rIr3rbrdr	r;rcre)
r
r=�source�cx�dcxr'rfrxrFryZdecombufri�chunkrrr�test_decompinc�s>
($z%CompressObjectTestCase.test_decompinccCs|jdd�dS)Nr=T)r�)r
rrr�test_decompincflush(sz*CompressObjectTestCase.test_decompincflushcCsY|p	t}|d}tj�}g}xDtdt|�|�D]*}|j|j||||���qAW|j|j��dj|�}|j	|tj
|�d�tj�}	g}|}
x^|
r%|	j
|
|�}|jt|�|kdt|�|f�|j|�|	j
}
q�W|j|	j��|j	|dj|�d�dS)NrTrrzcompressed data failurezchunk too big (%d>%d)zWrong data retrieved)rQrr7rJrKrwr-r=rIr	r3r;�assertFalserc)r
r|r}r~r'rfrxrFryri�cbrrrr�test_decompimax+s*
(	

z&CompressObjectTestCase.test_decompimaxcCs�td}tj�}g}xDtdt|�d�D]*}|j|j|||d���q5W|j|j��dj|�}|j	|tj
|�d�tj�}g}|}xr|r-dt|�d}	|j
||	�}
|jt|
�|	kdt|
�|	f�|j|
�|j
}q�W|rJ|j|j��nXxU|
r�|j
d|	�}
|jt|
�|	kdt|
�|	f�|j|
�qMW|j	|dj|�d	�dS)
NrTrrvrzcompressed data failurerr*zchunk too big (%d>%d)zWrong data retrieved)rQrr7rJrKrwr-r=rIr	r3r;r�rc)r
r=r'rfrxrFryrir�Z
max_lengthrrrr�test_decompressmaxlenFs6
(	

	z,CompressObjectTestCase.test_decompressmaxlencCs|jdd�dS)Nr=T)r�)r
rrr�test_decompressmaxlenflushfsz1CompressObjectTestCase.test_decompressmaxlenflushcCs<tj�}|jt|jdd�|jd|j�dS)Nrrr:)rr;r+r6r3r	rc)r
rirrr�test_maxlenmiscisz&CompressObjectTestCase.test_maxlenmisccCsQd}tj�}|j|d�}||j|j�7}|j|jd�dS)Ns
x�KLJMrr)rr;r3rcr	)r
ZcdatariZddatarrr�test_clear_unconsumed_tailos
z1CompressObjectTestCase.test_clear_unconsumed_tailc
	Cs�dddg}dd�|D�}td}x�|D]�}x�td�D]�}tj|�}|j|dd��}|j|�}|j|dd��}|j�}	|jtjd	j||||	g��|d
||f�~qFWq3WdS)NZ
Z_NO_FLUSH�Z_SYNC_FLUSHZZ_FULL_FLUSHcSs.g|]$}tt|�rtt|��qSr)�hasattrr�getattr)rEZoptrrrrH|s	z7CompressObjectTestCase.test_flushes.<locals>.<listcomp>rAr*i�rz*Decompress failed: flush mode=%i, level=%i)	rQrJrr7r-r=r	r3rI)
r
Zsync_optr'�syncro�obj�a�b�c�drrr�test_flushesxs

'z#CompressObjectTestCase.test_flushesr�zrequires zlib.Z_SYNC_FLUSHc	Cs�ddl}tjtj�}tj�}y|j�}Wn=tk
ryy|j�}Wntk
rt|}YnXYnX|jd�t	ddd|�}|j
|�}|jtj�}|j
||�}|j||d�dS)Nrr�i�	generatorz17K random source doesn't matchiD)rCrr7�Z_BEST_COMPRESSIONr;ZWichmannHill�AttributeErrorZRandom�seed�genblockr-r=r�r3r	)	r
rCrfri�genr'�first�secondZexpandedrrr�test_odd_flush�s 


z%CompressObjectTestCase.test_odd_flushcCsKtjtj�}|j|j��tj�}|j|j�d�dS)Nr)rr7r�rr=r;r	)r
rfrirrr�test_empty_flush�sz'CompressObjectTestCase.test_empty_flushcCs�t}|j�}tj|�dj|�}tjd|�}|j|�|j�}tj	d|�}|j
|j|�|j�|�tj	�}|jtj
|j|�dS)Nrrt)rQ�splitrCZshufflerIrr7r-r=r;r	r3r+r,)r
�hZwordsrtrfZcdrirrr�test_dictionary�s
#z&CompressObjectTestCase.test_dictionarycCstjdt�}tjdt�}tdd�}|j|�|jtj�}|j|dd��|jtj�}|j|dd��|jtj�}|j|j|�|�|j|j|�|dd��|j|j|�|dd��dS)Nrti�i�r^i����i����)	rr7rQr;r-r=r�r	r3)r
rfZdoZpiece�d0�d1Zd2rrr�test_dictionary_streaming�s))#z0CompressObjectTestCase.test_dictionary_streamingcCs�d}|jtj|�d�|jtjtj|dd��tj�}|j|dd��}||j�7}|j|d�dS)Nsx�K���Esfoo����r�)r	rr3r+r,r;r=)r
rRri�yrrr�!test_decompress_incomplete_stream�s#z8CompressObjectTestCase.test_decompress_incomplete_streamcCs�d}tj�}|j|j�|j|dd��|j|j�|j|dd��|j|j�|j�|j|j�dS)Nsx�K���Er�r�r�)rr;r��eofr3rr=)r
rRrirrr�test_decompress_eof�s
z*CompressObjectTestCase.test_decompress_eofcCsgd}tj�}|j|j�|j|dd��|j|j�|j�|j|j�dS)Nsx�K���Er�r�)rr;r�r�r3r=)r
rRrirrr�%test_decompress_eof_incomplete_stream�s
z<CompressObjectTestCase.test_decompress_eof_incomplete_streamc

Cs�d}d}tj|�}||}xXdD]P}xGddt|�t|�fD]'}tj�}d}x�tdt|�|�D]�}	|	t|�kr�|j|jd�n|dkr�||j||	|	|��7}|j|jd�q�||j|j||	|	|�|�7}q�W||j	�7}|j
|j�|j||�|j|jd�|j|j|�qQWq,WdS)	Nsabcdefghijklmnopqrstuvwxyzs
0123456789r��rr@r)rr�)rr-rKr;rJr	rer3rcr=rr�)
r
r|Z	remainderr�rR�maxlen�steprir'rFrrr�test_decompress_unused_data�s*

%!	&z2CompressObjectTestCase.test_decompress_unused_datacCsmd}d}tj|�}tj�}|j|d�~tj|�}|j|j�|dd��dS)NsabcdefghijklmnopqrstuvwxyzsQWERTYUIOPASDFGHJKLZXCVBNMr)rr-r;r3r	r=)r
Zinput1Zinput2r'rirrr�test_flush_with_freed_inputsz2CompressObjectTestCase.test_flush_with_freed_inputc	Cst}tttd�j�d�}tjtj�}g}|j|j|��|j	�}|dd�}|j|j|��|j|j
��dj|�}|j|j|��|j|j
��dj|�}|jtj
|�||�|jtj
|�||�dS)N�asciir)rQrd�str�swapcaserr7r�rwr-rr=rIr	r3)	r
Zdata0Zdata1Zc0�bufs0Zc1�bufs1�s0�s1rrr�test_compresscopysz(CompressObjectTestCase.test_compresscopycCs:tj�}|jt�|j�|jt|j�dS)N)rr7r-rQr=r+r6r)r
r�rrr�test_badcompresscopy3s

z+CompressObjectTestCase.test_badcompresscopyc	Cs�t}tj|�}|j|t�tj�}g}|j|j|dd���|j�}|dd�}|j|j|dd���dj	|�}|j|j|dd���dj	|�}|j
||�|j
||�dS)N� r)rQrr-rbrdr;rwr3rrIr	)	r
r'�compr�r�r�r�r�r�rrr�test_decompresscopy;s   z*CompressObjectTestCase.test_decompresscopycCsItjt�}tj�}|j|�|j�|jt|j�dS)N)	rr-rQr;r3r=r+r6r)r
r'r�rrr�test_baddecompresscopySs


z-CompressObjectTestCase.test_baddecompresscopycCs]xVttjd�D]A}|jttjf��!tjtjtj	�|�WdQXqWdS)Nr)
rJ�pickle�HIGHEST_PROTOCOLr+r2�
PicklingError�dumpsrr7r�)r
�protorrr�test_compresspickle\sz*CompressObjectTestCase.test_compresspicklecCsWxPttjd�D];}|jttjf��tjtj�|�WdQXqWdS)Nr)	rJr�r�r+r2r�r�rr;)r
r�rrr�test_decompresspickleasz,CompressObjectTestCase.test_decompresspickler#ir%rYcs5tjd���fdd�}|j||�dS)Nrcs�j|��j�S)N)r-r=)rZ)r�rrr[kszACompressObjectTestCase.test_big_compress_buffer.<locals>.<lambda>)rr7rL)r
r#r-r)r�rr\hsz/CompressObjectTestCase.test_big_compress_bufferr@cs2tj���fdd�}|j||�dS)Ncs�j|��j�S)N)r3r=)rZ)r�rrr[qszCCompressObjectTestCase.test_big_decompress_buffer.<locals>.<lambda>)rr;rO)r
r#r3r)r�rr]nsz1CompressObjectTestCase.test_big_decompress_bufferr^rr&c
Cscd|}tjd�}tj�}z0|jt|j|�|jt|j|�Wdd}XdS)NrMr)rr7r;r+r_r-r3)r
r#r'r�r�rrrr`ts
z+CompressObjectTestCase.test_length_overflowii))rrrrlrurzr�r�r�r�r�r�r�r��unittest�
skipUnlessr�rr�r�r�r�r�r�r�r�r��requires_Compress_copyr�r��requires_Decompress_copyr�r�r�r�rrr\r]rr`rrrrra�s<) 	!


		%%raics�|dk	r|j|�n|j�||ks=|dkrF|}nt�}xCtd||�D]/}|t�fdd�t|�D��7}qbW|S)zDlength-byte stream of random data from a seed (in step-byte blocks).Nr@rc3s|]}�dd�VqdS)r�Nr)rErR)�randintrr�	<genexpr>�szgenblock.<locals>.<genexpr>)r�r�rdrJ)r�Zlengthr�r�ZblocksrFr)r�rr��s			-r�csK|dk	r�j|�n|jd����fdd�t|�D�S)z=Return a list of number lines randomly chosen from the sourceN�
csg|]}�j���qSr)Zchoice)rE�n)r��sourcesrrrH�s	z choose_lines.<locals>.<listcomp>)r�r�rJ)r|Znumberr�r�r)r�r�r�choose_lines�sr�s�
LAERTES

       O, fear me not.
       I stay too long: but here my father comes.

       Enter POLONIUS

       A double blessing is a double grace,
       Occasion smiles upon a second leave.

LORD POLONIUS

       Yet here, Laertes! aboard, aboard, for shame!
       The wind sits in the shoulder of your sail,
       And you are stay'd for. There; my blessing with thee!
       And these few precepts in thy memory
       See thou character. Give thy thoughts no tongue,
       Nor any unproportioned thought his act.
       Be thou familiar, but by no means vulgar.
       Those friends thou hast, and their adoption tried,
       Grapple them to thy soul with hoops of steel;
       But do not dull thy palm with entertainment
       Of each new-hatch'd, unfledged comrade. Beware
       Of entrance to a quarrel, but being in,
       Bear't that the opposed may beware of thee.
       Give every man thy ear, but few thy voice;
       Take each man's censure, but reserve thy judgment.
       Costly thy habit as thy purse can buy,
       But not express'd in fancy; rich, not gaudy;
       For the apparel oft proclaims the man,
       And they in France of the best rank and station
       Are of a most select and generous chief in that.
       Neither a borrower nor a lender be;
       For loan oft loses both itself and friend,
       And borrowing dulls the edge of husbandry.
       This above all: to thine ownself be true,
       And it must follow, as the night the day,
       Thou canst not then be false to any man.
       Farewell: my blessing season this in thee!

LAERTES

       Most humbly do I take my leave, my lord.

LORD POLONIUS

       The time invites you; go; your servants tend.

LAERTES

       Farewell, Ophelia; and remember well
       What I have said to you.

OPHELIA

       'Tis in my memory lock'd,
       And you yourself shall keep the key of it.

LAERTES

       Farewell.
cCs tjtttttt�dS)N)rZrun_unittestrrr"r)rPrarrrr�	test_main�sr��__main__)"r�Ztestrr r�rC�sysZtest.supportrrr�
import_modulerr�r�r7r�r;r�ZTestCaserrr"r)�objectr?rPrar�r�rQr�r�mainrrrr�<module>s6		3	$ *��G