Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/audiotests.cpython-39.opt-1.pyc

a

��gg0�@spddlmZmZmZddlZddlZddlZGdd�dej�ZGdd�d�Z	Gdd�de	�Z
Gd	d
�d
e	�ZdS)�)�findfile�TESTFN�unlinkNc@seZdZdd�Zdd�ZdS)�UnseekableIOcCs
tj�dS�N��io�UnsupportedOperation��self�r�+/usr/local/lib/python3.9/test/audiotests.py�tellszUnseekableIO.tellcOs
tj�dSrr)r�args�kwargsrrr
�seekszUnseekableIO.seekN)�__name__�
__module__�__qualname__rrrrrr
rsrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
AudioTestsFcCsd|_|_dSr)�f�foutr
rrr
�setUpszAudioTests.setUpcCs4|jdur|j��|jdur(|j��tt�dSr)r�closerrrr
rrr
�tearDowns




zAudioTests.tearDownc	Cs
|�|��|�|�|��|�|�|��|�|�|��|�|�|��|�|�|��|�|��}|�|||||||f�|�|j|�|�|j	|�|�|j
|�|�|j|�|�|j|�|�|j
|�ttjd�D]"}	t�||	�}
|�t�|
�|�q�dS)N�)�assertEqual�getnchannels�getsampwidth�getframerate�
getnframesZgetcomptypeZgetcompname�	getparams�	nchannels�	sampwidth�	framerate�nframes�comptype�compname�range�pickle�HIGHEST_PROTOCOL�dumps�loads)rrr"r#r$r%r&r'�params�proto�dumprrr
�check_paramss&�zAudioTests.check_paramsN)rrr�close_fdrrr0rrrr
rsrc@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)$�AudioWriteTestscCsL|j�|d�}|_|�|j�|�|j�|�|j�|�	|j
|j�|S�N�wb)�module�openr�setnchannelsr"�setsampwidthr#�setframerater$�setcomptyper&r'�r�testfilerrrr
�create_file6szAudioWriteTests.create_filecCs�|j�|d��h}|�|��|j�|�|��|j�|�|��|j�|�|�	�|�|�|�
|�|�Wd�n1s|0YdS�N�rb)r5r6rrr"rr#rr$r �
readframes)rr<r%�framesrrrr
�
check_file>szAudioWriteTests.check_filec	CsP|�t�}|�|j�|�|j�|�||j|j|j	|j|j
|j�|��dSr)
r=r�
setnframesr%�writeframesrAr0r"r#r$r&r'r�rrrrr
�test_write_paramsFs
�z!AudioWriteTests.test_write_paramsc
Cs�|�|jj��>|j�td��Wd�n1s40YWd�n1sR0Y|�|jj��fttd��<}|j�|��Wd�n1s�0YWd�n1s�0YWd�n1s�0YdSr3)�assertRaisesr5�Errorr6r)rr<rrr
�&test_write_context_manager_calls_closeNs<z6AudioWriteTests.test_write_context_manager_calls_closec	Csfttd���}|j�|��D}|�|j�|�|j�|�|j�|�	|j
|j�Wd�n1sb0Y|�|j
|j�Wd�n1s�0Yttd���}|j�|��X}|�|��j
�|��}|�|j|j�|�|j|j�|�|j|j�Wd�n1�s0Y|j�s2|�|���|�|j
|j�Wd�n1�sX0YdS)Nr4r?)r6rr5r7r"r8r#r9r$r:r&r'r�closedr1�assertFalse�getfpr!�assertIsNone)rr<rr-rrr
�#test_context_manager_with_open_fileYs"..0z3AudioWriteTests.test_context_manager_with_open_filecCs�|j�td��D}|�|j�|�|j�|�|j�|�	|j
|j�Wd�n1sX0Y|j�t��X}|�|�
�j�|��}|�|j|j�|�|j|j�|�|j|j�Wd�n1s�0Y|js�|�|�
��dSr3)r5r6rr7r"r8r#r9r$r:r&r'rKrLrJr!rr1rM)rrr-rrr
�"test_context_manager_with_filenamels..z2AudioWriteTests.test_context_manager_with_filenamecCs@|�t�}|�|j�|�|j�|��|�t|j|j�dSr)r=rrCr%rDrArrBrErrr
�
test_write}s

zAudioWriteTests.test_writecCsD|�t�}|�|j�|�t|j��|��|�t|j|j�dSr)	r=rrCr%rD�	bytearrayrArrBrErrr
�test_write_bytearray�s

z$AudioWriteTests.test_write_bytearraycCsH|�t�}|�|j�|�t�d|j��|��|�t|j|j�dS)N�h)	r=rrCr%rD�arrayrArrBrErrr
�test_write_array�s

z AudioWriteTests.test_write_arraycCsD|�t�}|�|j�|�t|j��|��|�t|j|j�dSr)	r=rrCr%rD�
memoryviewrArrBrErrr
�test_write_memoryview�s

z%AudioWriteTests.test_write_memoryviewcCs�ttd��H}|�d�|�|�}|�|jd�|�|j�|��Wd�n1sX0Yttd��4}|�	|�
d�d�|�||j|j�Wd�n1s�0YdS�Nr4�
ababagalamagarr?�
�r6r�writer=rCr%rDrArr�readrBr;rrr
�test_incompleted_write�s

