o
    �¨Êhâ\  ã                   @   s0  d Z ddlZddlZddlmZ ddlmZmZmZ ddl	Z	ddl
Z
ddlmZ ddlZddlZddlZddlZddlmZ ddlm  mZ ddlZddlmZ ddlm  mZ ej  !d¡Z"G dd	„ d	ƒZ#e$e#egZ%zdd
l&m'Z( e% )e(¡ W n	 e*y‚   Y nw e
j+ ,e
j+ -e.¡¡Z/G dd„ dƒZ0ej1dd„ ƒZ2G dd„ dƒZ3dd„ Z4ej  5dddg¡ej  5dddg¡dd„ ƒƒZ6dd„ Z7ej  5deddfedd fg¡d!d"„ ƒZ8ej  5d#g d$¢¡ej  5dddg¡d%d&„ ƒƒZ9d'd(„ Z:d)d*„ Z;d+d,„ Z<d-d.„ Z=ej  5d/ej>ej?ej@ejAejBejCejDejEejFg	¡d0d1„ ƒZGdS )2z0
Tests for the pandas.io.common functionalities
é    N)Úpartial)ÚBytesIOÚStringIOÚUnsupportedOperation)ÚPath)Úis_platform_windowsz=ignore:Passing a BlockManager to DataFrame:DeprecationWarningc                   @   s"   e Zd ZdZddd„Zdd„ ZdS )	ÚCustomFSPathz%For testing fspath on unknown objectsÚreturnNc                 C   s
   || _ d S ©N©Úpath)Úselfr   © r   úM/var/www/html/env/lib/python3.10/site-packages/pandas/tests/io/test_common.pyÚ__init__%   s   
zCustomFSPath.__init__c                 C   s   | j S r
   r   ©r   r   r   r   Ú
__fspath__(   s   zCustomFSPath.__fspath__)r	   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   "   s    
r   )Úlocalc                   @   s  e Zd ZdZdd„ Zdd„ Zdd„ Ze d¡d	d
„ ƒZ	dd„ Z
dd„ Zej de¡dd„ ƒZej deeeg¡dd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zej dejdedfejdedfejd ed!fejd"ed#fej d$ed%fej!ded&fej"ded'fej#ded(fej$ded)fg	¡d*d+„ ƒZ%ej d,ej&j'dedfej&j(ded-fej&j)d ed!fej&j*d"ed#fej&j+d"ed.fej&j,ded&fej&j-ded(fej&j.ded)fg¡d/d0„ ƒZ/ej dejdedfej0dedfejdedfejd ed!fejd"ed#fej d$ed%fej!ded&fej"ded'fej#ded(fej$ded)fg
¡d1d2„ ƒZ1ej d3ejdd4fej0dd4fejdd5fejd d6fejd"d7fej d$d8fej!dd9fej"dd:fej#dd;fej$dd<fg
¡d=d>„ ƒZ2ej d?d@i dfdAdBdCidCfdDi d"fdEi dfdFi dfdGi dfdHi dfdIdJe 3dK¡idfg¡dLdM„ ƒZ4dNdO„ Z5dPS )QÚTestCommonIOCapabilitiesziindex,A,B,C,D
foo,2,3,4,5
bar,7,8,9,10
baz,12,13,14,15
qux,12,13,14,15
foo2,12,13,14,15
bar2,12,13,14,15
c                 C   sB   d}t  |¡}||ksJ ‚tj |¡sJ ‚tj |¡|ksJ ‚d S )Nz
~/sometest)ÚicomÚ_expand_userÚosr   ÚisabsÚ
expanduser©r   ÚfilenameÚexpanded_namer   r   r   Útest_expand_userD   s
   
