Your IP : 216.73.217.129


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_zlib.cpython-35.opt-2.pyc



���]Ӂ�@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�ZdZGdd�d�Ze dkr�ej!�dS)�N)�support)�
bigmemtest�_1G�_4G�zlib�copyzrequires Compress.copy()zrequires Decompress.copy()c@seZdZdd�ZdS)�VersionTestCasecCs"|jtjdtjd�dS)Nr)�assertEqualr�ZLIB_RUNTIME_VERSION�ZLIB_VERSION)�self�r
�./opt/alt/python35/lib64/python3.5/test_zlib.py�test_library_versionsz$VersionTestCase.test_library_versionN)�__name__�
__module__�__qualname__rr
r
r
rrsrc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�ChecksumTestCasecCsB|jtjd�tjdd��|jtjdd��dS)N�rsabcl��)r	r�crc32�
assertTrue)rr
r
r�test_crc32start s%z ChecksumTestCase.test_crc32startcCsX|jtjdd�d�|jtjdd�d�|jtjdd�d�dS)Nrr�i�)r	rr)rr
r
r�test_crc32empty$sz ChecksumTestCase.test_crc32emptycCsB|jtjd�tjdd��|jtjdd��dS)Nrrsabcl��)r	r�adler32r)rr
r
r�test_adler32start)s%z"ChecksumTestCase.test_adler32startcCsX|jtjdd�d�|jtjdd�d�|jtjdd�d�dS)Nrrri�)r	rr)rr
r
r�test_adler32empty-sz"ChecksumTestCase.test_adler32emptycCs�|jtjdd�d�|jtjdd�d�|jtjdd�d�|jtjdd�d�|jtjd�tjdd��|jtjd�tjdd��dS)Nspenguinrl !�Kri���Ci��i��)r	rrr)rr
r
r�
test_penguins2s%zChecksumTestCase.test_penguinscCsrd}|jtj|�d�|jtjd�d�|jtj||�d�|jtjd�d�dS)Nsabcdefghijklmnopl�@u(sspami=��Cl
*i�O)r	rrr)r�foor
r
r�test_crc32_adler32_unsigned;s
z,ChecksumTestCase.test_crc32_adler32_unsignedcCsdd}d}|jtj|�|�|jtj|�|�|jtjd�tjd��dS)Nsabcdefghijklmnopl�@u(sspam)r	�binasciirr)rrZcrcr
r
r�test_same_as_binascii_crc32Cs
z,ChecksumTestCase.test_same_as_binascii_crc32N)
rrrrrrrrrr!r
r
r
rrs	rc@s;eZdZededdddd�dd��Zd	S)
�ChecksumBigBufferTestCase�size��memuser�dry_runFcCsDdtd}|jtj|�d�|jtj|�d�dS)NsnyanriM"B>l�a
)rr	rrr)rr#�datar
r
r�test_big_bufferNsz)ChecksumBigBufferTestCase.test_big_bufferN)rrrrrr(r
r
r
rr"Lsr"c@saeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zej	dd��Z
d
S)�ExceptionTestCasecCs |jtjtjdd�dS)NsERROR�
)�assertRaisesr�error�compress)rr
r
r�
test_badlevelWszExceptionTestCase.test_badlevelcCs�|jttj�|jttj�|jttj�|jttj�xxddddfgfD]^}|jttj|�|jttj|�|jttj|�|jttj|�qeWdS)N�*��abc)r+�	TypeErrorrrrr-�
decompress)r�argr
r
r�test_badargs]szExceptionTestCase.test_badargscCsI|jttjdtjd�|jttjdtjtjd�dS)Nrr)r+�
ValueErrorr�compressobj�DEFLATED�	MAX_WBITS)rr
r
r�test_badcompressobjhs	z%ExceptionTestCase.test_badcompressobjcCs|jttjd�dS)Nr���)r+r6r�
decompressobj)rr
r
r�test_baddecompressobjosz'ExceptionTestCase.test_baddecompressobjcCs<|jttj�jd�|jttj�jd�dS)Nrrr;)r+r6rr<�flush)rr
r
r�test_decompressobj_badflushssz-ExceptionTestCase.test_decompressobj_badflushcCs�|jtd��tjddtjd�WdQRX|jtd��"tj�jdtjd�WdQRX|jtd��tj�jtjd�WdQRXdS)Nz
int too larger�r)�assertRaisesRegex�
OverflowErrorrr3�sys�maxsizer<r>)rr
r
r�
test_overflowxs!$zExceptionTestCase.test_overflowN)rrrr.r5r:r=r?rZcpython_onlyrEr
r
r
rr)Usr)c@s(eZdZdd�Zdd�ZdS)�BaseCompressTestCasec
sbd�dj�fdd�td�D��}||t|�d}z||�Wdd}XdS)Nircs/g|]%}tjd��j�d��qS)��little)�random�getrandbits�to_bytes)�.0�i)�_1Mr
r�
<listcomp>�s	zBBaseCompressTestCase.check_big_compress_buffer.<locals>.<listcomp>r*ri)�join�range�len)rr#Z
compress_funcr'r
)rNr�check_big_compress_buffer�sz.BaseCompressTestCase.check_big_compress_buffercCs}d|}ztj|d�}Wdd}X||�}z9|jt|�|�|jt|jd��d�Wdd}XdS)N�xrr)rr-r	rR�strip)rr#Zdecompress_funcr'�
compressedr
r
r�check_big_decompress_buffer�s
#z0BaseCompressTestCase.check_big_decompress_bufferN)rrrrSrWr
r
r
rrF�srFc@s�eZdZdd�Zdd�Zdd�Zededd	d
�dd��Zededd	d
�dd��Z	ede
d	d�dd��Zdd�Ze
jejdkd�ede
dd	d�dd���ZdS)�CompressTestCasecCs,tjt�}|jtj|�t�dS)N)rr-�HAMLET_SCENEr	r3)r�xr
r
r�test_speech�szCompressTestCase.test_speechcCsrtd}tj|�}|jtjt|��|�x3|t|�fD]}|jtj|�|�qKWdS)N�)rYrr-r	�	bytearrayr3)rr'rZ�obr
r
r�test_speech128�s

