Your IP : 216.73.217.32


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



���]v�@s�ddlZddlZddlZddlZddlZddlmZmZmZd/Z	Gdd�dej
�ZGdd �d ej�Z
ed!kr�ej�dS)0�N)�findfile�TESTFN�unlink�
python.png�png�
python.gif�gif�
python.bmp�bmp�
python.ppm�ppm�
python.pgm�pgm�
python.pbm�pbm�
python.jpg�jpeg�
python.ras�rast�
python.sgi�rgb�python.tiff�tiff�
python.xbm�xbm�python.webp�webp�
python.exr�exrc@s(eZdZdd�Zdd�ZdS)�UnseekableIOcCs
tj�dS)N)�io�UnsupportedOperation)�self�r#�0/opt/alt/python35/lib64/python3.5/test_imghdr.py�tellszUnseekableIO.tellcOs
tj�dS)N)r r!)r"�args�kwargsr#r#r$�seekszUnseekableIO.seekN)�__name__�
__module__�__qualname__r%r(r#r#r#r$rsrc@s�eZdZedd��Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
TestImghdrc	CsDtddd�|_t|jd��}|j�|_WdQRXdS)Nz
python.png�subdir�
imghdrdata�rb)r�testfile�open�read�testdata)�cls�streamr#r#r$�
setUpClass szTestImghdr.setUpClasscCstt�dS)N)rr)r"r#r#r$�tearDown&szTestImghdr.tearDowncCs�x�tD]�\}}t|dd�}|jtj|�|�t|d�� }|jtj|�|�WdQRXt|d��}|j�}WdQRX|jtjd|�|�|jtjdt|��|�qWdS)Nr-r.r/)�
TEST_FILESr�assertEqual�imghdr�whatr1r2�	bytearray)r"�filenameZexpectedr5�datar#r#r$�	test_data)s zTestImghdr.test_datacCsOdd�}tjj|�|jtjj�|jtjdd�d�dS)NcSs|jd�rdSdS)Nseggs�ham)�
startswith)�h�filer#r#r$�
test_jumbo5sz1TestImghdr.test_register_test.<locals>.test_jumboseggsr@)r:Ztests�appendZ
addCleanup�popr9r;)r"rDr#r#r$�test_register_test4szTestImghdr.test_register_testcCs�ttd��0}|jd�|j�}|j|j�WdQRXttd��C}|j|�|jtj|�d�|j|j�|�WdQRXdS)N�wbs
ababagalamagar/r)	r1r�writer%r3r(r9r:r;)r"r5�posr#r#r$�
test_file_pos<s

zTestImghdr.test_file_posc,Cs�|jt��tj�WdQRX|jt��tjd�WdQRX|jt��tj|jd�WdQRX|jt��tjtj|j��WdQRXt|jd��1}|jt��tj|j	��WdQRXWdQRXdS)N�r/)
�assertRaises�	TypeErrorr:r;�AttributeErrorr0�os�fsencoder1�fileno)r"�fr#r#r$�
test_bad_argsFs zTestImghdr.test_bad_argscCs.x'dD]}|jtjd|��qWdS)N��PN
���Y��cutecat�	000000JFI�GIF80)rUrVrWrXrYrZ)ZassertIsNoner:r;)r"�headerr#r#r$�test_invalid_headersSs
zTestImghdr.test_invalid_headersc Cs�tj���tjdt�x�tD]�\}}t|dd�}t|d��}|j�jd�}WdQRX|j	t
��tjt
j|��WdQRX|j	t
��tjd|�WdQRXq$WWdQRXdS)N�ignorer-r.r/�latin1)�warnings�catch_warnings�simplefilter�BytesWarningr8rr1r2�decoderMrNr:r;r �StringIO)r"r=�_r5r>r#r#r$�test_string_data\s
zTestImghdr.test_string_datac	Cs(|jt��tjd�WdQRXdS)N�missing)rM�FileNotFoundErrorr:r;)r"r#r#r$�test_missing_filehszTestImghdr.test_missing_filecCs�t|jd�}|j�|jt��}tj|�WdQRXtj|j	�}|j�|jt��}tj|�WdQRXdS)Nr/)
r1r0�closerM�
ValueErrorr:r;r �BytesIOr3)r"r5�cmr#r#r$�test_closed_filels

zTestImghdr.test_closed_filecCsmttd��}|j|j�WdQRXttd��.}|jtj��tj	|�WdQRXWdQRXdS)NrHr/)
r1rrIr3rrMr r!r:r;)r"r5r#r#r$�test_unseekablevs
zTestImghdr.test_unseekablecCs`ttd��J}|j|j�|jd�|jt��}tj|�WdQRXWdQRXdS)NrHr)	r1rrIr3r(rM�OSErrorr:r;)r"r5rmr#r#r$�test_output_stream}s

zTestImghdr.test_output_streamN)r)r*r+�classmethodr6r7r?rGrKrTr\rfrirnrorqr#r#r#r$r,s

	
r,�__main__�rr�rr�r	r
�rr�r
r�rr�rr�rr�rr�rr�rr�rr�rr)
rtrurvrwrxryrzr{r|r}r~rr�)r:r rPZunittestr_Ztest.supportrrrr8�FileIOrZTestCaser,r)�mainr#r#r#r$�<module>s,e