z)TestCommonIOCapabilities.test_expand_userc                 C   s2   d}t  |¡}||ksJ ‚tj |¡|ksJ ‚d S )Nz/somefolder/sometest)r   r   r   r   r   r   r   r   r   Útest_expand_user_normal_pathL   s   
z5TestCommonIOCapabilities.test_expand_user_normal_pathc                 C   sB   t  tdƒ¡}|dksJ ‚t  tdƒ¡}|tj dd¡ksJ ‚d S )NÚ.zfoo//barÚfooÚbar)r   Ústringify_pathr   r   r   Újoin)r   Úrel_pathÚredundant_pathr   r   r   Útest_stringify_path_pathlibS   s   z4TestCommonIOCapabilities.test_stringify_path_pathlibzpy.pathc                 C   s8   t j dd¡}t j |¡}t|ƒ}t |¡|ksJ ‚d S )Nr$   r%   )r   r   r'   ÚabspathÚ	LocalPathr   r&   )r   r   Úabs_pathÚlpathr   r   r   Útest_stringify_path_localpathY   s   z6TestCommonIOCapabilities.test_stringify_path_localpathc                 C   s"   t dƒ}t |¡}|dksJ ‚d S )Núfoo/bar.csv)r   r   r&   )r   ÚpÚresultr   r   r   Útest_stringify_path_fspath`   s   
z3TestCommonIOCapabilities.test_stringify_path_fspathc              	   C   sŽ   t  d¡}t ¡ �4}|jd|› �dd��}|t |¡ksJ ‚W d   ƒ n1 s(w   Y  W d   ƒ d S W d   ƒ d S 1 s@w   Y  d S )NÚfsspeczfile://Úwb©Úmode)ÚpytestÚimportorskipÚtmÚensure_cleanÚopenr   r&   )r   r4   r   Ú
fsspec_objr   r   r   Ú!test_stringify_file_and_path_likee   s   

ÿÿ"ÿz:TestCommonIOCapabilities.test_stringify_file_and_path_likeÚ	path_typec                 C   s2   |\}}|d| ƒ}t j|dd�}||ksJ ‚d S )Nr0   Úinfer)Úcompression)r   Úinfer_compression)r   Úcompression_formatr?   Ú	extensionÚexpectedr   rA   r   r   r   Ú test_infer_compression_from_pathl   s   z9TestCommonIOCapabilities.test_infer_compression_from_pathc              	   C   s´   t jt ¡ d��H}|dt|ƒj d ƒ}t |d¡�}t|jjƒ ¡ s%J ‚t	j
 |¡|jjks1J ‚W d   ƒ n1 s;w   Y  W d   ƒ d S W d   ƒ d S 1 sSw   Y  d S )N)Údirz~/z	/sometestÚw)ÚtempfileÚTemporaryDirectoryr   ÚhomeÚnamer   Ú
get_handleÚhandleÚis_absoluter   r   r   )r   r?   Útmpr   Úhandlesr   r   r   Útest_get_handle_with_paths   s   þþ"þz2TestCommonIOCapabilities.test_get_handle_with_pathc              	   C   sx   t ƒ �*}t |d¡�}|j|ksJ ‚W d   ƒ n1 sw   Y  |jr&J ‚W d   ƒ n1 s0w   Y  |js:J ‚d S )NÚr)r   r   rM   rN   Úclosed)r   Úinput_bufferrQ   r   r   r   Útest_get_handle_with_buffer|   s   ÿýz4TestCommonIOCapabilities.test_get_handle_with_bufferc                 C   s¬   d}t jt|ƒddd��@}d}d}	 |j |¡}t|ƒ|ks J ‚t|ƒ|k r6t|j ¡ ƒdks1J ‚||7 }n||7 }q|| d	¡ksDJ ‚W d   ƒ d S 1 sOw   Y  d S )
Nõ&   a,b,c
1,2,3
Â©,Â®,Â®
Look,a snake,ðŸ��ÚrbF©Úis_textó    é   Tr   úutf-8)r   rM   r   rN   ÚreadÚlenÚencode)r   ÚdatarQ   r2   Ú	chunksizeÚchunkr   r   r   Ú)test_bytesiowrapper_returns_correct_bytes„   s   ö"òzBTestCommonIOCapabilities.test_bytesiowrapper_returns_correct_bytesc                 C   s�   t  d¡}d}t g d¢g d¢g d¢dœ¡}t|ƒ}tj|ddd	��}| |j¡ 	¡ }t
 ||¡ |jr6J ‚W d   ƒ d S 1 sAw   Y  d S )
