Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_imghdr.cpython-34.pyo

�
f f=�@s�ddlZddlZddlZddlZddlZddlmZmZmZd)Z	Gdd�dej
�ZGdd�dej�Z
edkr�ej�ndS)*�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�xbmc@s(eZdZdd�Zdd�ZdS)�UnseekableIOcCs
tj�dS)N)�io�UnsupportedOperation)�self�r�5/opt/alt/python34/lib64/python3.4/test/test_imghdr.py�tellszUnseekableIO.tellcOs
tj�dS)N)rr)r�args�kwargsrrr �seekszUnseekableIO.seekN)�__name__�
__module__�__qualname__r!r$rrrr rsrc@s�eZdZedd��Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
TestImghdrc	CsCtddd�|_t|jd��}|j�|_WdQXdS)Nz
python.png�subdir�
imghdrdata�rb)r�testfile�open�read�testdata)�cls�streamrrr �
setUpClassszTestImghdr.setUpClasscCstt�dS)N)rr)rrrr �tearDown$szTestImghdr.tearDowncCs�x�tD]�\}}t|dd�}|jtj|�|�t|d�� }|jtj|�|�WdQXt|d��}|j�}WdQX|jtjd|�|�|jtjdt|��|�qWdS)Nr)r*r+)�
TEST_FILESr�assertEqual�imghdr�whatr-r.�	bytearray)r�filenameZexpectedr1�datarrr �	test_data'szTestImghdr.test_datacCsOdd�}tjj|�|jtjj�|jtjdd�d�dS)NcSs|jd�rdSdS)Nseggs�ham)�
startswith)�h�filerrr �
test_jumbo3sz1TestImghdr.test_register_test.<locals>.test_jumboseggsr<)r6Ztests�appendZ
addCleanup�popr5r7)rr@rrr �test_register_test2szTestImghdr.test_register_testcCs�ttd��0}|jd�|j�}|j|j�WdQXttd��C}|j|�|jtj|�d�|j|j�|�WdQXdS)N�wbs
ababagalamagar+r)	r-r�writer!r/r$r5r6r7)rr1�posrrr �
test_file_pos:s

zTestImghdr.test_file_posc(Cs�|jt��tj�WdQX|jt��tjd�WdQX|jt��tj|jd�WdQX|jt��tjtj|j��WdQXt|jd��0}|jt��tj|j	��WdQXWdQXdS)N�r+)
�assertRaises�	TypeErrorr6r7�AttributeErrorr,�os�fsencoder-�fileno)r�frrr �
test_bad_argsDszTestImghdr.test_bad_argscCs.x'dD]}|jtjd|��qWdS)N��PN
���Y��cutecat�	000000JFI�GIF80)rQrRrSrTrUrV)ZassertIsNoner6r7)r�headerrrr �test_invalid_headersQs
zTestImghdr.test_invalid_headerscCs�tj���tjdt�x�tD]�\}}t|dd�}t|d��}|j�jd�}WdQX|j	t
��tjt
j|��WdQX|j	t
��tjd|�WdQXq$WWdQXdS)N�ignorer)r*r+�latin1)�warnings�catch_warnings�simplefilter�BytesWarningr4rr-r.�decoderIrJr6r7r�StringIO)rr9�_r1r:rrr �test_string_dataZs
zTestImghdr.test_string_datac	Cs'|jt��tjd�WdQXdS)NZmissing)rI�FileNotFoundErrorr6r7)rrrr �test_missing_filefszTestImghdr.test_missing_filecCs�t|jd�}|j�|jt��}tj|�WdQXtj|j	�}|j�|jt��}tj|�WdQXdS)Nr+)
r-r,�closerI�
ValueErrorr6r7r�BytesIOr/)rr1�cmrrr �test_closed_filejs

zTestImghdr.test_closed_filecCsjttd��}|j|j�WdQXttd��-}|jtj��tj	|�WdQXWdQXdS)NrDr+)
r-rrEr/rrIrrr6r7)rr1rrr �test_unseekablets
zTestImghdr.test_unseekablecCs^ttd��I}|j|j�|jd�|jt��}tj|�WdQXWdQXdS)NrDr)	r-rrEr/r$rI�OSErrorr6r7)rr1rhrrr �test_output_stream{s

zTestImghdr.test_output_streamN)r%r&r'�classmethodr2r3r;rCrGrPrXrbrdrirjrlrrrr r(s

	
r(�__main__�rzpng�rr�r	r
�rr�r
r�rr�rr�rr�rr�rr�rr)rorprqrrrsrtrurvrwrxry)r6rrLZunittestr[Ztest.supportrrrr4�FileIOrZTestCaser(r%�mainrrrr �<module>s(e