zCompressTestCase.test_speech128cCs9tjt�}|jtjdtj|dd��dS)NzAError -5 while decompressing data: incomplete or truncated streamrr;)rr-rYrAr,r3)rrZr
r
r�test_incomplete_stream�sz'CompressTestCase.test_incomplete_streamr#ir%�cCs dd�}|j||�dS)NcSstj|d�S)Nr)rr-)�sr
r
r�<lambda>�sz;CompressTestCase.test_big_compress_buffer.<locals>.<lambda>)rS)rr#r-r
r
r�test_big_compress_buffer�sz)CompressTestCase.test_big_compress_buffer�cCs|j|tj�dS)N)rWrr3)rr#r
r
r�test_big_decompress_buffer�sz+CompressTestCase.test_big_decompress_bufferrcCs?td}tj|d�}|jtj|d|�|�dS)Nr*rr@)rYrr-r	r3)rr#r'rVr
r
r�test_large_bufsize�s
z#CompressTestCase.test_large_bufsizecCsBtd}tj|d�}|jtj|dt��|�dS)Nr*rr@)rYrr-r	r3�	CustomInt)rr'rVr
r
r�test_custom_bufsize�s
z$CompressTestCase.test_custom_bufsize� zrequires 64bit platform�dr$cCsKd|}z/tj|d�}|jtj|�|�Wdd}}XdS)NrTr)rr-r	r3)rr#r'�compr
r
r�test_64bit_compress�s