Nzpyarrow.csvrW   )Ú1õ   Â©ÚLook)Ú2õ   Â®za snake)Ú3ri   u   ðŸ��©ÚaÚbÚcrX   FrY   )r8   r9   ÚpdÚ	DataFramer   r   rM   Úread_csvrN   Ú	to_pandasr:   Úassert_frame_equalrT   )r   Úpa_csvra   rE   ÚsrQ   Údfr   r   r   Útest_get_handle_pyarrow_compat›   s   
ÿ"ýz7TestCommonIOCapabilities.test_get_handle_pyarrow_compatc                 C   sÐ   t jt| jƒdd��}t j|dd�}W d   ƒ n1 sw   Y  t  t| jƒ¡}t ||¡ t jt| jƒdd��%}t|ƒ}t ||jdg ¡ t t  |¡|jdd … ¡ W d   ƒ d S 1 saw   Y  d S )Né   )rb   T)Úignore_indexr   )	ro   rq   r   Údata1Úconcatr:   rs   ÚnextÚiloc)r   Úreaderr2   rE   ÚitÚfirstr   r   r   Útest_iterator¬   s   ÿ"ýz&TestCommonIOCapabilities.test_iteratorz#reader, module, error_class, fn_extr   ÚcsvÚtxtÚxlrdÚxlsxÚpyarrowÚfeatherÚtablesÚh5ÚdtaÚsas7bdatÚjsonÚpicklec                 C   sà   t  |¡ tj tdd| ¡}d|› d�}d|› d�}d}d}	d	|› d
|› d�}
d|› d�}d|› d�}d|› �}t j|d|› d|› d|› d|	› d|
› d|› d|› d|› d�d�� ||ƒ W d   ƒ d S 1 siw   Y  d S )Nra   údoes_not_exist.úFile (b')?.+does_not_exist\.ú'? does not existú:\[Errno 2\] No such file or directory: '.+does_not_exist\.ú'zExpected object or valueú7path_or_buf needs to be a string file path or file-likeú#\[Errno 2\] File .+does_not_exist\.ú$ does not exist: '.+does_not_exist\.õ<   \[Errno 2\] æ²¡æœ‰é‚£ä¸ªæ–‡ä»¶æˆ–ç›®å½•: '.+does_not_exist\.ú?\[Errno 2\] File o directory non esistente: '.+does_not_exist\.ú+Failed to open local file.+does_not_exist\.ú(ú|ú)©Úmatch)r8   r9   r   r   r'   ÚHEREÚraises)r   r~   ÚmoduleÚerror_classÚfn_extr   Úmsg1Úmsg2Úmsg3Úmsg4Úmsg5Úmsg6Úmsg7Úmsg8r   r   r   Útest_read_non_existent¸   s(   
ÿÿ
ÿ
4þ
"üz/TestCommonIOCapabilities.test_read_non_existentz#method, module, error_class, fn_extÚhtmlÚparquetc                 C   s|   t  |¡ t g d¢g d¢g d¢dœ¡}tj tddd| ¡}t j|dd	�� |||ƒ W d   ƒ d S 1 s7w   Y  d S )
N)rx   é   é   )r®   r¯   é   )r¯   r°   r\   rk   ra   Úmissing_folderrŽ   z@Cannot save file into a non-existent directory: .*missing_folderrœ   )	r8   r9   ro   rp   r   r   r'   rž   rŸ   )r   Úmethodr    r¡   r¢   Údummy_framer   r   r   r   Ú#test_write_missing_parent_directoryÞ   s   
þ"üz<TestCommonIOCapabilities.test_write_missing_parent_directoryc                 C   sð   t  |¡ tj dd| ¡}| tddd„ ¡ d|› d�}d|› d	�}d
}	d}
d|› d|› d	�}d|› d	�}d|› d	�}d|› �}t j|d|› d|› d|	› d|
› d|› d|› d|› d|› d�d�� ||ƒ W d   ƒ d S 1 sqw   Y  d S )Nú~rŽ   r   c                 S   s   t j d| ¡S )Nr$   )r   r   r'   )Úxr   r   r   Ú<lambda>  s    zJTestCommonIOCapabilities.test_read_expands_user_home_dir.<locals>.<lambda>r�   r�   r‘   r’   z0Unexpected character found when decoding 'false'r“   r”   r•   r–   r—   r˜   r™   rš   r›   rœ   )r8   r9   r   r   r'   Úsetattrr   rŸ   )r   r~   r    r¡   r¢   Úmonkeypatchr   r£   r¤   r¥   r¦   r§   r¨   r©   rª   r   r   r   Útest_read_expands_user_home_dirù   s*   
ÿÿ
ÿ
4þ
"üz8TestCommonIOCapabilities.test_read_expands_user_home_dirzreader, module, path)Úiora   r‚   ziris.csv)r»   ra   Úfixed_widthzfixed_width_format.txt)r»   ra   Úexcelz
test1.xlsx)r»   ra   r‡   zfeather-0_3_1.feather)r»   ra   Ú
legacy_hdfzdatetimetz_object.h5)r»   ra   Ústatazstata10_115.dta)r»   Úsasra   ztest1.sas7bdat)r»   rŒ   ra   ztsframe_v012.json)r»   ra   r�   zcategorical.0.25.0.picklec                 C   sT   t  |¡ ||Ž }t|ƒ}||ƒ}||ƒ}| d¡r"t ||¡ d S t ||¡ d S )Nz.pickle)r8   r9   r   Úendswithr:   Úassert_categorical_equalrs   )r   r~   r    r   ÚdatapathÚmypathr2   rE   r   r   r   Útest_read_fspath_all$  s   
 
