
    bMh]                     z   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Z ddlmc mZ ddlZddlmZ ddlmc m Z! ej"        #                    d          Z$ G d	 d
          Z%e&e%egZ'	 ddl(m)Z* e'+                    e*           n# e,$ r Y nw xY we
j-        .                    e
j-        /                    e0                    Z1 G d d          Z2ej3        d             Z4 G d d          Z5d Z6ej"        7                    dddg          ej"        7                    dddg          d                         Z8d Z9ej"        7                    deddfeddfg          d             Z:ej"        7                    dg d           ej"        7                    dddg          d!                         Z;d" Z<d# Z=d$ Z>d% Z?ej"        7                    d&ej@        ejA        ejB        ejC        ejD        ejE        ejF        ejG        ejH        g	          d'             ZIdS )(z0
Tests for the pandas.io.common functionalities
    N)partial)BytesIOStringIOUnsupportedOperation)Path)is_platform_windows)pa_version_under19p0z=ignore:Passing a BlockManager to DataFrame:DeprecationWarningc                        e Zd ZdZddZd ZdS )CustomFSPathz%For testing fspath on unknown objectsreturnNc                     || _         d S Npath)selfr   s     [/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pandas/tests/io/test_common.py__init__zCustomFSPath.__init__&   s    			    c                     | j         S r   r   r   s    r   
__fspath__zCustomFSPath.__fspath__)   s
    yr   )r   N)__name__
__module____qualname____doc__r   r    r   r   r   r   #   s=        //       r   r   )localc                   T   e Zd ZdZd Zd Zd Z ej        d          d             Z	d Z
d Zej                            d	e          d
             Zej                            d	eeeg          d             Zd Zd Zd Z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             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"             Z/ej                            dej        dedfej0        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#             Z1ej                            d$ej        dd%fej0        dd%fej        dd&fej        dd'fej        dd(f ej2        ej         dd)ej        3                    d*d+,          -          ej!        dd.fej"        dd/fej#        dd0fej$        dd1fg
          d2             Z4ej                            d3d4i dfd5d6d7id7fd8i dfd9i dfd:i dfd;i dfd<i dfd=d> ej5        d?          idfg          d@             Z6dA Z7dBS )C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                     d}t          j        |          }||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_names      r   test_expand_userz)TestCommonIOCapabilities.test_expand_userE   si    )(33((((w}}]+++++w!!(++}<<<<<<r   c                     d}t          j        |          }||k    sJ t          j                            |          |k    sJ d S )Nz/somefolder/sometest)r!   r"   r#   r   r%   r&   s      r   test_expand_user_normal_pathz5TestCommonIOCapabilities.test_expand_user_normal_pathM   sO    ))(33((((w!!(++}<<<<<<r   c                     t          j        t          d                    }|dk    sJ t          j        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_paths      r   test_stringify_path_pathlibz4TestCommonIOCapabilities.test_stringify_path_pathlibT   sd    &tCyy113,T*-=-=>>eU!;!;;;;;;;r   zpy.pathc                     t           j                            dd          }t           j                            |          }t	          |          }t          j        |          |k    sJ d S )Nr.   r/   )r#   r   r1   abspath	LocalPathr!   r0   )r   r   abs_pathlpaths       r   test_stringify_path_localpathz6TestCommonIOCapabilities.test_stringify_path_localpathZ   sW    w||E5))7??4(($"5))X555555r   c                 \    t          d          }t          j        |          }|dk    sJ d S )Nfoo/bar.csv)r   r!   r0   )r   presults      r   test_stringify_path_fspathz3TestCommonIOCapabilities.test_stringify_path_fspatha   s6    ''$Q''&&&&&&r   c                     t          j        d          }t          j                    5 }|                    d| d          5 }|t          j        |          k    sJ 	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nfsspeczfile://wbmode)pytestimportorskiptmensure_cleanopenr!   r0   )r   rA   r   
