
    Pia                        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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
j'        (                    e
j'        )                    e*                    Z+ G d d          Z,ej-        d             Z. G d d          Z/d Z0d Z1ej#        2                    dddg          d             Z3d Z4ej#        2                    deddfeddfg          d             Z5ej#        2                    dddg          ej#        2                    dddg          d                          Z6ej#        2                    dddg          d!             Z7d" Z8ej#        9                    ed#$          d%             Z:d& Z;d' Z< ej=        d(          ej#        2                    d)dd*g          d+                         Z>ej#        2                    d,ej?        ej@        ejA        ejB        ejC        ejD        ejE        ejF        ejG        g	          d-             ZH ej=        d.          d/             ZIdS )0z0
Tests for the pandas.io.common functionalities
    N)partial)BytesIOStringIOUnsupportedOperation)Path)WASM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     o/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/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   c                   ^   e Zd ZdZd Zd Zd Zd Zd Ze	j
                            deeeg          d             Ze	j
                            deeeg          d	             Zd
 Zd Zd Zd Ze	j
                            ed          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
                            ed          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ej"        dedfg
          d#                         Z/e	j
                            d$ej        dd%fej.        dd%fej        dd&fej        dd'fej        dd(fej        dd)fej        dd*fej         dd+fej!        dd,fej"        dd-fg
          d.             Z0e	j
                            d/d0i dfd1d2d3id3fd4i dfd5i dfd6i dfd7i dfd8i dfd9d: ej1        d;          idfg          d<             Z2d= Z3d>S )?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_user?   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_pathG   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_pathlibN   sd    &tCyy113,T*-=-=>>eU!;!;;;;;;;r   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_fspathT   s6    ''$Q''&&&&&&r   c                     t          j        d          }|                    d| d          5 }|t          j        |          k    sJ 	 d d d            d S # 1 swxY w Y   d S )Nfsspeczfile://wbmode)pytestimportorskipopenr!   r0   )r   	temp_filer;   
fsspec_objs       r   !test_stringify_file_and_path_likez:TestCommonIOCapabilities.test_stringify_file_and_path_likeY   s    $X..[[.9..T[:: 	Aj!4Z!@!@@@@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	As   AAA	path_typec                 h    |\  }} |d|z             }t          j        |d          }||k    sJ d S )Nr6   infer)compression)r!   infer_compression)r   compression_formatrE   	extensionexpectedr   rH   s          r    test_infer_compression_from_pathz9TestCommonIOCapabilities.test_infer_compression_from_path_   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   rE   tmpr'   handless        r   test_get_handle_with_pathz2TestCommonIOCapabilities.test_get_handle_with_pathf   ss   (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!   rU   rV   closed)r   input_bufferrY   s      r   test_get_handle_with_bufferz4TestCommonIOCapabilities.test_get_handle_with_buffern   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!   rU   r   rV   readlenencode)r   datarY   r8   	chunksizechunks         r   )test_bytesiowrapper_returns_correct_byteszBTestCommonIOCapabilities.test_bytesiowrapper_returns_correct_bytesv   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.csvra   )1   ©Look)2   ®za snake)3rs   u   🐍abcrb   Frc   object)r?   r@   pd	DataFramer   r!   rU   read_csvrV   	to_pandasr
   astypetmassert_frame_equalr]   )r   pa_csvrj   rL   srY   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   )rk   T)ignore_indexr   )	rz   r|   r   data1concatr   r   nextiloc)r   readerr8   rL   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"limited file system access on WASMreasonz#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 )Nrj   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)r?   r@   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   re   ru   rj   missing_folderr   z@Cannot save file into a non-existent directory: .*missing_folderr   )	r?   r@   rz   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   )r?   r@   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)iorj   r   ziris.csv)r   rj   fixed_widthzfixed_width_format.txt)r   rj   excelz