z-TestCommonIOCapabilities.test_read_fspath_allz"writer_name, writer_kwargs, moduleÚto_csvÚto_excelÚengineÚopenpyxlÚ
to_featherÚto_htmlÚto_jsonÚto_latexÚ	to_pickleÚto_stataÚ
time_stampz2019-01-01 00:00c                 C   s|  |dv r	t  d¡ t d¡}t d¡}t dddgi¡}|�–}|�{}t  |¡ t|ƒ}	t||ƒ}
|
|fi |¤Ž |
|	fi |¤Ž t|dƒ�H}t|dƒ�3}|d	kritj	|fi |¤Ž}tj	|fi |¤Ž}t 
||¡ n| ¡ }| ¡ }||kswJ ‚W d   ƒ n1 s�w   Y  W d   ƒ n1 s�w   Y  W d   ƒ n1 sŸw   Y  W d   ƒ d S W d   ƒ d S 1 s·w   Y  d S )
N)rÍ   Újinja2ÚstringÚfspathÚArx   r®   rX   rÇ   )r8   r9   r:   r;   ro   rp   r   Úgetattrr<   Ú
read_excelrs   r^   )r   Úwriter_nameÚwriter_kwargsr    Úp1Úp2rv   rÒ   rÓ   rÄ   ÚwriterÚf_strÚf_pathr2   rE   r   r   r   Útest_write_fspath_allQ  s2   




€ö€ €Pùz.TestCommonIOCapabilities.test_write_fspath_allc           	   	   C   sÈ   t  d¡ t dddgi¡}t d¡}t d¡}|�:}|�(}t|ƒ}|j|dd� |j|dd� tj|dd�}tj|dd�}W d   ƒ n1 sHw   Y  W d   ƒ n1 sWw   Y  t 	||¡ d S )	Nrˆ   rÔ   rx   r®   rÒ   rÓ   r%   )Úkey)
r8   r9   ro   rp   r:   r;   r   Úto_hdfÚread_hdfrs   )	r   rv   rÙ   rÚ   rÒ   rÓ   rÄ   r2   rE   r   r   r   Útest_write_fspath_hdf5x  s   


ú€ z/TestCommonIOCapabilities.test_write_fspath_hdf5N)6r   r   r   rz   r!   r"   r*   ÚtdÚ
skip_if_nor/   r3   r>   r8   ÚmarkÚparametrizeÚ
path_typesrF   Ústrr   r   rR   rV   rd   rw   r�   ro   rq   ÚFileNotFoundErrorÚread_fwfrÖ   Úread_featherÚOSErrorrá   Ú
read_stataÚread_sasÚ	read_jsonÚread_pickler«   rp   rÆ   rË   rÇ   rÊ   Ú
to_parquetrÏ   rÌ   rÎ   r´   Ú
read_tablerº   rÅ   Úto_datetimerÞ   râ   r   r   r   r   r   :   sÈ    	


÷þ
øþ
öþ


ý
ýý


