Mini Shell

Direktori : /opt/cppython/lib/python3.8/test/__pycache__/
Upload File :
Current File : //opt/cppython/lib/python3.8/test/__pycache__/audiotests.cpython-38.pyc

U

��eg�1�@s�ddlmZmZmZddlZddlZddlmZddlZGdd�dej	�Z
Gdd�d�ZGdd	�d	e�ZGd
d�de�Z
Gdd
�d
e�ZdS)�)�findfile�TESTFN�unlinkN)�mockc@seZdZdd�Zdd�ZdS)�UnseekableIOcCs
tj�dS�N��io�UnsupportedOperation��self�r
�./opt/cppython/lib/python3.8/test/audiotests.py�tell	szUnseekableIO.tellcOs
tj�dSrr)r�args�kwargsr
r
r�seekszUnseekableIO.seekN)�__name__�
__module__�__qualname__rrr
r
r
rrsrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
AudioTestsFcCsd|_|_dSr)�f�foutrr
r
r�setUpszAudioTests.setUpcCs4|jdk	r|j��|jdk	r(|j��tt�dSr)r�closerrrrr
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)rrr#r$r%r&r'r(�params�proto�dumpr
r
r�check_paramss&�zAudioTests.check_paramsN)rrr�close_fdrrr1r
r
r
rrsrc@seZdZdd�ZdS)�AudioMiscTestsc
Cs`d}d}t�|jj�d���:}|�t��$|jj||d�|j||d�W5QRXW5QRXdS)N�arg�modez.open)r5)rZpatch�modulerZassertWarns�DeprecationWarningZopenfpZassert_called_with)rr4r5Z	mock_openr
r
r�test_openfp_deprecated7s�z%AudioMiscTests.test_openfp_deprecatedN)rrrr8r
r
r
rr35sr3c@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)r6�openr�setnchannelsr#�setsampwidthr$�setframerater%�setcomptyper'r(�r�testfilerr
r
r�create_fileBszAudioWriteTests.create_filec	Csv|j�|d��^}|�|��|j�|�|��|j�|�|��|j�|�|�	�|�|�|�
|�|�W5QRXdS�N�rb)r6r<rrr#rr$r r%r!�
readframes)rrBr&�framesrr
r
r�
check_fileJszAudioWriteTests.check_filec	CsP|�t�}|�|j�|�|j�|�||j|j|j	|j|j
|j�|��dSr)
rCr�
setnframesr&�writeframesrGr1r#r$r%r'r(r�rrr
r
r�test_write_paramsRs
�z!AudioWriteTests.test_write_paramscCs�|�|jj�� |j�td��W5QRXW5QRX|�|jj��4ttd��}|j�|��W5QRXW5QRXW5QRXdSr:)�assertRaisesr6�Errorr<r)rrBr
r
r�&test_write_context_manager_calls_closeZsz6AudioWriteTests.test_write_context_manager_calls_closec
Csttd��b}|j�|��:}|�|j�|�|j�|�|j�|�	|j
|j�W5QRX|�|j
|j�W5QRXttd���}|j�|��N}|�|��j
�|��}|�|j|j�|�|j|j�|�|j|j�W5QRX|js�|�|���|�|j
|j�W5QRXdS)Nr;rE)r<rr6r=r#r>r$r?r%r@r'r(r�closedr2�assertFalse�getfpr"�assertIsNone)rrBrr.r
r
r�#test_context_manager_with_open_filees"z3AudioWriteTests.test_context_manager_with_open_filec	Cs�|j�td��:}|�|j�|�|j�|�|j�|�	|j
|j�W5QRX|j�t��N}|�|�
�j�|��}|�|j|j�|�|j|j�|�|j|j�W5QRX|js�|�|�
��dSr:)r6r<rr=r#r>r$r?r%r@r'r(rQrRrPr"rr2rS)rrr.r
r
r�"test_context_manager_with_filenamexsz2AudioWriteTests.test_context_manager_with_filenamecCs@|�t�}|�|j�|�|j�|��|�t|j|j�dSr)rCrrIr&rJrGrrHrKr
r
r�
test_write�s

zAudioWriteTests.test_writecCsD|�t�}|�|j�|�t|j��|��|�t|j|j�dSr)	rCrrIr&rJ�	bytearrayrGrrHrKr
r
r�test_write_bytearray�s

z$AudioWriteTests.test_write_bytearraycCsH|�t�}|�|j�|�t�d|j��|��|�t|j|j�dS)N�h)	rCrrIr&rJ�arrayrGrrHrKr
r
r�test_write_array�s

z AudioWriteTests.test_write_arraycCsD|�t�}|�|j�|�t|j��|��|�t|j|j�dSr)	rCrrIr&rJ�
memoryviewrGrrHrKr
r
r�test_write_memoryview�s

z%AudioWriteTests.test_write_memoryviewc	Cs�ttd��>}|�d�|�|�}|�|jd�|�|j�|��W5QRXttd��*}|�	|�
d�d�|�||j|j�W5QRXdS�Nr;�
ababagalamagarrE�
�r<r�writerCrIr&rJrGrr�readrHrAr
r
r�test_incompleted_write�s

z&AudioWriteTests.test_incompleted_writec	Cs�ttd��f}|�d�|�|�}|�|j�|j|j}|�|j	d|��|�|j	|d��|�
�W5QRXttd��*}|�|�d�d�|�
||j|j	�W5QRXdS�Nr;r_rEr`)r<rrbrCrIr&r#r$rJrGrrrcrH�rrBr�	framesizer
r
r�test_multiple_writes�s