fsspec_objs       r   !test_stringify_file_and_path_likez:TestCommonIOCapabilities.test_stringify_file_and_path_likef   s4   $X.._ 	E$-t--D99 EZ!T%8%D%DDDDDDE E E E E E E E E E E E E E E	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	Es5   BA+B+A/	/B2A/	3BB
B	path_typec                 h    |\  }} |d|z             }t          j        |d          }||k    sJ d S )Nr<   infer)compression)r!   infer_compression)r   compression_formatrL   	extensionexpectedr   rO   s          r    test_infer_compression_from_pathz9TestCommonIOCapabilities.test_infer_compression_from_pathm   sL    0	8y233,TwGGGh&&&&&&r   c                    t          j        t          j                              5 } |dt          |          j        z   dz             }t          j        |d          5 }t          |j        j                                                  sJ t          j
                            |          |j        j        k    sJ 	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )N)dirz~/z	/sometestw)tempfileTemporaryDirectoryr   homenamer!   
get_handlehandleis_absoluter#   r   r%   )r   rL   tmpr'   handless        r   test_get_handle_with_pathz2TestCommonIOCapabilities.test_get_handle_with_patht   su    (TY[[999 	KS yS		!6!DEEH3// K7GN/00<<>>>>>w))(33w~7JJJJJJK K K K K K K K K K K K K K K	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	Ks6   9C" AC
>C"
C	C"C	C""C&)C&c                     t                      5 }t          j        |d          5 }|j        |k    sJ 	 d d d            n# 1 swxY w Y   |j        rJ 	 d d d            n# 1 swxY w Y   |j        sJ d S )Nr)r   r!   r\   r]   closed)r   input_bufferr`   s      r   test_get_handle_with_bufferz4TestCommonIOCapabilities.test_get_handle_with_buffer}   s   ZZ 	+<s33 6w~555556 6 6 6 6 6 6 6 6 6 6 6 6 6 6#*****	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ """"""s3   A!A A! A	A!A	A!!A%(A%c                    d}t          j        t          |          dd          5 }d}d}	 |j                            |          }t          |          |k    sJ t          |          |k     r2t          |j                                                  dk    sJ ||z  }n||z  }z||                    d	          k    sJ 	 d d d            d S # 1 swxY w Y   d S )
N&   a,b,c
1,2,3
©,®,®
Look,a snake,🐍rbFis_textr      Tr   utf-8)r!   r\   r   r]   readlenencode)r   datar`   r>   	chunksizechunks         r   )test_bytesiowrapper_returns_correct_byteszBTestCommonIOCapabilities.test_bytesiowrapper_returns_correct_bytes   s:    _Xd^^T5AAA 	2WFI
 ++I665zzY....u::	)) w~224455::::eOF%
  T[[1111111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   BCCCc                    t          j        d          }d}t          j        g dg dg dd          }t	          |          }t          j        |dd	          5 }|                    |j                  	                                }t          r|                    d
          }t          j        ||           |j        rJ 	 d d d            d S # 1 swxY w Y   d S )Nzpyarrow.csvrh   )1   ©Look)2   ®za snake)3rz   u   🐍abcri   Frj   object)rE   rF   pd	DataFramer   r!   r\   read_csvr]   	to_pandasr	   astyperG   assert_frame_equalrd   )r   pa_csvrq   rS   sr`   dfs          r   test_get_handle_pyarrow_compatz7TestCommonIOCapabilities.test_get_handle_pyarrow_compat   s.   $]33 <%%%,B,B,BI\I\I\]]
 
 TNN_Qe444 	 00::<<B# 5#??844!"h///x	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   A'CCCc                 r   t          j        t          | j                  d          5 }t          j        |d          }d d d            n# 1 swxY w Y   t          j        t          | j                            }t          j        ||           t          j        t          | j                  d          5 }t          |          }t          j        ||j        dg                    t          j        t          j        |          |j        dd                     d d d            d S # 1 swxY w Y   d S )N   )rr   T)ignore_indexr   )	r   r   r   data1concatrG   r   nextiloc)r   readerr>   rS   itfirsts         r   test_iteratorz&TestCommonIOCapabilities.test_iterator   s   [$*--;;; 	:vYvD999F	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:;x
3344
fh/// [$*--;;; 	DrHHE!%s);<<<!")B--qrr1BCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Ds$   AAA:A%D,,D03D0z#reader, module, error_class, fn_extr#   csvtxtxlrdxlsxpyarrowfeathertablesh5dtasas7bdatjsonpicklec                 z   t          j        |           t          j                            t
          dd|z             }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          5   ||           d d d            d S # 1 swxY w Y   d S )Nrq   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 value7path_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)rE   rF   r#   r   r1   HEREraises)r   r   moduleerror_classfn_extr   msg1msg2msg3msg4msg5msg6msg7msg8s                 r   test_read_non_existentz/TestCommonIOCapabilities.test_read_non_existent   s    	F###w||D&*;f*DEEHvHHHVVVVV)H-6 - -#)- - - 	 YvXXXXvXXX 	 GfFF]OtOOdOOTOODOO4OO$OOOOOOO
 
 
 	 	 F4LLL		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   B00B47B4z#method, module, error_class, fn_exthtmlparquetc                 4   t          j        |           t          j        g dg dg dd          }t          j                            t          ddd|z             }t          j        |d	          5   |||           d d d            d S # 1 swxY w Y   d S )
N)r         )r   r      )r   r   rl   r|   rq   missing_folderr   z@Cannot save file into a non-existent directory: .*missing_folderr   )	rE   rF   r   r   r#   r   r1   r   r   )r   methodr   r   r   dummy_framer   s          r   #test_write_missing_parent_directoryz<TestCommonIOCapabilities.test_write_missing_parent_directory   s     	F###l#S#STTw||D&*:<MPV<VWW]U
 
 
 	& 	& F;%%%		& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s   3BBBc                    t          j        |           t          j                            dd|z             }|                    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          5   ||           d d d            d S # 1 swxY w Y   d S )N~r   r"   c                 B    t           j                            d|           S )Nr.   )r#   r   r1   )xs    r   <lambda>zJTestCommonIOCapabilities.test_read_expands_user_home_dir.<locals>.<lambda>  s    BGLLPQ<R<R r   r   r   r   r   z0Unexpected character found when decoding 'false'r   r   r   r   r   r   r   r   r   r   )rE   rF   r#   r   r1   setattrr!   r   )r   r   r   r   r   monkeypatchr   r   r   r   r   r   r   r   r   s                  r   test_read_expands_user_home_dirz8TestCommonIOCapabilities.test_read_expands_user_home_dir   s   $ 	F###w||C!2V!;<<D.2R2RSSSHvHHHVVVVVAH-6 - -#)- - - 	 YvXXXXvXXX 	 GfFF]OtOOdOOTOODOO4OO$OOOOOOO
 
 
 	 	 F4LLL		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   .CCCzreader, module, path)iorq   r   ziris.csv)r   rq   fixed_widthzfixed_width_format.txt)r   rq   excelz
test1.xlsx)r   rq   r   zfeather-0_3_1.feather)r   rq   
legacy_hdfzdatetimetz_object.h5zTODO(infer_string)F)reasonstrict)marks)r   rq   statazstata10_115.dta)r   sasrq   ztest1.sas7bdat)r   r   rq   ztsframe_v012.json)r   rq   r   zcategorical.0.25.0.picklec                    t          j        |            || }t          |          } ||          } ||          }|                    d          rt	          j        ||           d S t	          j        ||           d S )Nz.pickle)rE   rF   r   endswithrG   assert_categorical_equalr   )r   r   r   r   datapathmypathr>   rS   s           r   test_read_fspath_allz-TestCommonIOCapabilities.test_read_fspath_all'  s    D 	F###xd##6$<<==## 	4'99999!&(33333r   z"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           	      *   |dv rt          j        d           t          j        d          }t          j        d          }t	          j        dddgi          }|5 }|5 }t          j        |           t          |          }	t          ||          }
 |
|fi |  |
|	fi | t          |d          5 }t          |d          5 }|d	k    r:t	          j	        |fi |}t	          j	        |fi |}t          j
        ||           n0|                                }|                                }||k    sJ d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )
N)r   jinja2stringfspathAr   r   ri   r   )rE   rF   rG   rH   r   r   r   getattrrI   
read_excelr   rn   )r   writer_namewriter_kwargsr   p1p2r   r   r   r   writerf_strf_pathr>   rS   s                  r   test_write_fspath_allz.TestCommonIOCapabilities.test_write_fspath_allV  s    ,&&)))_X&&_X&&\3A-(( 	.62 	.'''!&))FR--FF6++]+++F6++]+++fd## 
.ud64.@.@ 
.F*,,  ]5BBMBBF!}VEE}EEH)&(;;;;"ZZ\\F%{{}}H!X----
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
.	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   FAE04EA1E	6EEE	E
EE0EE0 E!E0$F0E4	4F7E4	8FFFc                    t          j        d           t          j        dddgi          }t	          j        d          }t	          j        d          }|5 }|5 }t          |          }|                    |d           |                    |d           t          j        |d          }t          j        |d          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t	          j	        ||           d S )	Nr   r   r   r   r   r   r/   )key)
rE   rF   r   r   rG   rH   r   to_hdfread_hdfr   )	r   r   r   r   r   r   r   r>   rS   s	            r   test_write_fspath_hdf5z/TestCommonIOCapabilities.test_write_fspath_hdf5}  su    	H%%%\3A-((_X&&_X&& 	662 	6!&))FIIf%I(((IIf%I((([U333F{6u555H	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	fh/////s7   C'A*CC'C	C'C	C''C+.C+N)8r   r   r   r   r)   r+   r4   td
skip_if_nor:   r?   rK   rE   markparametrize
path_typesrT   strr   r   ra   rf   rt   r   r   r   r   FileNotFoundErrorread_fwfr   read_featherOSErrorr   
read_stataread_sas	read_jsonread_pickler   r   r   r   r   r   
to_parquetr   r   r   r   
read_tabler   paramxfailr   to_datetimer   r   r   r   r   r   r   ;   s)       E= = == = =< < < R]96 6 6' ' '
E E E [[*55' ' 65' [[3d*CDDK K EDK# # #2 2 2.     &
D 
D 
D [-[$ 159[$ 159]F$5v>_i)<[($5t<]D"3U;[$ 1:>\4!2F;^T#4h?
	
   0 [-\ $7\!4&9\"FGV<\$i)D\$i)D\"D'59\!4&9\#T7H=		
 & & & [-[$ 159]D"3U;[$ 159]F$5v>_i)<[($5t<]D"3U;[$ 1:>\4!2F;^T#4h?	
   8 [[$ AB]D"CDG
 ]F$IJB
 FLDk''/CE'RR   ]D"LM[$ GH\4!LME1	
   B4 4C   B4 [,r4 (J/<2y)D!D!T""d#,7I(J(JKTR		
 . . .40 0 0 0 0r   r   c                      | dddd          S )Nr   rq   r   ztest_mmap.csvr   )r   s    r   	mmap_filer    s    8D&%999r   c                       e Zd Zd Zd Zd Zd Zej        	                    dddg          ej        	                    dd	d
g          d                         Z
dS )TestMMapWrapperc                    t          d          }d |_        t                      r
d}t          }nd}t          j        }t          j        ||          5  t          j	        |d           d d d            n# 1 swxY w Y   t          |d          5 }	 d d d            n# 1 swxY w Y   d	}t          j        t          |          5  t          j	        |d           d d d            d S # 1 swxY w Y   d S )
NzI am not a filec                      dS )Nr   r   r   r   r   z;TestMMapWrapper.test_constructor_bad_file.<locals>.<lambda>  s    " r   zThe parameter is incorrectz
[Errno 22]r   Trm   encodingzI/O operation on closed file)r   filenor   r
  mmaperrorrE   r   r!   _maybe_memory_maprI   
ValueError)r   r  non_filemsgerrtargets         r   test_constructor_bad_filez)TestMMapWrapper.test_constructor_bad_file  s   -..$*    	.CCCC*C]3c*** 	3 	3"8T222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 )g... 	&	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 -]:S111 	1 	1"64000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s6   A66A:=A:B  B$'B$C++C/2C/c                 @   t          |d          5 }|                                }t          j        |ddd          5 }|j        }t          |j        j        t          j                  sJ |D ]=}t          |          }|	                                |	                                k    sJ >t          j        t          d          5  t          |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nrm   r  rc   T)rk   
memory_mapz^$r   )rI   	readlinesr!   r\   r]   
isinstancebufferr  r   striprE   r   StopIteration)r   r  r%  lineswrapperswrapperline	next_lines           r   	test_nextzTestMMapWrapper.test_next  s   )g... 	"&$$&&ETd   ""/!'."7CCCCC! = =D $WI$??,,

<<<<<]=>>> " "MMM" " " " " " " " " " " " " " "" " " " " " " " " " " " " " "	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"sY   -DB	C;C$C;$C((C;+C(,C;/D;C?	?DC?	DDDc                 (   t          j                    5 }t          j        dt	          j        d                              d          z  t          j        t          d                    t          j        d t          d          D                                 }|
                    |           t          j        t          d	          5  t          j        |d
           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )N皙?x      r   ABCDc                     g | ]}d | S zi-r   .0is     r   
<listcomp>z7TestMMapWrapper.test_unknown_engine.<locals>.<listcomp>      <<<QQ<<<r   r8  columnsindexzUnknown enginer   pyt)r   )rG   rH   r   r   nparangereshapeIndexlistranger   rE   r   r!  r   r   r   r   s      r   test_unknown_enginez#TestMMapWrapper.test_unknown_engine  sk   _ 	0$binn,,W555f..h<<%))<<<==  B
 IIdOOOz1ABBB 0 0D////0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s6   B8DC/#D/C3	3D6C3	7DDDc                    t          j                    5 }t          j        dt	          j        d                              d          z  t          j        t          d                    t          j        d t          d          D                                 }|
                    |d	           t          j        |t          j        |d
                     ddd           dS # 1 swxY w Y   dS )z\
        'encoding' shouldn't be passed to 'open' in binary mode.

        GH 35058
        r5  r6  r7  r9  c                     g | ]}d | S r;  r   r<  s     r   r?  z4TestMMapWrapper.test_binary_mode.<locals>.<listcomp>  r@  r   r8  rA  zw+brC   r   	index_colN)rG   rH   r   r   rE  rF  rG  rH  rI  rJ  r   r   r   rK  s      r   test_binary_modez TestMMapWrapper.test_binary_mode  s)    _ 	F$binn,,W555f..h<<%))<<<==  B
 IIdI'''!"bk$!&D&D&DEEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	Fs   CC))C-0C-r  zutf-16zutf-32compression_bz2xzc           
         t          j        dt          j        d                              d          z  t          j        t          d                    t          j        d t          d          D                                 }t          j	                    5 }t          j
        t                    5  |                    |||           d	d	d	           n# 1 swxY w Y   d
}t          j        t          |          5  t          j        |||           d	d	d	           n# 1 swxY w Y   d	d	d	           d	S # 1 swxY w 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
        r5  r6  r7  r9  c                     g | ]}d | S r;  r   r<  s     r   r?  z@TestMMapWrapper.test_warning_missing_utf_bom.<locals>.<listcomp>  s    888HHH888r   r8  rA  )rO   r  NzHUTF-\d+ stream does not start with BOM|'utf-\d+' codec can't decode byter   )r   r   rE  rF  rG  rH  rI  rJ  rG   rH   assert_produces_warningUnicodeWarningr   rE   r   UnicodeErrorr   )r   r  rR  r   r   r#  s         r   test_warning_missing_utf_bomz,TestMMapWrapper.test_warning_missing_utf_bom  s    \")C..((111HT&\\**(88eBii88899
 
 

 _ 
	O$+N;; M M		$L8	LLLM M M M M M M M M M M M M M M
5  |3777 O ODlXNNNNO O O O O O O O O O O O O O O
	O 
	O 
	O 
	O 
	O 
	O 
	O 
	O 
	O 
	O 
	O 
	O 
	O 
	O 
	O 
	O 
	O 
	OsZ   D>5CD>C	D>!C	" D>D&D>&D*	*D>-D*	.D>>EEN)r   r   r   r&  r3  rL  rQ  rE   r  r  rZ  r   r   r   r  r    s        1 1 1," " ""	0 	0 	0F F F [Z(H)=>>[^eT];;O O <; ?>O O Or   r  c                     t          j        d          sJ t          j        d          sJ t          j        d          rJ t          j        d          rJ t          j        d          rJ t          j        d          rJ t          j        d          rJ t          j        d          rJ t          j        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   test_is_fsspec_urlr]    s    >?????=>>>>>!"CDDDDD!"CDDDDD!-00000!"788888!"<=====!"LMMMMMCDDDDDDDr   r  rm   formatr   r   c           
         t          j        dt          j        d                              d          z  t          j        t          d                    t          j        d t          d          D                                 }t          j	                    5 }t          j        |d| 	          5 } t          |d
|           |           d d d            n# 1 swxY w Y   t          j        |d| 	          5 }|dk    rt          j        |d          }nt          j        |          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j        ||           d S )Nr5  r6  r7  r9  c                     g | ]}d | S r;  r   r<  s     r   r?  z(test_codecs_encoding.<locals>.<listcomp>      444QQ444r   r8  rA  rW   )rD   r  to_rc   r   r   rO  )r   r   rE  rF  rG  rH  rI  rJ  rG   rH   codecsrI   r   r   r  r   )r  r^  rS   r   r]   r   s         r   test_codecs_encodingrd    s
    |binn$$W---f&&h44%))44455  H
 
		 *d[C(;;; 	6v-GHnFnn--f555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6[C(;;; 	*v[1555\&))		* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	** * * * * * * * * * * * * * * (B'''''sZ   E3CEC 	 E#C 	$E>2D<0E<E 	 EE 	EEEc            
      ^   t          j        dt          j        d                              d          z  t          j        t          d                    t          j        d t          d          D                                 } t          j	                    5 }t          |d          5 } t          j        d	          |          5 }|                     |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          |d
          5 } t          j        d	          |          5 }t          j        |d          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j        | |           d S )Nr5  r6  r7  r9  c                     g | ]}d | S r;  r   r<  s     r   r?  z1test_codecs_get_writer_reader.<locals>.<listcomp>  ra  r   r8  rA  rB   rm   ri   r   rO  )r   r   rE  rF  rG  rH  rI  rJ  rG   rH   rI   rc  	getwriterr   	getreaderr   r   )rS   r   r]   encodedr   s        r   test_codecs_get_writer_readerrj    s   |binn$$W---f&&h44%))44455  H
 
		 7d$ 	)*!'**622 )g((() ) ) ) ) ) ) ) ) ) ) ) ) ) )	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) $ 	7*!'**622 7g[A6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7	7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 (B'''''s   F,D
C, D,C00D3C04D7FD	F
D	FE6<EE6E##E6&E#'E6*F6E:	:F=E:	>FFFzio_class,mode,msgtz*a bytes-like object is required, not 'str'r~   z%string argument expected, got 'bytes'c           
         t          j        dt          j        d                              d          z  t          j        t          d                    t          j        d t          d          D                                 } |             5 }t          j	        t          |          5  |                    |d	| 
           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr5  r6  r7  r9  c                     g | ]}d | S r;  r   r<  s     r   r?  z*test_explicit_encoding.<locals>.<listcomp>7  ra  r   r8  rA  r   rW   rC   )r   r   rE  rF  rG  rH  rI  rJ  rE   r   	TypeErrorr   )io_classrD   r#  rS   r+  s        r   test_explicit_encodingrp  )  sb    |binn$$W---f&&h44%))44455  H
 
 5v]9C000 	5 	5OOFTO444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	55 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s6   C-.C	C-C	C-C	C--C14C1encoding_errors)Nr   replacec                    d}d}|dk    r0d|z   dz   |dz  z   dz   |z   }t          t          j        d          }n2d	|dz  z   d
z   |z   dz   |z   dz   }t          t          j        d          }t	          j                    5 }t          |          }|                    |           | dk    rAt          j	        t          |          5   |||            d d d            n# 1 swxY w Y   nU |||           }|                    |           }	t          j        |	|	gi|	dz  g          }
t	          j        ||
           d d d            d S # 1 swxY w Y   d S )Nz'utf-8' codec can't decode byte   r      ,   
r   r   rO  s   {"s   ": {"s   ":"s   "}}rC  )orientrr  r   )rq  errors)rC  )r   r   r   r  rG   rH   r   write_bytesrE   r   UnicodeDecodeErrordecoder   r   )rq  r^  r#  bad_encodingcontentr   r   filer   decodedrS   s              r   test_encoding_errorsr  >  s'    ,CL%-q0@@4G,V222 Q  	
   	 g666			 0dDzz!!!i''1=== > >t_====> > > > > > > > > > > > > > > o>>>B")))AAG|Wwi$81NNNH!"h///0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0s8    AEC E C$	$E'C$	(AEEEc                      t          j                    5 } t          j        t          d          5  t          j        | dd           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nzunknown error handler namer   rW   badrx  )rG   rH   rE   r   LookupErrorr!   r\   r   s    r   test_bad_encdoing_errorsr  a  s    			 5d];.JKKK 	5 	5OD#e4444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	55 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s4   A,AA,A	A,A	A,,A03A0c                      t          j        t          d          5 } t          j        d           | j        t
          j        k    sJ 	 d d d            d S # 1 swxY w Y   d S )Nz\[Errno 2\]r   doesnt_exist)rE   r   r  r   r   errnoENOENT)r$  s    r   test_errno_attributer  h  s    	(	@	@	@ )C
N###yEL((((() ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )s   ,AAAc                      t          j        t          d          5  t                      5 } t	          j        | dd           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr  r   ri   T)r(  )rE   r   r   r   r!   r\   )r+  s    r   test_fail_mmapr  o  s    	+8	<	<	< ; ;YY 	;&OFDT::::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s4   A'AA'A	A'A	A''A+.A+c                  r    G d d          } t          j        t          d          5  t                      5 }t	          j        |d          5 }|j                             |                        d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nc                       e Zd Zd ZdS )&test_close_on_error.<locals>.TestErrorc                      t          d          )Ntest)r
  r   s    r   closez,test_close_on_error.<locals>.TestError.closex  s    &//!r   N)r   r   r   r  r   r   r   	TestErrorr  w  s#        	" 	" 	" 	" 	"r   r  r  r   ri   )rE   r   r
  r   r!   r\   created_handlesappend)r  r+  r`   s      r   test_close_on_errorr  u  s   " " " " " " " " 
wf	-	-	- < <YY 	<&.. <''..yy{{;;;< < < < < < < < < < < < < < <	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<< < < < < < < < < < < < < < < < < <sX   B,B#A=1B=BBBBB,B	B,B	B,,B03B0r   c                 ~    t                      5 }t          j        | |           d d d            d S # 1 swxY w Y   d S r   )r   r   dump)r   r+  s     r   test_pickle_readerr    s      
 $fFF###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $s   266)Jr   rc  r  	functoolsr   r   r   r   r   r  r#   pathlibr   r   rX   numpyrE  rE   pandas.compatr   pandas.compat.pyarrowr	   pandas.util._test_decoratorsutil_test_decoratorsr  pandasr   pandas._testing_testingrG   pandas.io.commoncommonr!   r  filterwarnings
pytestmarkr   r  r  py.pathr   r7   r  ImportErrorr   r6   dirname__file__r   r   fixturer  r  r]  r  rd  rj  rp  r  r  r  r  r  r   r  r   r	  r   r  r  r  r  r  r   r   r   <module>r     s:                    
  				              - - - - - - 6 6 6 6 6 6 ) ) ) ) ) ) ) ) )                   [''C 

        <&
	******i     	 	 	D	 
wrwx0011T0 T0 T0 T0 T0 T0 T0 T0n
 : : :[O [O [O [O [O [O [O [O|E E E dG_55E6?33( ( 43 65($( ( (" 	#CD	3?@ 5 5 5 *,G,G,GHHE6?330 0 43 IH0B5 5 5) ) ); ; ;	< 	< 	< 









 $ $ $ $ $s   B* *B21B2