ýêþ
øþ
r   c                 C   s   | ddddƒS )Nr»   ra   r‚   ztest_mmap.csvr   )rÃ   r   r   r   Ú	mmap_file�  s   rô   c                   @   sX   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zej 	d	d
dg¡ej 	dddg¡dd„ ƒƒZ
dS )ÚTestMMapWrapperc                 C   sÖ   t dƒ}dd„ |_tƒ rd}t}nd}tj}tj||d�� t 	|d¡ W d   ƒ n1 s.w   Y  t
|dd	��}W d   ƒ n1 sDw   Y  d
}tjt|d�� t 	|d¡ W d   ƒ d S 1 sdw   Y  d S )NzI am not a filec                   S   s   dS )Néÿÿÿÿr   r   r   r   r   r·   •  s    z;TestMMapWrapper.test_constructor_bad_file.<locals>.<lambda>zThe parameter is incorrectz
[Errno 22]rœ   Tr]   ©ÚencodingzI/O operation on closed file)r   Úfilenor   rì   ÚmmapÚerrorr8   rŸ   r   Ú_maybe_memory_mapr<   Ú
ValueError)r   rô   Únon_fileÚmsgÚerrÚtargetr   r   r   Útest_constructor_bad_file“  s"   
ÿÿ"ÿz)TestMMapWrapper.test_constructor_bad_filec              
   C   sò   t |dd��i}| ¡ }tj|dddd��C}|j}t|jjtjƒs"J ‚|D ]}t|ƒ}| 	¡ | 	¡ ks4J ‚q$t
jtdd�� t|ƒ W d   ƒ n1 sKw   Y  W d   ƒ n1 sZw   Y  W d   ƒ d S W d   ƒ d S 1 srw   Y  d S )Nr]   r÷   rS   T)rZ   Ú
memory_mapz^$rœ   )r<   Ú	readlinesr   rM   rN   Ú
isinstanceÚbufferrú   r|   Ústripr8   rŸ   ÚStopIteration)r   rô   r  ÚlinesÚwrappersÚwrapperÚlineÚ	next_liner   r   r   Ú	test_next©  s&   ÿ
ÿ€öý"ýzTestMMapWrapper.test_nextc              	   C   sÊ   t  ¡ �W}tjdt d¡ d¡ tjtdƒt	d�tjdd„ t
dƒD ƒt	d�d	�}| |¡ tjtd
d�� tj|dd� W d   ƒ n1 sFw   Y  W d   ƒ d S W d   ƒ d S 1 s^w   Y  d S )Nçš™™™™™ñ?éx   ©é   r°   ÚABCD©Údtypec                 S   ó   g | ]}d |› �‘qS ©zi-r   ©Ú.0Úir   r   r   Ú
<listcomp>¿  ó    z7TestMMapWrapper.test_unknown_engine.<locals>.<listcomp>r  ©ÚcolumnsÚindexzUnknown enginerœ   Úpyt)rÈ   )r:   r;   ro   rp   ÚnpÚarangeÚreshapeÚIndexÚlistÚobjectÚrangerÆ   r8   rŸ   rý   rq   ©r   r   rv   r   r   r   Útest_unknown_engineº  s   
ý
ÿù"ùz#TestMMapWrapper.test_unknown_enginec                 C   s˜   t  ¡ �>}tjdt d¡ d¡ tjtdƒt	d�tjdd„ t
dƒD ƒt	d�d	�}|j|d
d� t  |tj|dd�¡ W d  ƒ dS 1 sEw   Y  dS )z\
        'encoding' shouldn't be passed to 'open' in binary mode.

        GH 35058
        r  r  r  r  r  c                 S   r  r  r   r  r   r   r   r  Ï  r  z4TestMMapWrapper.test_binary_mode.<locals>.<listcomp>r  r  zw+br6   r   ©Ú	index_colN)r:   r;   ro   rp   r!  r"  r#  r$  r%  r&  r'  rÆ   rs   rq   r(  r   r   r   Útest_binary_modeÅ  s   
ý"ùz TestMMapWrapper.test_binary_moderø   zutf-16zutf-32Úcompression_Úbz2Úxzc              	   C   s   t jdt d¡ d¡ t jtdƒtd�t jdd„ tdƒD ƒtd�d	�}t	 
¡ �O}t	 t¡� |j|||d
� W d  ƒ n1 s@w   Y  d}tjt|d�� t j|||d
� W d  ƒ n1 saw   Y  W d  ƒ dS W d  ƒ dS 1 syw   Y  dS )zš
        bz2 and xz do not write the byte order mark (BOM) for utf-16/32.

        https://stackoverflow.com/questions/55171439

        GH 35681
        r  r  r  r  r  c                 S   r  r  r   r  r   r   r   r  á  r  z@TestMMapWrapper.test_warning_missing_utf_bom.<locals>.<listcomp>r  r  )rA   rø   NzHUTF-\d+ stream does not start with BOM|'utf-\d+' codec can't decode byterœ   )ro   rp   r!  r"  r#  r$  r%  r&  r'  r:   r;   Úassert_produces_warningÚUnicodeWarningrÆ   r8   rŸ   ÚUnicodeErrorrq   )r   rø   r-  rv   r   rÿ   r   r   r   Útest_warning_missing_utf_bomÔ  s"   