&z&AudioWriteTests.test_incompleted_writecCs�ttd��p}|�d�|�|�}|�|j�|j|j}|�|j	d|��|�|j	|d��|�
�Wd�n1s�0Yttd��4}|�|�d�d�|�
||j|j	�Wd�n1s�0YdS�Nr4rYr?rZ)r6rr\r=rCr%r"r#rDrArrr]rB�rr<r�	framesizerrr
�test_multiple_writes�s

&z$AudioWriteTests.test_multiple_writescCs�ttd��H}|�d�|�|�}|�|jd�|�|j�|��Wd�n1sX0Yttd��4}|�	|�
d�d�|�||j|j�Wd�n1s�0YdSrXr[r;rrr
�test_overflowed_write�s

&z%AudioWriteTests.test_overflowed_writecCs�|�t��(}|�|j�|�|j�Wd�n1s80Yttd��"}|�||j|j�Wd�n1st0YdSr>)r=rrCr%rDrArrB)rrr<rrr
�test_unseekable_read�s
*z$AudioWriteTests.test_unseekable_readc	Cs�ttd��R}|�|��(}|�|j�|�|j�Wd�n1sD0YWd�n1sb0Y|�t|j|j�dSr3)rrr=rCr%rDrArBr;rrr
�test_unseekable_write�s
Hz%AudioWriteTests.test_unseekable_writec	Cs�ttd��x}|�d�|�|�}|�|jd�z|�|j�WntyRYn0z|�	�WntyrYn0Wd�n1s�0Yt
td��8}|�|�d�d�|�
||jd|j�Wd�n1s�0YdSrX)rrr\r=rCr%rDrA�OSErrorrr6rr]rBr;rrr
�!test_unseekable_incompleted_write�s

$z1AudioWriteTests.test_unseekable_incompleted_writec	Cs�ttd��x}|�d�|�|�}|�|jd�z|�|j�WntyRYn0z|�	�WntyrYn0Wd�n1s�0Yt
td��N}|�|�d�d�|j
|j}|�||jd|jd|��Wd�n1s�0YdSrX)rrr\r=rCr%rDrArfrr6rr]r"r#rBr`rrr
� test_unseekable_overflowed_write�s 

$z0AudioWriteTests.test_unseekable_overflowed_writeN)rrrr=rBrFrIrNrOrPrRrUrWr^rbrcrdrergrhrrrr
r24s"r2c@s@eZdZedd��Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�AudioTestsWithSourceFilecCst|jdd�|_dS)NZ	audiodata)Zsubdir)rZsndfilename�sndfilepath)�clsrrr
�
setUpClass�sz#AudioTestsWithSourceFile.setUpClassc	Cs:|j�|j�}|_|�||j|j|j|j|j	|j
�dSr)r5r6rjrr0r"r#r$�sndfilenframesr&r'rErrr
�test_read_params�s�z)AudioTestsWithSourceFile.test_read_paramsc	Cs�t|jd��F}|j�|�}|_|�|j�|��|�|j|j�Wd�n1sX0Ytt	d��~}|j�|d�}|_
|�|j�|�|jj��|��Wd�n1s�0Y|�|j|j�|��Wd�n1s�0YdS)Nr?r4)
r6rjr5rrKrJrrr1rrrGrH)rr<rrrrr
�
test_closes.&z#AudioTestsWithSourceFile.test_closecCs�|j|j}|jdd|�}|jd|d|�}|j�|j�}|_|�|�d�d�|�|�	�d�|�|�d�|�|�
�|�	�}|�|d�|�|�d�|�|�	�}|�|d�|�|�d�|�|�|�|�|�d�|�|�|�|�|�d�|�|�|jj
��|�d�Wd�n1�s80Y|�|jj
��"|�|��d�Wd�n1�sz0YdS)N��r����r)r"r#rAr5r6rjrrr@r�rewindZsetposrGrHr )rraZchunk1Zchunk2rZpos0Zpos2rrr
�	test_reads,

*z"AudioTestsWithSourceFile.test_readcCs�|j�|j�}|_|j�td�}|_|�|���d}|��}|dkrl|d7}|�	|�
|��||8}qB|��|j�td�}|_|��|�
|��|���|�
|�
|���|�
|����dS)Nr4rrr?)r5r6rjrrrZ	setparamsr!r rDr@rrtr)rrr�i�nrrr
�	test_copy+s 
�z"AudioTestsWithSourceFile.test_copyc	Cs>ttd��T}|�d�t|jd��}|�|���Wd�n1sF0YWd�n1sd0Yttd���}|�|�d�d�|j�|d��n}|�|��|j�|�|�	�|j
�|�|��|j�|�|�
�|j�|�|�|j�|j�Wd�n1�s0YWd�n1�s00YdSr_)r6rr\rjr]rr5rr"rr#rr$r rmr@r%rAr;rrr
�test_read_not_from_start<s
Jz1AudioTestsWithSourceFile.test_read_not_from_startN)
rrr�classmethodrlrnrorurxryrrrr
ri�s
ri)Ztest.supportrrrrTrr)�FileIOrrr2rirrrr
�<module>s%F

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists