Your IP : 216.73.216.213


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



���]�0�@s�ddlmZmZmZddlZddlZddlZddlZddlZGdd�dej	�Z
Gdd�d�ZGdd�de�ZGd	d
�d
e�Z
dS)�)�findfile�TESTFN�unlinkNc@s(eZdZdd�Zdd�ZdS)�UnseekableIOcCs
tj�dS)N)�io�UnsupportedOperation)�self�r	�//opt/alt/python35/lib64/python3.5/audiotests.py�tell	szUnseekableIO.tellcOs
tj�dS)N)rr)r�args�kwargsr	r	r
�seekszUnseekableIO.seekN)�__name__�
__module__�__qualname__rrr	r	r	r
rsrc@s:eZdZdZdd�Zdd�Zdd�ZdS)	�
AudioTestsFcCsd|_|_dS)N)�f�fout)rr	r	r
�setUpszAudioTests.setUpcCsF|jdk	r|jj�|jdk	r8|jj�tt�dS)N)r�closerrr)rr	r	r
�tearDowns


zAudioTests.tearDowncCsq|j|j�|�|j|j�|�|j|j�|�|j|j�|�|j|j�|�|j|j�|�|j�}|j|||||||f�|j|j|�|j|j	|�|j|j
|�|j|j|�|j|j|�|j|j
|�xFttjd�D]1}	tj||	�}
|jtj|
�|�q8WdS)N�)�assertEqual�getnchannels�getsampwidth�getframerate�
getnframesZgetcomptypeZgetcompname�	getparams�	nchannels�	sampwidth�	framerate�nframes�comptype�compname�range�pickle�HIGHEST_PROTOCOL�dumps�loads)rrrr r!r"r#r$�params�proto�dumpr	r	r
�check_paramss$	zAudioTests.check_paramsN)rrr�close_fdrrr-r	r	r	r
rsrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#S)$�AudioWriteTestscCsf|jj|d�}|_|j|j�|j|j�|j|j�|j	|j
|j�|S)N�wb)�module�openr�setnchannelsr�setsampwidthr �setframerater!�setcomptyper#r$)r�testfilerr	r	r
�create_file7szAudioWriteTests.create_filec
Cs�|jj|d���}|j|j�|j�|j|j�|j�|j|j�|j�|j|j	�|�|j|j
|�|�WdQRXdS)N�rb)r1r2rrrrr rr!r�
readframes)rr7r"�framesrr	r	r
�
check_file?szAudioWriteTests.check_filecCsn|jt�}|j|j�|j|j�|j||j|j|j	|j|j
|j�|j�dS)N)
r8r�
setnframesr"�writeframesr;r-rr r!r#r$r)rrr	r	r
�test_write_paramsGsz!AudioWriteTests.test_write_paramsc%Cs�|j|jj��"|jjtd��WdQRXWdQRX|j|jj��8ttd��!}|jj|��WdQRXWdQRXWdQRXdS)Nr0)�assertRaisesr1�Errorr2r)rr7r	r	r
�&test_write_context_manager_calls_closeOsz6AudioWriteTests.test_write_context_manager_calls_closecCs`ttd��}|jj|��M}|j|j�|j|j�|j|j�|j	|j
|j�WdQRX|j|j
|j�WdQRXttd���}|jj|��k}|j|j�j
�|j�}|j|j|j�|j|j|j�|j|j|j�WdQRX|js?|j|j��|j|j
|j�WdQRXdS)Nr0r9)r2rr1r3rr4r r5r!r6r#r$r�closedr.�assertFalse�getfpr�assertIsNone)rr7rr*r	r	r
�#test_context_manager_with_open_fileZs"	z3AudioWriteTests.test_context_manager_with_open_filecCs|jjtd��M}|j|j�|j|j�|j|j�|j	|j
|j�WdQRX|jjt��k}|j|j
�j�|j�}|j|j|j�|j|j|j�|j|j|j�WdQRX|js|j|j
��dS)Nr0)r1r2rr3rr4r r5r!r6r#r$rDrErCrrr.rF)rrr*r	r	r
�"test_context_manager_with_filenamems	z2AudioWriteTests.test_context_manager_with_filenamecCsV|jt�}|j|j�|j|j�|j�|jt|j|j�dS)N)r8rr=r"r>r;rr<)rrr	r	r
�
test_write~s

zAudioWriteTests.test_writecCs\|jt�}|j|j�|jt|j��|j�|jt|j|j�dS)N)	r8rr=r"r>�	bytearrayr;rr<)rrr	r	r
�test_write_bytearray�s

z$AudioWriteTests.test_write_bytearraycCsb|jt�}|j|j�|jtjd|j��|j�|jt|j|j�dS)N�h)	r8rr=r"r>�arrayr;rr<)rrr	r	r
�test_write_array�s

z AudioWriteTests.test_write_arraycCs\|jt�}|j|j�|jt|j��|j�|jt|j|j�dS)N)	r8rr=r"r>�
memoryviewr;rr<)rrr	r	r
�test_write_memoryview�s

z%AudioWriteTests.test_write_memoryviewcCs�ttd��Q}|jd�|j|�}|j|jd�|j|j�|j�WdQRXttd��9}|j	|j
d�d�|j||j|j�WdQRXdS)Nr0s
ababagalamagarr9�
)r2r�writer8r=r"r>r;rr�readr<)rr7rr	r	r
�test_incompleted_write�s
z&AudioWriteTests.test_incompleted_writecCs�ttd���}|jd�|j|�}|j|j�|j|j}|j|j	d|��|j|j	|d��|j
�WdQRXttd��9}|j|jd�d�|j
||j|j	�WdQRXdS)Nr0s
ababagalamagar9rQ)r2rrRr8r=r"rr r>r;rrrSr<)rr7r�	framesizer	r	r
�test_multiple_writes�s
z$AudioWriteTests.test_multiple_writescCs�ttd��Q}|jd�|j|�}|j|jd�|j|j�|j�WdQRXttd��9}|j	|j
d�d�|j||j|j�WdQRXdS)Nr0s
ababagalamagarr9rQ)r2rrRr8r=r"r>r;rrrSr<)rr7rr	r	r
�test_overflowed_write�s
z%AudioWriteTests.test_overflowed_writecCso|jt��'}|j|j�|j|j�WdQRXttd�� }|j||j|j�WdQRXdS)Nr9)r8rr=r"r>r;rr<)rrr7r	r	r
�test_unseekable_read�s
z$AudioWriteTests.test_unseekable_readcCsottd��@}|j|��'}|j|j�|j|j�WdQRXWdQRX|jt|j|j�dS)Nr0)rrr8r=r"r>r;r<)rr7rr	r	r
�test_unseekable_write�s
z%AudioWriteTests.test_unseekable_writec"Cs�ttd���}|jd�|j|�}|j|jd�y|j|j�Wntk
rjYnXy|j	�Wntk
r�YnXWdQRXt
td��=}|j|jd�d�|j
||jd|j�WdQRXdS)Nr0s
ababagalamagarr9rQ)rrrRr8r=r"r>r;�OSErrorrr2rrSr<)rr7rr	r	r
�!test_unseekable_incompleted_write�s


z1AudioWriteTests.test_unseekable_incompleted_writec$Csttd���}|jd�|j|�}|j|jd�y|j|j�Wntk
rjYnXy|j	�Wntk
r�YnXWdQRXt
td��X}|j|jd�d�|j
|j}|j||jd|jd|��WdQRXdS)Nr0s
ababagalamagarr9rQ)rrrRr8r=r"r>r;rZrr2rrSrr r<)rr7rrUr	r	r
� test_unseekable_overflowed_write�s 


z0AudioWriteTests.test_unseekable_overflowed_writeN)rrrr8r<r?rBrGrHrIrKrNrPrTrVrWrXrYr[r\r	r	r	r
r/5s"r/c@s^eZdZedd��Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�AudioTestsWithSourceFilecCst|jdd�|_dS)NZsubdirZ	audiodata)rZsndfilename�sndfilepath)�clsr	r	r
�
setUpClass�sz#AudioTestsWithSourceFile.setUpClasscCsQ|jj|j�}|_|j||j|j|j|j|j	|j
�dS)N)r1r2r^rr-rr r!�sndfilenframesr#r$)rrr	r	r
�test_read_paramssz)AudioTestsWithSourceFile.test_read_paramscCs�t|jd��P}|jj|�}|_|j|j�|j�|j|j|j�WdQRXtt	d��z}|jj|d�}|_
|j|j�|j|jj��|j�WdQRX|j|j|j�|j�WdQRXdS)Nr9r0)
r2r^r1rrDrCrrr.rrr@rA)rr7rrr	r	r
�
test_closes
z#AudioTestsWithSourceFile.test_closecCs�|j|j}|jdd|�}|jd|d|�}|jj|j�}|_|j|jd�d�|j|j	�d�|j|jd�|�|j
�|j	�}|j|d�|j|jd�|�|j	�}|j|d�|j|jd�|�|j|�|j|jd�|�|j|�|j|jd�|�|j|jj
��|jd�WdQRX|j|jj
��|j|j�d�WdQRXdS)N��r�r���)rr r;r1r2r^rrr:r�rewindZsetposr@rAr)rrUZchunk1Zchunk2rZpos0Zpos2r	r	r
�	test_reads,


z"AudioTestsWithSourceFile.test_readcCs|jj|j�}|_|jjtd�}|_|j|j��d}|j�}x:|dkr�|d7}|j	|j
|��||8}q`W|j�|jjtd�}|_|j�|j
|j�|j��|j
|j
|j��|j
|j���dS)Nr0rrr9)r1r2r^rrrZ	setparamsrrr>r:rrhr)rrr�i�nr	r	r
�	test_copy,s


z"AudioTestsWithSourceFile.test_copycCs-ttd��C}|jd�t|jd��}|j|j��WdQRXWdQRXttd���}|j|jd�d�|jj|d���}|j|j�|j�|j|j	�|j
�|j|j�|j�|j|j
�|j�|j|j|j�|j�WdQRXWdQRXdS)Nr0s
ababagalamagar9rQ)r2rrRr^rSrr1rrrr rr!rrar:r"r;)rr7rr	r	r
�test_read_not_from_start=s
!z1AudioTestsWithSourceFile.test_read_not_from_startN)
rrr�classmethodr`rbrcrirlrmr	r	r	r
r]�sr])Ztest.supportrrrZunittestrMrr&�sys�FileIOrrr/r]r	r	r	r
�<module>s%