ý
ÿÿÿ÷	"÷z,TestMMapWrapper.test_warning_missing_utf_bomN)r   r   r   r  r  r)  r,  r8   rå   ræ   r3  r   r   r   r   rõ   ’  s    rõ   c                   C   s‚   t  d¡sJ ‚t  d¡sJ ‚t  d¡rJ ‚t  d¡rJ ‚t  d¡r#J ‚t  d¡r*J ‚t  d¡r1J ‚t  d¡r8J ‚t  d	¡s?J ‚d S )
Nzgcs://pandas/somethingelse.comzgs://pandas/somethingelse.comzhttp://pandas/somethingelse.comzrandom:pandas/somethingelse.comz/local/pathzrelative/local/pathzthis is not fsspec://urlz({'url': 'gs://pandas/somethingelse.com'}z#RFC-3986+compliant.spec://something)r   Úis_fsspec_urlr   r   r   r   Útest_is_fsspec_urlð  s   r5  rø   r]   Úformatr‚   rŒ   c              	   C   s  t jdt d¡ d¡ t jtdƒtd�t jdd„ tdƒD ƒtd�d	�}t	 
¡ �S}tj|d
| d��}t|d|› �ƒ|ƒ W d   ƒ n1 sEw   Y  tj|d| d��}|dkr_t j|dd�}nt  |¡}W d   ƒ n1 snw   Y  W d   ƒ n1 s}w   Y  t	 ||¡ d S )Nr  r  r  r  r  c                 S   r  r  r   r  r   r   r   r    r  z(test_codecs_encoding.<locals>.<listcomp>r  r  rH   )r7   rø   Úto_rS   r‚   r   r*  )ro   rp   r!  r"  r#  r$  r%  r&  r'  r:   r;   Úcodecsr<   rÕ   rq   rï   rs   )rø   r6  rE   r   rN   rv   r   r   r   Útest_codecs_encodingÿ  s$   ý
ÿ
€ü€ýr9  c               
   C   sF  t jdt d¡ d¡ t jtdƒtd�t jdd„ tdƒD ƒtd�d	�} t	 
¡ �l}t|d
ƒ�$}t d¡|ƒ�}|  |¡ W d   ƒ n1 sEw   Y  W d   ƒ n1 sTw   Y  t|dƒ�&}t d¡|ƒ�}t j|dd�}W d   ƒ n1 sxw   Y  W d   ƒ n1 s‡w   Y  W d   ƒ n1 s–w   Y  t	 | |¡ d S )Nr  r  r  r  r  c                 S   r  r  r   r  r   r   r   r    r  z1test_codecs_get_writer_reader.<locals>.<listcomp>r  r  r5   r]   rX   r   r*  )ro   rp   r!  r"  r#  r$  r%  r&  r'  r:   r;   r<   r8  Ú	getwriterrÆ   Ú	getreaderrq   rs   )rE   r   rN   Úencodedrv   r   r   r   Útest_codecs_get_writer_reader  s*   ý
ÿ€ÿÿ€ÿ€ür=  zio_class,mode,msgÚtz*a bytes-like object is required, not 'str'rm   z%string argument expected, got 'bytes'c              	   C   sÄ   t jdt d¡ d¡ t jtdƒtd�t jdd„ tdƒD ƒtd�d	�}| ƒ �2}t	j
t|d
�� |j|d|› �d� W d   ƒ n1 sCw   Y  W d   ƒ d S W d   ƒ d S 1 s[w   Y  d S )Nr  r  r  r  r  c                 S   r  r  r   r  r   r   r   r  2  r  z*test_explicit_encoding.<locals>.<listcomp>r  r  rœ   rH   r6   )ro   rp   r!  r"  r#  r$  r%  r&  r'  r8   rŸ   Ú	TypeErrorrÆ   )Úio_classr7   rÿ   rE   r  r   r   r   Útest_explicit_encoding$  s   ýÿÿ"ÿrA  Úencoding_errors)NÚstrictÚreplacec              	   C   s<  d}d}|dkrd| d |d  d | }t tjdd�}nd	|d  d
 | d | d }t tjdd�}t ¡ �[}t|ƒ}| |¡ | dkretj	t
