
    4imb                     D   S r SSKrSSKrSSKJr  SSKJrJrJr  SSK	r	SSK
r
SSKJr  SSKrSSKrSSKrSSKrSSKJrJr  SSKJr  SSKJs  Jr  SSKrSSKJr  SSK Js  J!r"  \RF                  RI                  S5      r% " S	 S
5      r&\
RN                  RQ                  \
RN                  RS                  \*5      5      r+ " S S5      r,\RZ                  S 5       r. " S S5      r/S r0S r1\RF                  Re                  SSS/5      S 5       r3S r4\RF                  Re                  S\SS4\SS4/5      S 5       r5\RF                  Re                  SSS/5      \RF                  Re                  SSS/5      S  5       5       r6\RF                  Re                  SSS/5      S! 5       r7S" r8\RF                  Rs                  \S#S$9S% 5       r:S& r;S' r<\Rz                  " S(5      \RF                  Re                  S)SS*/5      S+ 5       5       r>\RF                  Re                  S,\R~                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  \R                  /	5      S- 5       rH\Rz                  " S.5      S/ 5       rIg)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                   (    \ rS rSrSrSS jrS rSrg)CustomFSPath'   z%For testing fspath on unknown objectsNc                     Xl         g Npath)selfr   s     ]/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/pandas/tests/io/test_common.py__init__CustomFSPath.__init__*   s    	    c                     U R                   $ r   r   r   s    r   
__fspath__CustomFSPath.__fspath__-   s    yyr   r   )returnN)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r   r   '   s    /r   r   c                      \ rS rSrSrS rS rS rS rS r	\
R                  R                  S\\\/5      S	 5       r\
R                  R                  S\\\/5      S
 5       rS rS rS rS r\