z$CompressTestCase.test_64bit_compressNiil)rrrr[r_r`rrrdrfrrgri�unittest�
skipUnlessrCrDrmr
r
r
rrX�s	%%!rXc@s�eZdZdd�Zdd�Zdd�Zddd	d
dd�Zd
d�Zdd	d
dd�Zddd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zejeed�d �d!d"��Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zed5ed6d7�d8d9��Z d:d;�Z!e"d<d=��Z#e"d>d?��Z$e%d@dA��Z&e%dBdC��Z'dDdE�Z(dFdG�Z)ed5e*d\d6dI�dJdK��Z+ed5e*d]d6dL�dMdN��Z,eje-j.d^kdP�ed5edQd6dR�dSdT���Z/eje-j.d_kdP�ed5edQd6dI�dUdV���Z0eje-j.d`kdP�ed5edQd6dW�dXdY���Z1dZd[�Z2dS)a�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)Nr\)rYrr-r]r7r>r+r,r	r<r3�assertIsInstance�unconsumed_tail�bytes�unused_data)rZdatasrcZdatazipr'�co�x1�x2Zv1Zv2�dco�y1�y2r
r
r�	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)Nre��	�level�method�wbits�memLevel�strategy�zdictri�)
rr8�
Z_FILTEREDr7r-rYr>r<r3r	)rr~rr�r�r�rurvrwrxryrzr
r
r�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)Nr\r�r)rYrr7rQrR�appendr-r>rPr<r3r	)	rr'ru�bufsrM�combufrxryrzr
r
r�test_compressincrementals
(z/CompressObjectTestCase.test_compressincrementalFNr��@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)Nr\rrz"(A) uct should be b'': not %d longz"(B) uct should be b'': not %d long)rYrr7rQrRr�r-r>rPr3rqrsr	r<rrrt)
rr>�source�cx�dcxr'rur�rMr�Zdecombufrx�chunkr
r
r�test_decompincs>
($z%CompressObjectTestCase.test_decompinccCs|jdd�dS)Nr>T)r�)rr
r
r�test_decompincflush8sz*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)Nr\rrzcompressed data failurezchunk too big (%d>%d)zWrong data retrieved)rYrr7rQrRr�r-r>rPr	r3r<�assertFalserr)rr�r�r�r'rur�rMr�rx�cbr�r
r
r�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)
Nr\rr�rzcompressed data failurerr*zchunk too big (%d>%d)zWrong data retrieved)rYrr7rQrRr�r-r>rPr	r3r<r�rr)rr>r'rur�rMr�rxr�Z
max_lengthr�r
r
r�test_decompressmaxlenVs6
(	

	z,CompressObjectTestCase.test_decompressmaxlencCs|jdd�dS)Nr>T)r�)rr
r
r�test_decompressmaxlenflushvsz1CompressObjectTestCase.test_decompressmaxlenflushcCs<tj�}|jt|jdd�|jd|j�dS)Nrrr;)rr<r+r6r3r	rr)rrxr
r
r�test_maxlenmiscysz&CompressObjectTestCase.test_maxlenmisccCsdtd}|jt|�tj�tj|d�}tj�}|j|j|t	j
�|�dS)Nr*r)rYZ
assertGreaterrRr�DEF_BUF_SIZEr-r<r	r3rCrD)rr'rVrxr
r
r�test_maxlen_larges

z(CompressObjectTestCase.test_maxlen_largecCsUtd}tj|d�}tj�}|j|j|t��|dd��dS)Nr*rrk)rYrr-r<r	r3rh)rr'rVrxr
r
r�test_maxlen_custom�s
z)CompressObjectTestCase.test_maxlen_customcCsQd}tj�}|j|d�}||j|j�7}|j|jd�dS)Ns
x�KLJMrr)rr<r3rrr	)rZcdatarxZddatar
r
r�test_clear_unconsumed_tail�s
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)N�
Z_NO_FLUSH�Z_SYNC_FLUSH�Z_FULL_FLUSHcSs.g|]$}tt|�rtt|��qSr
)�hasattrr�getattr)rL�optr
r
rrO�s	z7CompressObjectTestCase.test_flushes.<locals>.<listcomp>rGr*i�rz*Decompress failed: flush mode=%i, level=%i)	rYrQrr7r-r>r	r3rP)
rZsync_optr'�syncr~�obj�a�b�c�dr
r
r�test_flushes�s

'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)rIrr7�Z_BEST_COMPRESSIONr<ZWichmannHill�AttributeError�Random�seed�genblockr-r>r�r3r	)	rrIrurx�genr'�first�secondZexpandedr
r
r�test_odd_flush�s 