|d�� ||| d� W d   ƒ n1 s_w   Y  n'||| d�}|j| d�}	tj|	|	gi|	d gd�}
t ||
¡ W d   ƒ d S W d   ƒ d S 1 s—w   Y  d S )Nz'utf-8' codec can't decode byteó   är‚   ó   ,ó   
r®   r   r*  s   {"s   ": {"s   ":"s   "}}r  )ÚorientrD  rœ   )rB  ©Úerrors)r  )r   ro   rq   rï   r:   r;   r   Úwrite_bytesr8   rŸ   ÚUnicodeDecodeErrorÚdecoderp   rs   )rB  r6  rÿ   Úbad_encodingÚcontentr~   r   Úfilerv   ÚdecodedrE   r   r   r   Útest_encoding_errors9  sF   ÿþýüûúÿ	

ÿ€õ€" rR  c               	   C   s|   t  ¡ �0} tjtdd�� tj| ddd� W d   ƒ n1 sw   Y  W d   ƒ d S W d   ƒ d S 1 s7w   Y  d S )Nzunknown error handler namerœ   rH   ÚbadrI  )r:   r;   r8   rŸ   ÚLookupErrorr   rM   r   r   r   r   Útest_bad_encdoing_errors\  s   
ÿÿ"ÿrU  c                  C   sN   t jtdd��} t d¡ | jtjksJ ‚W d   ƒ d S 1 s w   Y  d S )Nz\[Errno 2\]rœ   Údoesnt_exist)r8   rŸ   ré   ro   rq   ÚerrnoÚENOENT)r   r   r   r   Útest_errno_attributec  s   
"þrY  c               	   C   sz   t jtdd��, tƒ �} tj| ddd� W d   ƒ n1 sw   Y  W d   ƒ d S W d   ƒ d S 1 s6w   Y  d S )Nrù   rœ   rX   T)r  )r8   rŸ   r   r   r   rM   )r  r   r   r   Útest_fail_mmapj  s   ÿÿ"ÿrZ  c               
   C   s²   G dd„ dƒ} t jtdd��A tƒ �%}t |d¡�}|j | ƒ ¡ W d   ƒ n1 s+w   Y  W d   ƒ n1 s:w   Y  W d   ƒ d S W d   ƒ d S 1 sRw   Y  d S )Nc                   @   s   e Zd Zdd„ ZdS )z&test_close_on_error.<locals>.TestErrorc                 S   s   t dƒ‚)NÚtest)rì   r   r   r   r   Úcloses  s   z,test_close_on_error.<locals>.TestError.closeN)r   r   r   r\  r   r   r   r   Ú	TestErrorr  s    r]  r[  rœ   rX   )r8   rŸ   rì   r   r   rM   Úcreated_handlesÚappend)r]  r  rQ   r   r   r   Útest_close_on_errorp  s   ÿ€ÿÿ"ÿr`  r~   c                 C   s8   t ƒ �}t | |¡ W d   ƒ d S 1 sw   Y  d S r
   )r   r�   Údump)r~   r  r   r   r   Útest_pickle_reader|  s   "ÿrb  )Hr   r8  rW  Ú	functoolsr   r»   r   r   r   rú   r   Úpathlibr   r�   rI   Únumpyr!  r8   Úpandas.compatr   Úpandas.util._test_decoratorsÚutilÚ_test_decoratorsrã   Úpandasro   Úpandas._testingÚ_testingr:   Úpandas.io.commonÚcommonr   rå   ÚfilterwarningsÚ
pytestmarkr   rè   rç   Úpy.pathr   r,   r_  ÚImportErrorr   r+   ÚdirnameÚ__file__rž   r   Úfixturerô   rõ   r5  ræ   r9  r=  rA  rR  rU  rY  rZ  r`  rq   rê   rÖ   rë   rá   rí   rî   rï   rð   rb  r   r   r   r   Ú<module>   sˆ    ÿ
ÿ  U
^þþ
!÷þ