R                  R-                  \SS9\
R                  R                  S\R2                  S\S4\R6                  S\S4\R8                  S\S4\R:                  S\S4\R>                  S\S4\R@                  S\S4\RB                  S\S4\RD                  S\S4\RF                  S\S4/	5      S 5       5       r$\
R                  R                  S \RJ                  RL                  S\S4\RJ                  RN                  S\S!4\RJ                  RP                  S\S4\RJ                  RR                  S\S4\RJ                  RT                  S\S"4\RJ                  RV                  S\S4\RJ                  RX                  S\S4\RJ                  RZ                  S\S4/5      S# 5       r.\
R                  R-                  \SS9\
R                  R                  S\R2                  S\S4\R^                  S\S4\R6                  S\S4\R8                  S\S4\R:                  S\S4\R>                  S\S4\R@                  S\S4\RB                  S\S4\RD                  S\S4\RF                  S\S4/
5      S$ 5       5       r0\
R                  R                  S%\R2                  SS&4\R^                  SS&4\R6                  SS'4\R8                  SS(4\R:                  SS)4\R>                  SS*4\R@                  SS+4\RB                  SS,4\RD                  SS-4\RF                  SS.4/
5      S/ 5       r1\
R                  R                  S0S10 S4S2S3S40S44S50 S4S60 S4S70 S4S80 S4S90 S4S:S;\Rd                  " S<5      0S4/5      S= 5       r3S> r4S?r5g@)ATestCommonIOCapabilities5   ziindex,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                     Sn[         R                  " U5      nX!:w  d   e[        R                  R	                  U5      (       d   e[        R                  R                  U5      U:X  d   eg )Nz
~/sometest)icom_expand_userosr   isabs
expanduserr   filenameexpanded_names      r   test_expand_user)TestCommonIOCapabilities.test_expand_user?   sY    ))(3(((ww}}]++++ww!!(+}<<<r   c                     Sn[         R                  " U5      nX!:X  d   e[        R                  R	                  U5      U:X  d   eg )Nz/somefolder/sometest)r'   r(   r)   r   r+   r,   s      r   test_expand_user_normal_path5TestCommonIOCapabilities.test_expand_user_normal_pathG   s@    )))(3(((ww!!(+}<<<r   c                     [         R                  " [        S5      5      nUS:X  d   e[         R                  " [        S5      5      nU[        R                  R                  SS5      :X  d   eg )N.zfoo//barfoobar)r'   stringify_pathr   r)   r   join)r   rel_pathredundant_paths      r   test_stringify_path_pathlib4TestCommonIOCapabilities.test_stringify_path_pathlibN   sT    &&tCy13,,T*-=>eU!;;;;r   c                 V    [        S5      n[        R                  " U5      nUS:X  d   eg )Nfoo/bar.csv)r   r'   r8   )r   presults      r   test_stringify_path_fspath3TestCommonIOCapabilities.test_stringify_path_fspathT   s*    '$$Q'&&&r   c                     [         R                  " S5      nUR                  SU 3SS9 nU[        R                  " U5      :X  d   e S S S 5        g ! , (       d  f       g = f)Nfsspeczfile://wbmode)pytestimportorskipopenr'   r8   )r   	temp_filerE   
fsspec_objs       r   !test_stringify_file_and_path_like:TestCommonIOCapabilities.test_stringify_file_and_path_likeY   sP    $$X.[[79+.T[:j!4!4Z!@@@@ ;::s   A
A	path_typec                 Z    Uu  p4U" SU-   5      n[         R                  " USS9nXd:X  d   eg )Nr?   infer)compression)r'   infer_compression)r   compression_formatrP   	extensionexpectedr   rS   s          r    test_infer_compression_from_path9TestCommonIOCapabilities.test_infer_compression_from_path_   s7    0	23,,TwG&&&r   c                    [         R                  " [        R                  " 5       S9 nU" S[        U5      R                  -   S-   5      n[
        R                  " US5       n[        UR                  R                  5      R                  5       (       d   e[        R                  R                  U5      UR                  R                  :X  d   e S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)N)dirz~/z	/sometestw)tempfileTemporaryDirectoryr   homenamer'   
get_handlehandleis_absoluter)   r   r+   )r   rP   tmpr-   handless        r   test_get_handle_with_path2TestCommonIOCapabilities.test_get_handle_with_pathf   s    ((TYY[9S S	!6!DEH3/7GNN//0<<>>>>ww))(3w~~7J7JJJJ 0 :9// :9s$   9C2!A.C!C2!
C/	+C22
D c                 "   [        5        n[        R                  " US5       nUR                  U:X  d   e S S S 5        UR                  (       a   e S S S 5        WR                  (       d   eg ! , (       d  f       N>= f! , (       d  f       N3= f)Nr)r   r'   ra   rb   closed)r   input_bufferre   s      r   test_get_handle_with_buffer4TestCommonIOCapabilities.test_get_handle_with_buffern   si    Z<s3w~~555 4#*****  """" 43 Zs!   B A/B /
A=	9B  
Bc                    Sn[         R                  " [        U5      SSS9 nSnSn UR                  R	                  U5      n[        U5      U::  d   e[        U5      U:  a.  [        UR                  R	                  5       5      S:X  d   eX5-  nOX5-  nMo  X1R                  S5      :X  d   e S S S 5        g ! , (       d  f       g = f)	N&   a,b,c
1,2,3
©,®,®
Look,a snake,🐍rbFis_textr      r   utf-8)r'   ra   r   rb   readlenencode)r   datare   rA   	chunksizechunks         r   )test_bytesiowrapper_returns_correct_bytesBTestCommonIOCapabilities.test_bytesiowrapper_returns_correct_bytesv   s     __Xd^T5AWFI++I65zY...u:	) w~~2245:::OF  [[1111 BAAs   BB77
Cc                 :   [         R                  " S5      nSn[        R                  " / SQ/ SQ/ SQS.5      n[	        U5      n[
        R                  " USSS	9 nUR                  UR                  5      R                  5       n[        (       a  UR                  S
5      nO8U(       d1  UR                  [        R                  " [        R                  S95      n[        R                   " Xt5        UR"                  (       a   e S S S 5        g ! , (       d  f       g = f)Nzpyarrow.csvro   )1   ©Look)2   ®za snake)3r   u   🐍abcrp   Frq   object)na_value)rI   rJ   pd	DataFramer   r'   ra   read_csvrb   	to_pandasr
   astypeStringDtypenpnantmassert_frame_equalrj   )selusing_infer_stringpa_csvrx   rW   sre   dfs           r   test_get_handle_pyarrow_compat7TestCommonIOCapabilities.test_get_handle_pyarrow_compat   s    $$]3 <<%,BI\]
 TN__Qe40::<B###??84'#??2>>266+JK!!"/xx<x 544s   B(D
Dc                    [         R                  " [        U R                  5      SS9 n[         R                  " USS9nS S S 5        [         R                  " [        U R                  5      5      n[
        R                  " WU5        [         R                  " [        U R                  5      SS9 n[        U5      n[
        R                  " XSR                  S/   5        [
        R                  " [         R                  " U5      UR                  SS  5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)N   )ry   T)ignore_indexr   )	r   r   r   data1concatr   r   nextiloc)r   readerrA   rW   itfirsts         r   test_iterator&TestCommonIOCapabilities.test_iterator   s    [[$**-;vYYvD9F <;;x

34
fh/ [[$**-;rHE!!%s);<!!"))B-qr1BC <; <; <;s   D /A(D1 
D.1
D?"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                 t   [         R                  " U5        [        R                  R	                  [
        SSU-   5      nSU S3nSU S3nSnSn	S	U S
U S3n
SU S3nSU S3nSU 3n[         R                  " USU SU SU SU	 SU
 SU SU SU S3S9   U" U5        S S S 5        g ! , (       d  f       g = f)Nrx   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)rI   rJ   r)   r   r9   HEREraises)r   r   moduleerror_classfn_extr   msg1msg2msg3msg4msg5msg6msg7msg8s                 r   test_read_non_existent/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))
B7z#method, module, error_class, fn_exthtmlparquetc                 0   [         R                  " U5        [        R                  " / SQ/ SQ/ SQS.5      n[        R
                  R                  [        SSSU-   5      n[         R                  " USS	9   U" XV5        S S S 5        g ! , (       d  f       g = f)
N)r         )r   r      )r   r   rs   r   rx   missing_folderr   z@Cannot save file into a non-existent directory: .*missing_folderr   )	rI   rJ   r   r   r)   r   r9   r   r   )r   methodr   r   r   dummy_framer   s          r   #test_write_missing_parent_directory<TestCommonIOCapabilities.test_write_missing_parent_directory   ss     	F#ll#STww||D&*:<MPV<VW]]U
 ;%	
 
 
s   5	B
Bc                    [         R                  " U5        [        R                  R	                  SSU-   5      nUR                  [        SS 5        SU S3nSU S3nS	n	S
n
SU SU S3nSU S3nSU S3nSU 3n[         R                  " USU SU SU	 SU
 SU SU SU SU S3S9   U" U5        S S S 5        g ! , (       d  f       g = f)N~r   r(   c                 B    [         R                  R                  SU 5      $ )Nr6   )r)   r   r9   )xs    r   <lambda>JTestCommonIOCapabilities.test_read_expands_user_home_dir.<locals>.<lambda>  s    BGGLLPQ<Rr   r   r   r   r   z0Unexpected character found when decoding 'false'r   r   r   r   r   r   r   r   r   r   )rI   rJ   r)   r   r9   setattrr'   r   )r   r   r   r   r   monkeypatchr   r   r   r   r   r   r   r   r   s                  r   test_read_expands_user_home_dir8TestCommonIOCapabilities.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)iorx   r   ziris.csv)r   rx   fixed_widthzfixed_width_format.txt)r   rx   excelz
test1.xlsx)r   rx   r   zfeather-0_3_1.feather)r   rx   
legacy_hdfzpytables_native2.h5)r   rx   statazstata10_115.dta)r   sasrx   ztest1.sas7bdat)r   r   rx   ztsframe_v012.json)r   rx   r   zcategorical.0.25.0.picklec                     [         R                  " U5        U" U6 n[        U5      nU" U5      nU" U5      nUR                  S5      (       a  [        R
                  " Xg5        g [        R                  " Xg5        g )Nz.pickle)rI   rJ   r   endswithr   assert_categorical_equalr   )r   r   r   r   datapathmypathrA   rW   s           r   test_read_fspath_all-TestCommonIOCapabilities.test_read_fspath_all  sc    @ 	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                    US;   a  [         R                  " S5        [        US-  5      n[        US-  5      n[        R                  " SSS/05      n[         R                  " U5        [        U5      n[        Xq5      n	U	" U40 UD6  U	" U40 UD6  [        US5       n
[        US5       nUS	:X  aE  [        R                  " U
40 UD6n[        R                  " U40 UD6n[        R                  " X5        O'U
R                  5       nUR                  5       nX:X  d   eS S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)
N)r   jinja2stringfspathAr   r   rp   r   )rI   rJ   strr   r   r   getattrrK   
read_excelr   r   ru   )r   writer_namewriter_kwargsr   tmp_pathr  r  r   r   writerf_strf_pathrA   rW   s                 r   test_write_fspath_all.TestCommonIOCapabilities.test_write_fspath_allI  s    ,&)X()X()\\3A-(F#f%)v''v''&$5$vt*<j( u>>==A=A%%f7!;;=))) +=*<*<s%   D?*A3D.D?.
D<	8D??
Ec                 r   [         R                  " S5        [        R                  " SSS/05      n[	        US-  5      n[	        US-  5      n[        U5      nUR                  USS9  UR                  USS9  [        R                  " USS9n[        R                  " USS9n[        R                  " Xg5        g )	Nr   r  r   r   r  r  r7   )key)
rI   rJ   r   r   r  r   to_hdfread_hdfr   r   )r   r  r   r  r  r   rA   rW   s           r   test_write_fspath_hdf5/TestCommonIOCapabilities.test_write_fspath_hdf5o  s     	H%\\3A-(X()X()f%
		&e	$
		&e	$V/;;v51
f/r   r"   N)6r   r   r   r   r   r/   r2   r<   rB   rN   rI   markparametrizer  r   r   rX   rf   rl   r{   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$   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                     U " SSSS5      $ )Nr   rx   r   ztest_mmap.csvr"   )r   s    r   	mmap_filer(    s    D&%99r   c                   *   \ rS rSr\R
                  R                  \SS9S 5       r\R
                  R                  \SS9S 5       r	S r
S r\R
                  R                  SS	S
/5      \R
                  R                  SSS/5      S 5       5       rSrg)TestMMapWrapperi  r   r   c                    [        S5      nS Ul        [        5       (       a	  Sn[        nOSn[        R
                  n[        R                  " XCS9   [        R                  " US5        S S S 5        [        USS9 n S S S 5        S	n[        R                  " [        US9   [        R                  " WS5        S S S 5        g ! , (       d  f       N^= f! , (       d  f       N[= f! , (       d  f       g = f)
NzI am not a filec                      g)Nr"   r"   r   r   r   ;TestMMapWrapper.test_constructor_bad_file.<locals>.<lambda>  s    "r   zThe parameter is incorrectz
[Errno 22]r   Trt   encodingzI/O operation on closed file)r   filenor	   r  mmaperrorrI   r   r'   _maybe_memory_maprK   
ValueError)r   r(  non_filemsgerrtargets         r   test_constructor_bad_file)TestMMapWrapper.test_constructor_bad_file  s    -.$   .CCC**C]]3*""8T2 + )g.& / -]]:S1""640 21 +* /. 21s$   C<C!C$
C
C!$
C2c                 <   [        USS9 nUR                  5       n[        R                  " USSSS9 nUR                  n[        UR                  R                  [        R                  5      (       d   eU H2  n[        U5      nUR                  5       UR                  5       :X  a  M2   e   [        R                  " [        SS9   [        U5        S S S 5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       N(= f! , (       d  f       g = f)Nrt   r/  ri   T)rr   
memory_mapz^$r   )rK   	readlinesr'   ra   rb   
isinstancebufferr2  r   striprI   r   StopIteration)r   r(  r9  lineswrapperswrapperline	next_lines           r   	test_nextTestMMapWrapper.test_next  s    )g.&$$&ETd"//!'.."7"7CCCC!D $WI$??,

<<< " ]]=>M ? /. ?>  /.sA   (DA2C<)C<C+C<D+
C95C<<
D
	D
Dc                    [         R                  " S[        R                  " S5      R	                  S5      -  [         R
                  " [        S5      5      [         R
                  " [        S5       Vs/ s H  nSU 3PM
     sn5      S9nUR                  U5        [        R                  " [        SS	9   [         R                  " US
S9  S S S 5        g s  snf ! , (       d  f       g = f)N皙?x      r   ABCDrN  i-columnsindexzUnknown enginer   pyt)r   )r   r   r   arangereshapeIndexlistranger   rI   r   r5  r   r   rL   ir   s       r   test_unknown_engine#TestMMapWrapper.test_unknown_engine  s    \\"))C.((11HHT&\*((eBi8ibHi89

 			)]]:-=>KK	%0 ?> 9 ?>s   3C5C
C'c                    [         R                  " S[        R                  " S5      R	                  S5      -  [         R
                  " [        S5      5      [         R
                  " [        S5       Vs/ s H  nSU 3PM
     sn5      S9nUR                  USS	9  [        R                  " U[         R                  " US
S95        gs  snf )zD
'encoding' shouldn't be passed to 'open' in binary mode.

GH 35058
rK  rL  rM  rO  rN  rP  rQ  zw+brG   r   	index_colN)r   r   r   rU  rV  rW  rX  rY  r   r   r   r   rZ  s       r   test_binary_mode TestMMapWrapper.test_binary_mode  s     \\"))C.((11HHT&\*((eBi8ibHi89

 			)%	(
b"++i1"EF 9s   3Cr0  zutf-16zutf-32compression_bz2xzc                 <   [         R                  " S[        R                  " S5      R	                  S5      -  [         R
                  " [        S5      5      [         R
                  " [        S5       Vs/ s H  nSU 3PM
     sn5      S9n[        R                  " [        SS	9   UR                  X2US
9  SSS5        Sn[        R                  " [        US	9   [         R                  " X2US
9  SSS5        gs  snf ! , (       d  f       NM= f! , (       d  f       g= f)zz
bz2 and xz do not write the byte order mark (BOM) for utf-16/32.

https://stackoverflow.com/questions/55171439

GH 35681
rK  rL  rM  rO  rN  rP  rQ  zbyte order markr   )rS   r0  NzHUTF-\d+ stream does not start with BOM|'utf-\d+' codec can't decode byte)r   r   r   rU  rV  rW  rX  rY  r   assert_produces_warningUnicodeWarningr   rI   r   UnicodeErrorr   )r   r0  rc  rL   r[  r   r7  s          r   test_warning_missing_utf_bom,TestMMapWrapper.test_warning_missing_utf_bom  s     \\"))C.((11HHT&\*((eBi8ibHi89

 ''>OPIIiHIM Q
1 	 ]]<s3KK	hO 43 9PP 43s   3C7$C<D<
D

Dr"   N)r   r   r   r   rI   r  r  r   r:  rH  r\  ra  r  rj  r!   r"   r   r   r*  r*    s    [[%IJ1 K1, [[%IJ" K""1G [[Z(H)=>[[^eT];P < ?Pr   r*  c                     [         R                  " S5      (       d   e[         R                  " S5      (       d   e[         R                  " S5      (       a   e[         R                  " S5      (       a   e[         R                  " S5      (       a   e[         R                  " S5      (       a   e[         R                  " S5      (       a   e[         R                  " S5      (       a   e[         R                  " S	5      (       d   eg )
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_urlro    s    >????=>>>>!!"CDDDD!!"CDDDD!!-0000!!"78888!!"<====!!"LMMMMCDDDDr   c                     [         R                  " S5      (       d   e[         R                  " S5      (       d   e[         R                  " S5      (       d   e[         R                  " S5      (       d   e[         R                  " S5      (       a   e[         R                  " S5      (       a   e[         R                  " S5      (       a   eg )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.csvrm  r"   r   r   test_is_fsspec_url_chainedrq    s     ?@@@@PQQQQPQQQQEFFFF!!"BCCCC!!"DEEEE!!"ABBBBBr   formatr   r   c                 p   [         R                  " S[        R                  " S5      R	                  S5      -  [         R
                  " [        S5      5      [         R
                  " [        S5       Vs/ s H  nSU 3PM
     sn5      S9n[        USS	S
9 n[        USU  35      " U5        S S S 5        [        US	S9 nU S:X  a  [         R                  " USS9nO[         R                  " U5      nS S S 5        [        R                  " UW5        g s  snf ! , (       d  f       Np= f! , (       d  f       N<= f)NrK  rL  rM  rO  rN  rP  rQ  r\   rt   )rH   r0  to_r/  r   r   r_  )r   r   r   rU  rV  rW  rX  rY  rK   r	  r   r"  r   r   )rr  rL   r[  rW   rb   r   s         r   test_codecs_encodingru     s     ||biin$$W--f&hh%)4)Q"QC)45H
 
icG	4Cx.)&1 
5	i'	*fU?Vq1Bf%B	 
+
 (B' 5	4	4	*	*s   3DD>3D'
D$'
D5c                    [         R                  " S[        R                  " S5      R	                  S5      -  [         R
                  " [        S5      5      [         R
                  " [        S5       Vs/ s H  nSU 3PM
     sn5      S9n[        U S5       n[        R                  " S	5      " U5       nUR                  U5        S S S 5        S S S 5        [        U S
5       n[        R                  " S	5      " U5       n[         R                  " USS9nS S S 5        S S S 5        [        R                  " UW5        g s  snf ! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       NU= f! , (       d  f       N^= f)NrK  rL  rM  rO  rN  rP  rQ  rF   rt   rp   r   r_  )r   r   r   rU  rV  rW  rX  rY  rK   codecs	getwriterr   	getreaderr   r   r   )rL   r[  rW   rb   encodedr   s         r   test_codecs_get_writer_readerr{    s   ||biin$$W--f&hh%)4)Q"QC)45H
 
i	&g&v.'OOG$ / 
 
i	&g&v.'W2B / 
 (B' 5 /. 
	 /. 
	sN   3D=E4EE"E5?E$E5
E	E
E!$
E2	.E55
Fzio_class,mode,msgtz*a bytes-like object is required, not 'str'r   z%string argument expected, got 'bytes'c                    [         R                  " S[        R                  " S5      R	                  S5      -  [         R
                  " [        S5      5      [         R
                  " [        S5       Vs/ s H  nSU 3PM
     sn5      S9nU " 5        n[        R                  " [        US9   UR                  US	U 3S
9  S S S 5        S S S 5        g s  snf ! , (       d  f       N= f! , (       d  f       g = f)NrK  rL  rM  rO  rN  rP  rQ  r   r\   rG   )r   r   r   rU  rV  rW  rX  rY  rI   r   	TypeErrorr   )io_classrH   r7  r[  rW   r@  s         r   test_explicit_encodingr  "  s     ||biin$$W--f&hh%)4)Q"QC)45H
 
v]]9C0OOF1TFO4 1 
 5 10 
s*   3CC',C C'
C$	 C''
C5encoding_errorsstrictreplacec                    SnSnUS:X  a-  SU-   S-   US-  -   S-   U-   n[        [        R                  SS9nO/S	US-  -   S
-   U-   S-   U-   S-   n[        [        R                  SS9nUnUR	                  U5        U S:w  a)  [
        R                  " [        US9   U" X S9  S S S 5        g U" X S9nUR                  U S9n	[        R                  " X/0U	S-  /S9n
[        R                  " X5        g ! , (       d  f       g = f)Nz'utf-8' codec can't decode byte   r      ,   
r   r   r_  s   {"s   ": {"s   ":"s   "}}rS  )orientr  r   r  errors)rS  )r   r   r   r"  write_bytesrI   r   UnicodeDecodeErrordecoder   r   r   )r  rr  rL   r7  bad_encodingcontentr   filer   decodedrW   s              r   test_encoding_errorsr  7  s,    ,CL%-q0@@4G,V2 Q  	
   	 g6DW)#]]-S99> :9 I?%%_%=<<) 4Wq[MJ
b+ :9s   C00
C>c                     [        S5      n[        [        R                  U S9nSnU[	        U 5      R
                   -  n[        R                  " [        US9   U" U5        S S S 5        g ! , (       d  f       g = f)NzA,B
1,2
3,4
r  z&encoding_errors must be a string, got r   )	r   r   r   r   typer   rI   r   r5  )r  r  r   expected_errors       r   test_encoding_errors_badtyper  Y  s]     ()GR[[/BF=No.7789N	z	8w 
9	8	8s   	A**
A8c                     [         R                  " [        SS9   [        R                  " U SSS9  S S S 5        g ! , (       d  f       g = f)Nzunknown error handler namer   r\   badr  )rI   r   LookupErrorr'   ra   )rL   s    r   test_bad_encdoing_errorsr  d  s.    	{*F	G	3u5 
H	G	Gs	   :
Ar   r   c                      [         R                  " [        SS9 n [        R                  " S5        U R
                  [
        R                  :X  d   e S S S 5        g ! , (       d  f       g = f)Nz\[Errno 2\]r   doesnt_exist)rI   r   r  r   r   errnoENOENT)r8  s    r   test_errno_attributer  j  sD     
(	@C
N#yyELL((( 
A	@	@s   7A
A)c                      [         R                  " [        SS9   [        5        n [        R
                  " U SSS9  S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       g = f)Nr1  r   rp   T)r=  )rI   r   r   r   r'   ra   )r@  s    r   test_fail_mmapr  r  sD    	+8	<Y&OOFDT:  
=	<Y 
=	<s!   AAA
A	A
A,c                  h    " S S5      n [         R                  " [        SS9   [        5        n[        R
                  " US5       nUR                  R                  U " 5       5        S S S 5        S S S 5        S S S 5        g ! , (       d  f       N= f! , (       d  f       N(= f! , (       d  f       g = f)Nc                       \ rS rSrS rSrg)&test_close_on_error.<locals>.TestErroriz  c                     [        S5      e)Ntest)r  r   s    r   close,test_close_on_error.<locals>.TestError.close{  s    &/!r   r"   N)r   r   r   r   r  r!   r"   r   r   	TestErrorr  z  s    	"r   r  r  r   rp   )rI   r   r  r   r'   ra   created_handlesappend)r  r@  re   s      r   test_close_on_errorr  x  ss    " " 
wf	-Y&.'''..y{; /  
.	-.. Y 
.	-s:   B#B!B(B0B#
BB
B 	B##
B1rE   rS   rR   c                     U " SSSS5      nSU 3n[         R                  " X1SS9n[         R                  " SS	0SS
0S.5      n[        R                  " XT5        g )Nr   rx   tarztest-csv.tarztar://test.csv::file://;)rS   sepr   r   r   )r~   r   )r   r   r   r   r   )r   rS   tar_file_pathchained_file_urlrA   rW   s         r   "test_read_csv_chained_url_no_errorr    s[     T65.AM0@[[)LF||1a&1v67H(+r   r   c                 x    [        5        n[        R                  " X5        S S S 5        g ! , (       d  f       g = fr   )r   r   dump)r   r@  s     r   test_pickle_readerr    s!      
fF# 
s   +
9r   c                      Sn [         R                  " [        U 5      S/SSS9n[         R                  " S[         R                  S/SS9n[         R
                  " SU05      n[        R                  " X15        g )	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   )rx   rA   expect_dataexpects       r   $test_pyarrow_read_csv_datetime_dtyper    se     4D[[VHt9F ..,!EPTUK\\6;/0F&)r   )Jr    rw  r  	functoolsr   r   r   r   r   r2  r)   pathlibr   r   r]   numpyr   rI   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*  ro  rq  r  ru  r{  r  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 ) )    [[''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   