z%CompressObjectTestCase.test_odd_flushcCsKtjtj�}|j|j��tj�}|j|j�d�dS)Nr)rr7r�rr>r<r	)rrurxr
r
r�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)Nrr�)rY�splitrI�shufflerPrr7r-r>r<r	r3r+r,)r�hZwordsr�ruZcdrxr
r
r�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)Nr�i�i�rki����i����)	rr7rYr<r-r>r�r	r3)rru�doZpiece�d0�d1Zd2r
r
r�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rZrx�yr
r
r�!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rZrxr
r
r�test_decompress_eofs
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rZrxr
r
r�%test_decompress_eof_incomplete_streams
z<CompressObjectTestCase.test_decompress_eof_incomplete_streamc

Cs�d}d}tj|�}||}xUdD]M}xDddt|�t|�fD]$}tj�}d}x�tdt|�|�D]�}	|	t|�kr�|j|jd�|dkr�||j||	|	|��7}|j|jd�q�||j|j||	|	|�|�7}q�W||j	�7}|j
|j�|j||�|j|jd�|j|j|�qQWq,WdS)	Nsabcdefghijklmnopqrstuvwxyzs
0123456789r��rrer)rr�)rr-rRr<rQr	rtr3rrr>rr�)
rr�Z	remainderr�rZ�maxlen�steprxr'rMr
r
r�test_decompress_unused_datas*

%!	&z2CompressObjectTestCase.test_decompress_unused_datacCs�d}tjdtjd|�}|j|�|j�}tjdtjd|�}|j|�|j�}|j||�dS)Nsabcdefghijklmnopqrstuvwxyzr�r�)rr7r9r-r>r<r3r	)rr�rurlrx�uncompr
r
r�#test_decompress_raw_with_dictionary0sz:CompressObjectTestCase.test_decompress_raw_with_dictionarycCsmd}d}tj|�}tj�}|j|d�~tj|�}|j|j�|dd��dS)NsabcdefghijklmnopqrstuvwxyzsQWERTYUIOPASDFGHJKLZXCVBNMr)rr-r<r3r	r>)rZinput1Zinput2r'rxr
r
r�test_flush_with_freed_input8sz2CompressObjectTestCase.test_flush_with_freed_inputr#r%rcCs_td}tj|d�}tj�}|j|d�|j|j|�|dd��dS)Nr*r)rYrr-r<r3r	r>)rr#�inputr'rxr
r
r�test_flush_large_lengthDs

z.CompressObjectTestCase.test_flush_large_lengthcCsbtd}tj|d�}tj�}|j|d�|j|jt��|dd��dS)Nr*r)rYrr-r<r3r	r>rh)rr�r'rxr
r
r�test_flush_custom_lengthMs

z/CompressObjectTestCase.test_flush_custom_lengthc	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)rYrs�str�swapcaserr7r�r�r-rr>rPr	r3)	rZdata0Zdata1Zc0�bufs0�c1�bufs1�s0�s1r
r
r�test_compresscopyTsz(CompressObjectTestCase.test_compresscopycCs:tj�}|jt�|j�|jt|j�dS)N)rr7r-rYr>r+r6r)rr�r
r
r�test_badcompresscopyks

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)Nrjr)rYrr-rqrsr<r�r3rrPr	)	rr'rlr�r�r�r�r�r�r
r
r�test_decompresscopyss   z*CompressObjectTestCase.test_decompresscopycCsItjt�}tj�}|j|�|j�|jt|j�dS)N)	rr-rYr<r3r>r+r6r)rr'r�r
r
r�test_baddecompresscopy�s