z$AudioWriteTests.test_multiple_writesc	Cs�ttd��>}|�d�|�|�}|�|jd�|�|j�|��W5QRXttd��*}|�	|�
d�d�|�||j|j�W5QRXdSr^rarAr
r
r�test_overflowed_write�s

z%AudioWriteTests.test_overflowed_writec	CsZ|�t��}|�|j�|�|j�W5QRXttd��}|�||j|j�W5QRXdSrD)rCrrIr&rJrGrrH)rrrBr
r
r�test_unseekable_read�s
z$AudioWriteTests.test_unseekable_readc
CsZttd��4}|�|��}|�|j�|�|j�W5QRXW5QRX|�t|j|j�dSr:)rrrCrIr&rJrGrHrAr
r
r�test_unseekable_write�s
 z%AudioWriteTests.test_unseekable_writec	Cs�ttd��r}|�d�|�|�}|�|jd�z|�|j�Wntk
rTYnXz|�	�Wntk
rvYnXW5QRXt
td��.}|�|�d�d�|�
||jd|j�W5QRXdSr^)rrrbrCrIr&rJrG�OSErrorrr<rrcrHrAr
r
r�!test_unseekable_incompleted_write�s

z1AudioWriteTests.test_unseekable_incompleted_writec	Cs�ttd��r}|�d�|�|�}|�|jd�z|�|j�Wntk
rTYnXz|�	�Wntk
rvYnXW5QRXt
td��D}|�|�d�d�|j
|j}|�||jd|jd|��W5QRXdSr^)rrrbrCrIr&rJrGrlrr<rrcr#r$rHrfr
r
r� test_unseekable_overflowed_write�s 

z0AudioWriteTests.test_unseekable_overflowed_writeN)rrrrCrHrLrOrTrUrVrXr[r]rdrhrirjrkrmrnr
r
r
rr9@s"r9c@s@eZdZedd��Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�AudioTestsWithSourceFilecCst|jdd�|_dS)NZ	audiodata)Zsubdir)rZsndfilename�sndfilepath)�clsr
r
r�
setUpClasssz#AudioTestsWithSourceFile.setUpClassc	Cs:|j�|j�}|_|�||j|j|j|j|j	|j
�dSr)r6r<rprr1r#r$r%�sndfilenframesr'r(rKr
r
r�test_read_paramss�z)AudioTestsWithSourceFile.test_read_paramsc
Cs�t|jd��<}|j�|�}|_|�|j�|��|�|j|j�W5QRXtt	d��`}|j�|d�}|_
|�|j�|�|jj��|��W5QRX|�|j|j�|��W5QRXdS)NrEr;)
r<rpr6rrQrPrrr2rrrMrN)rrBrrr
r
r�
test_closesz#AudioTestsWithSourceFile.test_closec	Cs\|j|j}|jdd|�}|jd|d|�}|j�|j�}|_|�|�d�d�|�|�	�d�|�|�d�|�|�
�|�	�}|�|d�|�|�d�|�|�	�}|�|d�|�|�d�|�|�|�|�|�d�|�|�|�|�|�d�|�|�|jj
��|�d�W5QRX|�|jj
��|�|��d�W5QRXdS)N��r����r)r#r$rGr6r<rprrrFr�rewindZsetposrMrNr!)rrgZchunk1Zchunk2rZpos0Zpos2r
r
r�	test_reads,

z"AudioTestsWithSourceFile.test_readcCs�|j�|j�}|_|j�td�}|_|�|���d}|��}|dkrl|d7}|�	|�
|��||8}qB|��|j�td�}|_|��|�
|��|���|�
|�
|���|�
|����dS)Nr;rrrE)r6r<rprrrZ	setparamsr"r!rJrFrrzr)rrr�i�nr
r
r�	test_copy7s 
�z"AudioTestsWithSourceFile.test_copyc
Cs�ttd��6}|�d�t|jd��}|�|���W5QRXW5QRXttd���}|�|�d�d�|j�|d��d}|�|��|j�|�|�	�|j
�|�|��|j�|�|�
�|j�|�|�|j�|j�W5QRXW5QRXdSre)r<rrbrprcrr6rr#rr$r r%r!rsrFr&rGrAr
r
r�test_read_not_from_startHs
"z1AudioTestsWithSourceFile.test_read_not_from_startN)
rrr�classmethodrrrtrur{r~rr
r
r
rros
ro)Ztest.supportrrrrZr	Zunittestrr*�FileIOrrr3r9ror
r
r
r�<module>s%F

Zerion Mini Shell 1.0