test1.xlsx)r   rj   r   zfeather-0_3_1.feather)r   rj   
legacy_hdfzpytables_native2.h5)r   rj   statazstata10_115.dta)r   sasrj   ztest1.sas7bdat)r   r   rj   ztsframe_v012.json)r   rj   r   zcategorical.0.25.0.picklec                    t          j        |            || }t          |          } ||          } ||          }|                    d          rt	          j        ||           d S t	          j        ||           d S )Nz.pickle)r?   r@   r   endswithr   assert_categorical_equalr   )r   r   r   r   datapathmypathr8   rL   s           r   test_read_fspath_allz-TestCommonIOCapabilities.test_read_fspath_all  s    @ 	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          |dz            }t          |dz            }t          j        dddgi          }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            d S # 1 swxY w Y   d S )
N)r   jinja2stringfspathAr   r   rb   r   )r?   r@   strrz   r{   r   getattrrA   
read_excelr   r   rg   )r   writer_namewriter_kwargsr   tmp_pathr   r   r   r   writerf_strf_pathr8   rL   s                 r   test_write_fspath_allz.TestCommonIOCapabilities.test_write_fspath_allG  s    ,&&)))X())X())\3A-((F###f%%[))v'''''v'''''&$ 
	*5$vt*<*< 
	*j(( u>>>>=AA=AA%fh7777!;;==))))
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	* 
	*s7   *E;A1D8,E8D<	<E?D<	 EEEc                    t          j        d           t          j        dddgi          }t	          |dz            }t	          |dz            }t          |          }|                    |d           |                    |d           t          j        |d          }t          j        |d          }t          j	        ||           d S )	Nr   r   r   r   r   r   r/   )key)
r?   r@   rz   r{   r   r   to_hdfread_hdfr   r   )r   r   r   r   r   r   r8   rL   s           r   test_write_fspath_hdf5z/TestCommonIOCapabilities.test_write_fspath_hdf5m  s     	H%%%\3A-((X())X())f%%
		&e	$$$
		&e	$$$V///;v5111
fh/////r   N)4r   r   r   r   r)   r+   r4   r9   rD   r?   markparametrizer   r   r   rM   rZ   r_   rm   r   r   skipifr   rz   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   r   to_datetimer   r   r   r   r   r   r   5   s        E= = == = =< < <' ' '
A A A [[3d*CDD' ' ED' [[3d*CDDK K EDK# # #2 2 2.     &
D 
D 
D [%IJJ[-[$ 159[$ 159]F$5v>_i)<[($5t<]D"3U;[$ 1:>\4!2F;^T#4h?
	
    KJ0 [-\ $7\!4&9\"FGV<\$i)D\$i)D\"D'59\!4&9\#T7H=		
 & & & [%IJJ[-[$ 159]D"3U;[$ 159]F$5v>_i)<[($5t<]D"3U;[$ 1:>\4!2F;^T#4h?	
    KJ 8 [[$ AB]D"CDG
 ]F$IJB C
 ]D"LM[$ GH\4!LME-	
 >4 4? >4 [,r4 (J/<2y)D!D!T""d#,7I(J(JKTR		
 * * *20 0 0 0 0r   r   c                      | dddd          S )Nr   rj   r   ztest_mmap.csvr   )r   s    r   	mmap_filer
    s    8D&%999r   c                   @   e Zd Zej                            ed          d             Zej                            ed          d             Zd Z	d Z
ej                            ddd	g          ej                            d
ddg          d                         ZdS )TestMMapWrapperr   r   c                    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   Trf   encodingzI/O operation on closed file)r   filenor	   r  mmaperrorr?   r   r!   _maybe_memory_maprA   
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 )Nrf   r  r\   T)rd   
memory_mapz^$r   )rA   	readlinesr!   rU   rV   
isinstancebufferr  r   stripr?   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        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            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>      888HHH888r   r-  columnsindexzUnknown enginer   pyt)r   )rz   r{   nparangereshapeIndexlistranger   r?   r   r  r|   r   rB   r   s      r   test_unknown_enginez#TestMMapWrapper.test_unknown_engine  s   \")C..((111HT&\\**(88eBii88899
 
 

 			)]:-=>>> 	1 	1K	%0000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   8CC #C c           
         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S )z\
        'encoding' shouldn't be passed to 'open' in binary mode.

        GH 35058
        r*  r+  r,  r.  c                     g | ]}d | S r0  r   r1  s     r   r4  z4TestMMapWrapper.test_binary_mode.<locals>.<listcomp>  r5  r   r-  r6  zw+br=   r   	index_colN)rz   r{   r:  r;  r<  r=  r>  r?  r   r   r   r|   r@  s      r   test_binary_modez TestMMapWrapper.test_binary_mode  s     \")C..((111HT&\\**(88eBii88899
 
 

 			)%	(((
b"+i1"E"E"EFFFFFr   r  zutf-16zutf-32compression_bz2xzc           
      D   t          j        dt          j        d                              d          z  t          j        t          d                    t          j        d t          d          D                                 }t          j	        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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
        r*  r+  r,  r.  c                     g | ]}d | S r0  r   r1  s     r   r4  z@TestMMapWrapper.test_warning_missing_utf_bom.<locals>.<listcomp>  r5  r   r-  r6  zbyte order markr   )rH   r  NzHUTF-\d+ stream does not start with BOM|'utf-\d+' codec can't decode byte)rz   r{   r:  r;  r<  r=  r>  r?  r   assert_produces_warningUnicodeWarningr   r?   r   UnicodeErrorr|   )r   r  rG  rB   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PPP 	N 	NIIi\HIMMM	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N