z-CompressObjectTestCase.test_baddecompresscopycCs^xWttjd�D]B}|jttjf��!tjtjtj	�|�WdQRXqWdS)Nr)
rQ�pickle�HIGHEST_PROTOCOLr+r2�
PicklingError�dumpsrr7r�)r�protor
r
r�test_compresspickle�sz*CompressObjectTestCase.test_compresspicklecCsXxQttjd�D]<}|jttjf��tjtj�|�WdQRXqWdS)Nr)	rQr�r�r+r2r�r�rr<)rr�r
r
r�test_decompresspickle�sz,CompressObjectTestCase.test_decompresspickleiracs5tjd���fdd�}|j||�dS)Nrcs�j|��j�S)N)r-r>)rb)r�r
rrc�szACompressObjectTestCase.test_big_compress_buffer.<locals>.<lambda>)rr7rS)rr#r-r
)r�rrd�sz/CompressObjectTestCase.test_big_compress_bufferrecs2tj���fdd�}|j||�dS)Ncs�j|��j�S)N)r3r>)rb)r�r
rrc�szCCompressObjectTestCase.test_big_decompress_buffer.<locals>.<lambda>)rr<rW)rr#r3r
)r�rrf�sz1CompressObjectTestCase.test_big_decompress_bufferrjzrequires 64bit platformrkr$cCs�d|}tjd�}tj�}zF|j|�|j�}|j|�|j�}|j||�Wdd}}}XdS)NrTr)rr7r<r-r>r3r	)rr#r'rur�rlr�r
r
rrm�s
z*CompressObjectTestCase.test_64bit_compresscCs�d}d|}tj|�|}tj�}z@|j|�|j�}|j||j�|j||�Wdd}}}XdS)NsabcdefghijklmnoprT)rr-r<r3r>r	rt)rr#r'Zunusedrlr�r�r
r
r�test_large_unused_data�s
z-CompressObjectTestCase.test_large_unused_datar�cCs�d|}tj�}zUtj|d�}|j|d�|j�}|j||�|j|jd�Wdd}}}XdS)NrTrrr)rr<r-r3r>r	rr)rr#r'r�rlr�r
r
r�test_large_unconsumed_tail�s
z1CompressObjectTestCase.test_large_unconsumed_tailc
CsEtjdjdd�}t|d�dkp�t|d�dko�t|d�dkp�t|d�dko�t|d�dkp�t|d�dko�t|d�dk}tjd	dd
d�}|jt�|j�}|jtj	|d�t�|r"|jtj	|d�t�|jtj	|d�t�|j
tjd
��tj	|d�WdQRXtjd
d�}|j|j	|�t�tjd
d�}|j
tjd
��|j	|�WdQRXtjd	dd
d�}|jt�|j�}|jtj	|d�t�|jtj	|d�t�|r]|jtj	|d�t�|jtj	|d�t�tjd
d�}|j|j	|�t�tjd	dd
d�}|jt�|j�}|jtj	|d�t�tjd
d�}|j|j	|�t�tjd	dd
d�}|jt�|j�}|jtj	|d�t�|jtj	|d�t�tjd
d�}|j|j	|�t�tjd	dd
d�}|jt�|j�}	|jtj	|	d�t�|jtj	|	d�t�tjd�}|j|j	|	�t�dS) Nz.0�.r$rrrerar�r~r�r@rjzinvalid window size�r}��/r��)r�i�i�i�i����i����i�i�����r�r�r�)
rr
r��intr7r-rYr>r	r3rAr,r<)
r�vZsupports_wbits_0ruZzlib15rxZzlib9Z	deflate15Zdeflate9�gzipr
r
r�
test_wbits�sV,,Bz!CompressObjectTestCase.test_wbitsiilll)3rrrr{r�r�r�r�r�r�r�r�r�r�r�r�rnror�rr�r�r�r�r�r�r�r�r�r�rrr�r��requires_Compress_copyr�r��requires_Decompress_copyr�r�r�r�rrdrfrCrDrmr�r�r�r
r
r
rrp�sR) 		!


	!		%%((
(rpics�|dk	r|j|�|j�||ks:|dkr@|}t�}xCtd||�D]/}|t�fdd�t|�D��7}q\W|S)Nrerc3s|]}�dd�VqdS)r�Nr
)rLrZ)�randintr
r�	<genexpr>szgenblock.<locals>.<genexpr>)r�r�rsrQ)r��lengthr�r�ZblocksrMr
)r�rr�	s
		-r�csH|dk	r�j|�|jd����fdd�t|�D�S)N�
csg|]}�j���qSr
)�choice)rL�n)r��sourcesr
rrOs	z choose_lines.<locals>.<listcomp>)r�r�rQ)r�Znumberr�r�r
)r�r�r�choose_liness
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.
c@seZdZdd�ZdS)rhcCsdS)Nrkr
)rr
r
r�__int__bszCustomInt.__int__N)rrrr�r
r
r
rrhasrh�__main__)"rnZtestrr r�rIrCZtest.supportrrr�
import_modulerror�r7r�r<r�ZTestCaserrr"r)�objectrFrXrpr�r�rYrhr�mainr
r
r
r�<module>s8		.	-7��3G