
    .imb                     J   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jF                  jI                  d      Z% G d	 d
      Z&e
jN                  jQ                  e
jN                  jS                  e*            Z+ G d d      Z,ejZ                  d        Z. G d d      Z/d Z0d Z1ejF                  je                  dddg      d        Z3d Z4ejF                  je                  deddfeddfg      d        Z5ejF                  je                  dddg      ejF                  je                  dddg      d                Z6ejF                  je                  dddg      d!        Z7d" Z8ejF                  js                  ed#$      d%        Z:d& Z;d' Z< ejz                  d(      ejF                  je                  d)dd*g      d+               Z>ejF                  je                  d,ej~                  ej                  ej                  ej                  ej                  ej                  ej                  ej                  ej                  g	      d-        ZH ejz                  d.      d/        ZIy)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y)CustomFSPathz%For testing fspath on unknown objectsNc                     || _         y Npath)selfr   s     Y/var/www/app/trading-bot/venv/lib/python3.12/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    yyr   )returnN)__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                  j                  deeeg      d        Ze	j                  j                  deeeg      d	        Zd
 Zd Zd Zd Ze	j                  j+                  ed      e	j                  j                  dej0                  dedfej4                  dedfej6                  dedfej8                  dedfej<                  dedfej>                  dedfej@                  dedfejB                  dedfejD                  dedfg	      d               Z#e	j                  j                  dejH                  jJ                  dedfejH                  jL                  ded fejH                  jN                  dedfejH                  jP                  dedfejH                  jR                  ded!fejH                  jT                  dedfejH                  jV                  dedfejH                  jX                  dedfg      d"        Z-e	j                  j+                  ed      e	j                  j                  dej0                  dedfej\                  dedfej4                  dedfej6                  dedfej8                  dedfej<                  dedfej>                  dedfej@                  dedfejB                  dedfejD                  dedfg
      d#               Z/e	j                  j                  d$ej0                  dd%fej\                  dd%fej4                  dd&fej6                  dd'fej8                  dd(fej<                  dd)fej>                  dd*fej@                  dd+fejB                  dd,fejD                  dd-fg
      d.        Z0e	j                  j                  d/d0i dfd1d2d3id3fd4i dfd5i dfd6i dfd7i dfd8i dfd9d: ejb                  d;      idfg      d<        Z2d= Z3y>)?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                  |      }||k7  sJ t        j                  j	                  |      sJ t        j                  j                  |      |k(  sJ y )Nz