1 	 ]<s333 	P 	PK	|hOOOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	Ps$   #CCC0DDDN)r   r   r   r?   r   r   r   r  r(  rA  rF  r   rO  r   r   r   r  r    s        [%IJJ1 1 KJ1, [%IJJ" " KJ""1 1 1G G G [Z(H)=>>[^eT];;P P <; ?>P P P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_urlrS    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   c                  :   t          j        d          sJ t          j        d          sJ 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 d S )Nzfilecache::s3://pandas/test.csvz0zip://test.csv::filecache::gcs://bucket/file.zipz0filecache::zip://test.csv::gcs://bucket/file.zipz%filecache::dask::s3://pandas/test.csvzfilecache:s3://pandas/test.csvz filecache:::s3://pandas/test.csvzfilecache::://pandas/test.csvrQ  r   r   r   test_is_fsspec_url_chainedrU    s     ?@@@@@PQQQQQPQQQQQEFFFFF!"BCCCCC!"DEEEEE!"ABBBBBBBr   formatr   r   c           
      ~   t          j        dt          j        d                              d          z  t          j        t          d                    t          j        d t          d          D                                 }t          |dd	
          5 } t          |d|            |           d d d            n# 1 swxY w Y   t          |d	          5 }| dk    rt          j
        |d          }nt          j        |          }d d d            n# 1 swxY w Y   t          j        ||           d S )Nr*  r+  r,  r.  c                     g | ]}d | S r0  r   r1  s     r   r4  z(test_codecs_encoding.<locals>.<listcomp>      444QQ444r   r-  r6  rP   rf   )r>   r  to_r  r   r   rD  )rz   r{   r:  r;  r<  r=  r>  r?  rA   r   r|   r  r   r   )rV  rB   rL   rV   r   s        r   test_codecs_encodingr[    s    |binn$$W---f&&h44%))44455  H
 
icG	4	4	4 2)...))&1112 2 2 2 2 2 2 2 2 2 2 2 2 2 2	i'	*	*	* &fU??Vq111BBf%%B	& & & & & & & & & & & & & & &
 (B'''''s$   CC
C2DD!$D!c           
         t          j        dt          j        d                              d          z  t          j        t          d                    t          j        d t          d          D                                 }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   t          j        ||           d S )Nr*  r+  r,  r.  c                     g | ]}d | S r0  r   r1  s     r   r4  z1test_codecs_get_writer_reader.<locals>.<listcomp>  rY  r   r-  r6  r<   rf   rb   r   rD  )rz   r{   r:  r;  r<  r=  r>  r?  rA   codecs	getwriterr   	getreaderr|   r   r   )rB   rL   rV   encodedr   s        r   test_codecs_get_writer_readerrb    sN   |binn$$W---f&&h44%))44455  H
 
i		 %&&Vg&&v.. 	%'OOG$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%% % % % % % % % % % % % % % % 
i		 3&&Vg&&v.. 	3'W222B	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	33 3 3 3 3 3 3 3 3 3 3 3 3 3 3 (B'''''sl   C/6CC/C	C/C	 C//C36C3
E"(E?E"E	E"E	E""E&)E&zio_class,mode,msgtz*a bytes-like object is required, not 'str'rw   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 )Nr*  r+  r,  r.  c                     g | ]}d | S r0  r   r1  s     r   r4  z*test_explicit_encoding.<locals>.<listcomp>.  rY  r   r-  r6  r   rP   r=   )rz   r{   r:  r;  r<  r=  r>  r?  r?   r   	TypeErrorr   )io_classr>   r  rL   r   s        r   test_explicit_encodingrh     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strictreplacec                 H   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          }|}|                    |           | dk    rCt          j        t          |          5   |||            d d d            d S # 1 swxY w Y   d S  |||           }|                    |           }	t          j	        |	|	gi|	dz  g          }
t          j        ||
           d S )Nz'utf-8' codec can't decode byte   r      ,   
