Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/test_imghdr.cpython-311.pyc
�

�KeA����ddlZddlZddlZddlZddlZddlmZmZddlm	Z	m
Z
ejd��ZdZ
Gd�dej��ZGd�d	ej��Zed
krej��dSdS)�N)�findfile�warnings_helper)�TESTFN�unlink�imghdr))�
python.png�png)z
python.gif�gif)z
python.bmp�bmp)z
python.ppm�ppm)z
python.pgm�pgm)z
python.pbm�pbm)z
python.jpg�jpeg)zpython-raw.jpgr)z
python.ras�rast)z
python.sgi�rgb)zpython.tiff�tiff)z
python.xbm�xbm)zpython.webp�webp)z
python.exr�exrc��eZdZd�Zd�ZdS)�UnseekableIOc��tj��N��io�UnsupportedOperation��selfs �:/usr/local/apps/python3/lib/python3.11/test/test_imghdr.py�tellzUnseekableIO.tell����%�%�c��tj�rr)r�args�kwargss   r�seekzUnseekableIO.seek!r!r"N)�__name__�
__module__�__qualname__r r&�r"rrrs2������&�&�&�&�&�&�&�&r"rc�l�eZdZed���Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�ZdS)�
TestImghdrc��tdd���|_t|jd��5}|���|_ddd��dS#1swxYwYdS)Nr�
imghdrdata��subdir�rb)r�testfile�open�read�testdata)�cls�streams  r�
setUpClasszTestImghdr.setUpClass%s�����\�B�B�B���
�#�,��
%�
%�	)��!�;�;�=�=�C�L�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	)�	)s�A�A�Ac�.�tt��dSr)rrrs r�tearDownzTestImghdr.tearDown+s���v�����r"c	��tD�]B\}}t|d���}|�t�|��|��t|d��5}|�t�|��|��ddd��n#1swxYwYt|d��5}|���}ddd��n#1swxYwY|�t�d|��|��|�t�dt|����|����DdS)Nr.r/r1)�
TEST_FILESr�assertEqualr�whatr3r4�	bytearray)r�filename�expectedr7�datas     r�	test_datazTestImghdr.test_data.s���",�	K�	K��H�h����>�>�>�H����V�[�[��2�2�H�=�=�=��h��%�%�
@��� � ����V�!4�!4�h�?�?�?�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@�
@����
@�
@�
@�
@��h��%�%�
%���{�{�}�}��
%�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%����
%�
%�
%�
%����V�[�[��t�4�4�h�?�?�?����V�[�[��y����?�?��J�J�J�J�	K�	Ks$�/B�B	�B	�3C�C	�C	c	��tD]�\}}|�|���5t|d���}|�t�t
j|����|��ddd��n#1swxYwY��dS)N)r@r.r/)r<�subTestrr=rr>�pathlib�Path)rr@rAs   r�test_pathlike_filenamez!TestImghdr.test_pathlike_filename9s���",�	P�	P��H�h����x��0�0�
P�
P�#�H�\�B�B�B��� � ����W�\�(�-C�-C�!D�!D�h�O�O�O�
P�
P�
P�
P�
P�
P�
P�
P�
P�
P�
P����
P�
P�
P�
P��	P�	Ps�AB�B	�B	c���d�}tj�|��|�tjj��|�t�dd��d��dS)Nc�4�|�d��rdSdS)N�eggs�ham)�
startswith)�h�files  r�
test_jumboz1TestImghdr.test_register_test.<locals>.test_jumbo@s%���|�|�G�$�$�
��u�
�
r"rKrL)r�tests�append�
addCleanup�popr=r>)rrPs  r�test_register_testzTestImghdr.test_register_test?sj��	�	�	�	����J�'�'�'������(�)�)�)�������T�7�3�3�U�;�;�;�;�;r"c��ttd��5}|�d��|���}|�|j��ddd��n#1swxYwYttd��5}|�|��|�t�|��d��|�|���|��ddd��dS#1swxYwYdS)N�wbs
ababagalamagar1r	)	r3r�writer r5r&r=rr>)rr7�poss   r�
test_file_poszTestImghdr.test_file_posGs]��
�&�$�
�
�	(�6��L�L�)�*�*�*��+�+�-�-�C��L�L���'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(��&�$�
�
�	1�6��K�K��������V�[�[��0�0�%�8�8�8����V�[�[�]�]�C�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1s%�AA&�&A*�-A*�A,C?�?D�Dc��|�t��5t���ddd��n#1swxYwY|�t��5t�d��ddd��n#1swxYwY|�t��5t�|jd��ddd��n#1swxYwY|�t��5t�t
j|j����ddd��n#1swxYwYt|jd��5}|�t��5t�|�	����ddd��n#1swxYwYddd��dS#1swxYwYdS)N�r1)
�assertRaises�	TypeErrorrr>�AttributeErrorr2�os�fsencoder3�fileno)r�fs  r�
test_bad_argszTestImghdr.test_bad_argsQs���
�
�
�y�
)�
)�	�	��K�K�M�M�M�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�~�
.�
.�	�	��K�K�����	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�
�
�y�
)�
)�	*�	*��K�K��
�q�)�)�)�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*�	*����	*�	*�	*�	*�
�
�
�~�
.�
.�	4�	4��K�K���D�M�2�2�3�3�3�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�
�$�-��
&�
&�	(�!��"�"�>�2�2�
(�
(����A�H�H�J�J�'�'�'�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(�
(����
(�
(�
(�
(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�	(�	(s}�A�A�A�&B
�
B�B�2!C�C#�&C#�2E�E�	E�"G�=-F6�*G�6F:	�:G�=F:	�>G�G�Gc�l�dD]0}|�t�d|�����1dS)N)s�PN
s�sY�scutecats	000000JFIsGIF80)�assertIsNonerr>)r�headers  r�test_invalid_headerszTestImghdr.test_invalid_headers^sD��!�	9�	9�F�
���f�k�k�$��7�7�8�8�8�8�
	9�	9r"c���tj��5tjdt��tD�]\}}t|d���}t
|d��5}|����d��}ddd��n#1swxYwY|�	t��5t�tj|����ddd��n#1swxYwY|�	t��5t�d|��ddd��n#1swxYwY��	ddd��dS#1swxYwYdS)N�ignorer.r/r1�latin1)�warnings�catch_warnings�simplefilter�BytesWarningr<rr3r4�decoder]r^rr>r�StringIO)rr@�_r7rBs     r�test_string_datazTestImghdr.test_string_datags2��
�
$�
&�
&�		,�		,��!�(�L�9�9�9�)�
,�
,���!�#�H�\�B�B�B���(�D�)�)�:�V�!�;�;�=�=�/�/��9�9�D�:�:�:�:�:�:�:�:�:�:�:����:�:�:�:��&�&�y�1�1�3�3��K�K���D� 1� 1�2�2�2�3�3�3�3�3�3�3�3�3�3�3����3�3�3�3��&�&�y�1�1�,�,��K�K��d�+�+�+�,�,�,�,�,�,�,�,�,�,�,����,�,�,�,��

,�		,�		,�		,�		,�		,�		,�		,�		,�		,�		,�		,�		,����		,�		,�		,�		,�		,�		,s~�A	E�(B�E�B�E�B�E�6-C/�#E�/C3�3E�6C3�7E�D<�0E�<E�E�E�E�E�Ec��|�t��5t�d��ddd��dS#1swxYwYdS)N�missing)r]�FileNotFoundErrorrr>rs r�test_missing_filezTestImghdr.test_missing_filess���
�
�
�0�
1�
1�	#�	#��K�K�	�"�"�"�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#�	#����	#�	#�	#�	#�	#�	#s�A�A�
Ac���t|jd��}|���|�t��5}t
�|��ddd��n#1swxYwYtj|j	��}|���|�t��5}t
�|��ddd��dS#1swxYwYdS)Nr1)
r3r2�closer]�
ValueErrorrr>r�BytesIOr5�rr7�cms   r�test_closed_filezTestImghdr.test_closed_filews=���d�m�T�*�*��������
�
�
�z�
*�
*�	 �b��K�K�����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 ���D�M�*�*��������
�
�
�z�
*�
*�	 �b��K�K�����	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 �	 ����	 �	 �	 �	 �	 �	 s$�A+�+A/�2A/�=C%�%C)�,C)c��ttd��5}|�|j��ddd��n#1swxYwYt	td��5}|�tj��5t�	|��ddd��n#1swxYwYddd��dS#1swxYwYdS)NrWr1)
r3rrXr5rr]rrrr>)rr7s  r�test_unseekablezTestImghdr.test_unseekable�sg��
�&�$�
�
�	(�6��L�L���'�'�'�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�
�&�$�
'�
'�	$�6��"�"�2�#:�;�;�
$�
$����F�#�#�#�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$����
$�
$�
$�
$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$sE�=�A�A� B<�=B$�B<�$B(	�(B<�+B(	�,B<�<C�Cc�X�ttd��5}|�|j��|�d��|�t��5}t�|��ddd��n#1swxYwYddd��dS#1swxYwYdS)NrWr)	r3rrXr5r&r]�OSErrorrr>r|s   r�test_output_streamzTestImghdr.test_output_stream�s��
�&�$�
�
�	$�6��L�L���'�'�'��K�K��N�N�N��"�"�7�+�+�
$�r����F�#�#�#�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$����
$�
$�
$�
$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$s6�A
B� B�;B�B	�B�B	�B�B#�&B#N)r'r(r)�classmethodr8r:rCrHrUrZrdrhrsrwr~r�r�r*r"rr,r,$s��������)�)��[�)�
���	K�	K�	K�P�P�P�<�<�<�1�1�1�(�(�(�9�9�9�
,�
,�
,�#�#�#� � � �$�$�$�$�$�$�$�$r"r,�__main__)rr`rF�unittestrl�test.supportrr�test.support.os_helperrr�import_deprecatedrr<�FileIOr�TestCaser,r'�mainr*r"r�<module>r�s��	�	�	�	�	�	�	�	�������������2�2�2�2�2�2�2�2�1�1�1�1�1�1�1�1�	*��	*�8�	4�	4���
�"&�&�&�&�&�2�9�&�&�&�i$�i$�i$�i$�i$��"�i$�i$�i$�V�z����H�M�O�O�O�O�O��r"