~/sometest)icom_expand_userosr   isabs
expanduserr   filenameexpanded_names      r   test_expand_userz)TestCommonIOCapabilities.test_expand_user?   sX    ))(3(((ww}}]+++ww!!(+}<<<r   c                     d}t        j                  |      }||k(  sJ t        j                  j	                  |      |k(  sJ y )Nz/somefolder/sometest)r!   r"   r#   r   r%   r&   s      r   test_expand_user_normal_pathz5TestCommonIOCapabilities.test_expand_user_normal_pathG   sB    )))(3(((ww!!(+}<<<r   c                     t        j                  t        d            }|dk(  sJ t        j                  t        d            }|t        j                  j                  dd      k(  sJ y )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   sT    &&tCy13,,T*-=>eU!;;;;r   c                 R    t        d      }t        j                  |      }|dk(  sJ y )Nfoo/bar.csv)r   r!   r0   )r   presults      r   test_stringify_path_fspathz3TestCommonIOCapabilities.test_stringify_path_fspathT   s*    '$$Q'&&&r   c                     t        j                  d      }|j                  d| d      5 }|t        j                  |      k(  sJ 	 d d d        y # 1 sw Y   y xY w)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.[[79+.T[: 	Aj!4!4Z!@@@@	A 	A 	As   AA	path_typec                 `    |\  }} |d|z         }t        j                  |d      }||k(  sJ y )Nr6   infer)compression)r!   infer_compression)r   compression_formatrE   	extensionexpectedr   rH   s          r    test_infer_compression_from_pathz9TestCommonIOCapabilities.test_infer_compression_from_path_   s;    0	823,,TwGh&&&r   c                    t        j                  t        j                               5 } |dt        |      j                  z   dz         }t        j                  |d      5 }t        |j                  j                        j                         sJ t        j                  j                  |      |j                  j                  k(  sJ 	 d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)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   s    ((TYY[9 	KS S	!6!DEH3/ K7GNN//0<<>>>ww))(3w~~7J7JJJJK	K 	KK K	K 	Ks$   8C'!A(C
C'C$	 C''C0c                     t               5 }t        j                  |d      5 }|j                  |k(  sJ 	 d d d        |j                  rJ 	 d d d        j                  sJ y # 1 sw Y   /xY w# 1 sw Y   $xY w)Nr)r   r!   rU   rV   closed)r   input_bufferrY   s      r   test_get_handle_with_bufferz4TestCommonIOCapabilities.test_get_handle_with_buffern   sx    Z 	+<s3 6w~~5556#*****	+ """"6 6	+ 	+s!   A/A#A/#A,	(A//A8c                    d}t        j                  t        |      dd      5 }d}d}	 |j                  j	                  |      }t        |      |k  sJ t        |      |k  r.t        |j                  j	                               dk(  sJ ||z  }n||z  }m||j                  d      k(  sJ 	 d d d        y # 1 sw Y   y xY w)	N&   a,b,c
1,2,3
©,®,®
Look,a snake,🐍rbFis_textr      r   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 	2WFI++I65zY...u:	) w~~2245:::eOF%  T[[1111	2 	2 	2s   B	B77C c                    t        j                  d      }d}t        j                  g dg dg dd      }t	        |      }t        j                  |dd	      5 }|j                  |j                        j                         }t        r|j                  d
      }n5|s3|j                  t        j                  t        j                              }t        j                   ||       |j"                  rJ 	 d d d        y # 1 sw Y   y xY w)Nzpyarrow.csvra   )1   ©Look)2   ®za snake)3rs   u   🐍abcrb   Frc   object)na_value)r?   r@   pd	DataFramer   r!   rU   read_csvrV   	to_pandasr
   astypeStringDtypenpnantmassert_frame_equalr]   )selusing_infer_stringpa_csvrj   rL   srY   dfs           r   test_get_handle_pyarrow_compatz7TestCommonIOCapabilities.test_get_handle_pyarrow_compat   s    $$]3 <<%,BI\]
 TN__Qe4 	 0::<B##??84'#??2>>266+JK!!"h/xx<x	  	  	 s   BC??Dc                 t   t        j                  t        | j                        d      5 }t        j                  |d      }d d d        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        y # 1 sw Y   xY w# 1 sw Y   y xY w)N   )rk   T)ignore_indexr   )	r{   r}   r   data1concatr   r   nextiloc)r   readerr8   rL   itfirsts         r   test_iteratorz&TestCommonIOCapabilities.test_iterator   s    [[$**-; 	:vYYvD9F	:;;x

34
fh/ [[$**-; 	DrHE!!%s);<!!"))B-qr1BC	D 	D	: 	:	D 	Ds   D"3A&D."D+.D7"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                 l   t        j                  |       t        j                  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        y # 1 sw Y   y xY w)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#ww||D&*;f*DE.vh6GHLVHTUV)H26( ;##)(!- 	 OvhVWXNvhVWX 	 >fXF]]tfAdV1TF!D64&$qavQO
 	 4L		 	 	s   	B**B3z#method, module, error_class, fn_exthtmlparquetc                 (   t        j                  |       t        j                  g dg dg dd      }t        j
                  j                  t        ddd|z         }t        j                  |d	      5   |||       d d d        y # 1 sw Y   y xY w)
N)r         )r   r      )r   r   re   ru   rj   missing_folderr   z@Cannot save file into a non-existent directory: .*missing_folderr   )	r?   r@   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   sz     	F#ll#STww||D&*:<MPV<VW]]U
 	& ;%		& 	& 	&s   5
BBc                    t        j                  |       t        j                  j	                  dd|z         }|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      5   ||       d d d        y # 1 sw Y   y xY w)N~r   r"   c                 B    t         j                  j                  d|       S )Nr.   )r#   r   r1   )xs    r   <lambda>zJTestCommonIOCapabilities.test_read_expands_user_home_dir.<locals>.<lambda>  s    BGGLLPQ<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#ww||C!2V!;<D.2RS.vh6GHLVHTUVAH26( ;##)(!- 	 OvhVWXNvhVWX 	 >fXF]]tfAdV1TF!D64&$qavQO
 	 4L		 	 	s   +	B==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        |      } ||      } ||      }|j                  d      rt	        j
                  ||       y t	        j                  ||       y )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  sd    @ 	F#d#$<==#''9!!&(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(  rCt        j                  |