r   r   rD  s   {"s   ": {"s   ":"s   "}}r8  )orientrk  r   ri  errors)r8  )r   rz   r|   r  write_bytesr?   r   UnicodeDecodeErrordecoder{   r   r   )ri  rV  rB   r  bad_encodingcontentr   filer   decodedrL   s              r   test_encoding_errorsr{  5  s    ,CL%-q0@@4G,V222 Q  	
   	 g666DW)##]-S999 	? 	?F9o>>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? VI???%%_%==<7) 4Wq[MJJJ
b(+++++s   %C  CCc                    t          d          }t          t          j        |           }d}|t	          |           j         z  }t          j        t          |          5   ||           d d d            d S # 1 swxY w Y   d S )NzA,B
1,2
3,4
rq  z&encoding_errors must be a string, got r   )	r   r   rz   r|   typer   r?   r   r  )ri  rx  r   expected_errors       r   test_encoding_errors_badtyper  W  s     ())GR[/BBBF=No..799N	z	8	8	8  w                 s    A99A= A=c                     t          j        t          d          5  t          j        | dd           d d d            d S # 1 swxY w Y   d S )Nzunknown error handler namer   rP   badrr  )r?   r   LookupErrorr!   rU   )rB   s    r   test_bad_encdoing_errorsr  b  s    	{*F	G	G	G 6 6	3u55556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6s   AAAr   r   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)r?   r   r   rz   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   rb   T)r  )r?   r   r   r   r!   rU   )r   s    r   test_fail_mmapr  p  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.closey  s    &//!r   N)r   r   r   r  r   r   r   	TestErrorr  x  s#        	" 	" 	" 	" 	"r   r  r  r   rb   )r?   r   r  r   r!   rU   created_handlesappend)r  r   rY   s      r   test_close_on_errorr  v  s   " " " " " " " " 
wf	-	-	- < <YY 	<&.. <''..yy{{;;;< < < < < < < < < < < < < < <	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<< < < < < < < < < < < < < < < < < <sX   B,B#A=1B=BBBBB,B	B,B	B,,B03B0r;   rH   rG   c                      | dddd          }d| }t          j        ||d          }t          j        dd	idd
id          }t          j        ||           d S )Nr   rj   tarztest-csv.tarztar://test.csv::file://;)rH   sepr   r   r   )ro   rr   )rz   r|   r{   r   r   )r   rH   tar_file_pathchained_file_urlr8   rL   s         r   "test_read_csv_chained_url_no_errorr    sv     HT65.AAM@@@[){LLLF|1a&1v6677H(F+++++r   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r   c                      d} t          j        t          |           dgdd          }t          j        dt           j        dgd          }t          j        d|i          }t          j        ||           d S )	Nz#"date"
"20/12/2025"
""
"31/12/2020"dateTr   )parse_datesdayfirstdtype_backendz
20/12/2025z
31/12/2020)r  )rz   r|   r   r  NaTr{   r   r   )rj   r8   expect_dataexpects       r   $test_pyarrow_read_csv_datetime_dtyper    s}     4D[VHt9  F .,!EPTUUUK\6;/00F&&)))))r   )Jr   r^  r  	functoolsr   r   r   r   r   r  r#   pathlibr   r   rQ   numpyr:  r?   pandas.compatr   r	   pandas.compat.pyarrowr
   pandas.util._test_decoratorsutil_test_decoratorstdpandasrz   pandas._testing_testingr   pandas.io.commoncommonr!   r   filterwarnings
pytestmarkr   r   abspathdirname__file__r   r   fixturer
  r  rS  rU  r   r[  rb  rh  r{  r  r  r   r  r  r  
skip_if_nor  r|   r   r   r   r   r  r  r  r  r  r  r   r   r   <module>r     s                    
  				                     7 6 6 6 6 6 ) ) ) ) ) ) ) ) )                   [''C 

        
wrwx0011I0 I0 I0 I0 I0 I0 I0 I0X
 : : :ZP ZP ZP ZP ZP ZP ZP ZPzE E E	C 	C 	C E6?33( ( 43("( ( (  	#CD	3?@ 5 5 5 *Xy,ABBE6?33, , 43 CB,@ *QI66  766 6 6 D!EFF) ) GF); ; ;	< 	< 	< xw88, , 98 , 









 $ $ $ y
* 
* 
* 
* 
*r   