fi |}t        j                  |fi |}t        j                  ||       n'|
j                         }|j                         }||k(  sJ d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)
N)r   jinja2stringfspathAr   r   rb   r   )r?   r@   strr{   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_allI  s1    ,&)X()X()\\3A-(F#f%[)v''v''&$ 
	*5$vt*< 
	*j( u>>==A=A%%fh7!;;=)))
	* 
	* 
	* 
	* 
	* 
	*s%   D3&A0D'D3'D0	,D33D<c                    t        j                  d       t        j                  dddgi      }t	        |dz        }t	        |dz        }t        |      }|j                  |d       |j                  |d       t        j                  |d      }t        j                  |d      }t        j                  ||       y )	Nr   r   r   r   r   r   r/   )key)
r?   r@   r{   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_hdf5o  s     	H%\\3A-(X()X()f%
		&e	$
		&e	$V/;;v5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   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   r   to_datetimer   r   r   r   r   r   r   5   s   E==<'
A [[[3d*CD' E' [[[3d*CDK EK#2. *
D [[%IJ[[-[[$ 159[[$ 159]]F$5v>__i)<[[($5t<]]D"3U;[[$ 1:>\\4!2F;^^T#4h?
	
 K0 [[-\\  $7\\!!4&9\\""FGV<\\$$i)D\\$$i)D\\""D'59\\!!4&9\\##T7H=		
&& [[%IJ[[-[[$ 159]]D"3U;[[$ 159]]F$5v>__i)<[[($5t<]]D"3U;[[$ 1:>\\4!2F;^^T#4h?	
 K 8 [[[[$ AB]]D"CDG
 ]]F$IJB C
 ]]D"LM[[$ GH\\4!LME-	
>4?>4 [[,r4 (J/<2y)D!D!T""d#,7I(JKTR		
**20r   r   c                      | dddd      S )Nr   rj   r   ztest_mmap.csvr   )r   s    r   	mmap_filer    s    D&%99r   c                   .   e Zd Zej                  j                  ed      d        Zej                  j                  ed      d        Zd Z	d Z
ej                  j                  ddd	g      ej                  j                  d
ddg      d               Zy)TestMMapWrapperr   r   c                    t        d      }d |_        t               r	d}t        }nd}t        j
                  }t        j                  ||      5  t        j                  |d       d d d        t        |d      5 }	 d d d        d	}t        j                  t        |      5  t        j                  d       d d d        y # 1 sw Y   ]xY w# 1 sw Y   RxY w# 1 sw Y   y xY w)
NzI am not a filec                       y)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CC**C]]3c* 	3""8T2	3 )g. 	&	 -]]:S1 	1""640	1 	1	3 	3	 		1 	1s$   C<C#CCCC$c                    t        |d      5 }|j                         }t        j                  |ddd      5 }|j                  }t        |j                  j                  t        j                        sJ |D ]0  }t        |      }|j                         |j                         k(  r0J  t        j                  t        d      5  t        |       d d d        d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)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"7CCC! =D $WI$??,

<<<= ]]=> "M""	" 	"" "" "	" 	"sA   *DA.C6'C6C*C6D*C3/C66C?	;DDc                    t        j                  dt        j                  d      j	                  d      z  t        j
                  t        d            t        j
                  t        d      D cg c]  }d| 	 c}            }|j                  |       t        j                  t        d	      5  t        j                  |d
       d d d        y c c}w # 1 sw Y   y xY w)N皙?x      r   ABCDr3  i-columnsindexzUnknown enginer   pyt)r   )r{   r|   r   arangereshapeIndexlistranger   r?   r   r  r}   r   rB   ir   s       r   test_unknown_enginez#TestMMapWrapper.test_unknown_engine  s    \\"))C.((11HHT&\*((eBi8bH89

 			)]]:-=> 	1KK	%0	1 	1 9	1 	1s   /C3CC"c                    t        j                  dt        j                  d      j	                  d      z  t        j
                  t        d            t        j
                  t        d      D cg c]  }d| 	 c}            }|j                  |d	       t        j                  |t        j                  |d
             yc c}w )z\
        'encoding' shouldn't be passed to 'open' in binary mode.

        GH 35058
        r0  r1  r2  r4  r3  r5  r6  zw+br=   r   	index_colN)r{   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HHT&\*((eBi8bH89

 			)%	(
b"++i1"EF 9s   /Cr  zutf-16zutf-32compression_bz2xzc                 6   t        j                  dt        j                  d      j	                  d      z  t        j
                  t        d            t        j
                  t        d      D cg c]  }d| 	 c}            }t        j                  t        d	      5  |j                  |||
       ddd       d}t        j                  t        |	      5  t        j                  |||
       ddd       yc c}w # 1 sw Y   MxY w# 1 sw Y   yxY w)z
        bz2 and xz do not write the byte order mark (BOM) for utf-16/32.

        https://stackoverflow.com/questions/55171439

        GH 35681
        r0  r1  r2  r4  r3  r5  r6  zbyte order markr   )rH   r  NzHUTF-\d+ stream does not start with BOM|'utf-\d+' codec can't decode byte)r{   r|   r   r:  r;  r<  r=  r>  r   assert_produces_warningUnicodeWarningr   r?   r   UnicodeErrorr}   )r   r  rF  rB   r@  r   r  s          r   test_warning_missing_utf_bomz,TestMMapWrapper.test_warning_missing_utf_bom  s     \\"))C.((11HHT&\*((eBi8bH89

 ''>OP 	NIIi\HIM	N
1 	 ]]<s3 	PKK	|hO	P 	P 9	N 	N	P 	Ps   /C>"DDDDN)r   r   r   r?   r  r  r   r!  r.  rA  rE  r  rM  r   r   r   r  r    s    [[%IJ1 K1, [[%IJ" K""1G [[Z(H)=>[[^eT];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 y )
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_urlrQ    s    >???=>>>!!"CDDD!!"CDDD!!-000!!"7888!!"<===!!"LMMMCDDDr   c                  F   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 y )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.csvrO  r   r   r   test_is_fsspec_url_chainedrS    s     ?@@@PQQQPQQQEFFF!!"BCCC!!"DEEE!!"ABBBBr   formatr   r   c                 ^   t        j                  dt        j                  d      j	                  d      z  t        j
                  t        d            t        j
                  t        d      D cg c]  }d| 	 c}            }t        |dd	
      5 } t        |d|        |       d d d        t        |d	      5 }| dk(  rt        j                  |d      }nt        j                  |      }d d d        t        j                  |       y c c}w # 1 sw Y   mxY w# 1 sw Y   1xY w)Nr0  r1  r2  r4  r3  r5  r6  rP   rf   )r>   r  to_r  r   r   rC  )r{   r|   r   r:  r;  r<  r=  r>  rA   r   r}   r
  r   r   )rT  rB   r@  rL   rV   r   s         r   test_codecs_encodingrW     s     ||biin$$W--f&hh%)4Q"QC45H
 
icG	4 2)Cx.)&12	i'	* &fU?Vq1Bf%B	&
 (B' 52 2& &s   /DD 3D#D #D,c                    t        j                  dt        j                  d      j	                  d      z  t        j
                  t        d            t        j
                  t        d      D cg c]  }d| 	 c}            }t        | d      5 } t        j                  d	      |      5 }|j                  |       d d d        d d d        t        | d
      5 } t        j                  d	      |      5 }t        j                  |d      }d d d        d d d        t        j                  |       y c c}w # 1 sw Y   }xY w# 1 sw Y   xY w# 1 sw Y   ExY w# 1 sw Y   IxY w)Nr0  r1  r2  r4  r3  r5  r6  r<   rf   rb   r   rC  )r{   r|   r   r:  r;  r<  r=  r>  rA   codecs	getwriterr   	getreaderr}   r   r   )rB   r@  rL   rV   encodedr   s         r   test_codecs_get_writer_readerr]    s-   ||biin$$W--f&hh%)4Q"QC45H
 
i	 %&&Vg&v. 	%'OOG$	%% 
i	 3&&Vg&v. 	3'W2B	33 (B' 5	% 	%% %	3 	33 3sN   /D8E	/D=E	E!9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      j	                  d      z  t        j
                  t        d            t        j
                  t        d      D cg c]  }d| 	 c}            } |        5 }t        j                  t        |      5  |j                  |d	| 
       d d d        d d d        y c c}w # 1 sw Y   xY w# 1 sw Y   y xY w)Nr0  r1  r2  r4  r3  r5  r6  r   rP   r=   )r{   r|   r   r:  r;  r<  r=  r>  r?   r   	TypeErrorr   )io_classr>   r  r@  rL   r&  s         r   test_explicit_encodingrb  "  s     ||biin$$W--f&hh%)4Q"QC45H
 
 5v]]9C0 	5OOF1TFO4	55 5 5	5 	55 5s*   /CC#*CC#C 	C##C,encoding_errorsstrict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      }|}|j	                  |       | dk7  r/t        j                  t        |      5   |||        d d d        y  |||       }|j                  |       }	t        j                  |	|	gi|	dz  g      }
t        j                  ||
       y # 1 sw Y   y xY w)Nz'utf-8' codec can't decode byte   r      ,   
r   r   rC  s   {"s   ": {"s   ":"s   "}}r8  )orientre  r   rc  errors)r8  )r   r{   r}   r
  write_bytesr?   r   UnicodeDecodeErrordecoder|   r   r   )rc  rT  rB   r  bad_encodingcontentr   filer   decodedrL   s              r   test_encoding_errorsru  7  s=    ,CL%-q0@@4G,V2 Q  	
   	 g6DW)#]]-S9 	?9o>	? 	? I?%%_%=<<7) 4Wq[MJ
b(+	? 	?s   DDc                     t        d      }t        t        j                  |       }d}|t	        |       j
                   z  }t        j                  t        |      5   ||       d d d        y # 1 sw Y   y xY w)NzA,B
1,2
3,4
rk  z&encoding_errors must be a string, got r   )	r   r   r{   r}   typer   r?   r   r  )rc  rr  r   expected_errors       r   test_encoding_errors_badtypery  Y  sf     ()GR[[/BF=No.7789N	z	8 w  s   	A//A8c                     t        j                  t        d      5  t        j                  | dd       d d d        y # 1 sw Y   y xY w)Nzunknown error handler namer   rP   badrl  )r?   r   LookupErrorr!   rU   )rB   s    r   test_bad_encdoing_errorsr}  d  s6    	{*F	G 6	3u56 6 6s	   >Ar   r   c                      t        j                  t        d      5 } t        j                  d       | j
                  t
        j                  k(  sJ 	 d d d        y # 1 sw Y   y xY w)Nz\[Errno 2\]r   doesnt_exist)r?   r   r  r{   r}   errnoENOENT)r  s    r   test_errno_attributer  j  sL     
(	@ )C
N#yyELL((() ) )s   5AA$c                      t        j                  t        d      5  t               5 } t	        j
                  | dd       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr  r   rb   T)r#  )r?   r   r   r   r!   rU   )r&  s    r   test_fail_mmapr  r  sW    	+8	< ;Y 	;&OOFDT:	;; ;	; 	;; ;s"   AA AA	AA&c                  L    G d d      } t        j                  t        d      5  t               5 }t	        j
                  |d      5 }|j                  j                   |               d d d        d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nc                       e Zd Zd Zy)&test_close_on_error.<locals>.TestErrorc                     t        d      )Ntest)r  r   s    r   closez,test_close_on_error.<locals>.TestError.close{  s    &/!r   N)r   r   r   r  r   r   r   	TestErrorr  z  s    	"r   r  r  r   rb   )r?   r   r  r   r!   rU   created_handlesappend)r  r&  rY   s      r   test_close_on_errorr  x  s    " " 
wf	- <Y 	<&. <'''..y{;<	<< << <	< 	<< <s:   BB!B)B1BBBB	BB#r;   rH   rG   c                      | dddd      }d| }t        j                  ||d      }t        j                  dd	idd
id      }t        j                  ||       y )Nr   rj   tarztest-csv.tarztar://test.csv::file://;)rH   sepr   r   r   )ro   rr   )r{   r}   r|   r   r   )r   rH   tar_file_pathchained_file_urlr8   rL   s         r   "test_read_csv_chained_url_no_errorr    s_     T65.AM0@[[){LF||1a&1v67H(F+r   r   c                 n    t               5 }t        j                  | |       d d d        y # 1 sw Y   y xY wr   )r   r   dump)r   r&  s     r   test_pickle_readerr    s.      
 $fFF#$ $ $s   +4r   c                      d} t        j                  t        |       dgdd      }t        j                  dt         j                  dgd      }t        j
                  d|i      }t        j                  ||       y )	Nz#"date"
"20/12/2025"
""
"31/12/2020"dateTr   )parse_datesdayfirstdtype_backendz
20/12/2025z
31/12/2020)r  )r{   r}   r   r  NaTr|   r   r   )rj   r8   expect_dataexpects       r   $test_pyarrow_read_csv_datetime_dtyper    sg     4D[[VHt9F ..,!EPTUK\\6;/0F&&)r   )Jr   rY  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pandasr{   pandas._testing_testingr   pandas.io.commoncommonr!   r  filterwarnings
pytestmarkr   r   abspathdirname__file__r   r   fixturer  r  rQ  rS  r  rW  r]  rb  ru  ry  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 ) )    [[''C

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