
    Owg\                        d Z ddlZddlZddlmZ ddlmZmZmZ ddl	Z	ddl
Z
ddlmZ ddlZddlZddlZddlZddlmZ ddlmc mZ ddlZddlmZ ddlmc mZ ej@                  jC                  d      Z" G d d	      Z#e$e#egZ%	 dd
l&m'Z( e%jS                  e(       e
jV                  jY                  e
jV                  j[                  e.            Z/ G d d      Z0ejb                  d        Z2 G d d      Z3d Z4ej@                  jk                  dddg      ej@                  jk                  dddg      d               Z6d Z7ej@                  jk                  deddfeddfg      d        Z8ej@                  jk                  dg d      ej@                  jk                  dddg      d                Z9d! Z:d" Z;d# Z<d$ Z=ej@                  jk                  d%ej|                  ej~                  ej                  ej                  ej                  ej                  ej                  ej                  ej                  g	      d&        ZGy# e*$ r Y w xY w)'z0
Tests for the pandas.io.common functionalities
    N)partial)BytesIOStringIOUnsupportedOperation)Path)is_platform_windowsz=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     R/var/www/horilla/myenv/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
   )localc                      e Zd ZdZd Zd Zd Z ej                  d      d        Z	d Z
d Zej                  j                  d	e      d
        Zej                  j                  d	eeeg      d        Zd Zd Zd Zd Zej                  j                  dej4                  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ejF                  dedfejH                  dedfg	      d        Z%ej                  j                  dejL                  jN                  dedfejL                  jP                  ded fejL                  jR                  dedfejL                  jT                  dedfejL                  jV                  ded!fejL                  jX                  dedfejL                  jZ                  dedfejL                  j\                  dedfg      d"        Z/ej                  j                  dej4                  dedfej`                  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ejF                  dedfejH                  dedfg
      d#        Z1ej                  j                  d$ej4                  dd%fej`                  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ejF                  dd,fejH                  dd-fg
      d.        Z2e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jf                  d;      idfg      d<        Z4d= Z5y>)?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_userD   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_pathL   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_pathlibS   sT    &&tCy13,,T*-=>eU!;;;;r   zpy.pathc                     t         j                  j                  dd      }t         j                  j                  |      }t	        |      }t        j                  |      |k(  sJ y )Nr-   r.   )r"   r   r0   abspath	LocalPathr    r/   )r   r   abs_pathlpaths       r   test_stringify_path_localpathz6TestCommonIOCapabilities.test_stringify_path_localpathY   sJ    ww||E5)77??4($""5)X555r   c                 R    t        d      }t        j                  |      }|dk(  sJ y )Nfoo/bar.csv)r
   r    r/   )r   presults      r   test_stringify_path_fspathz3TestCommonIOCapabilities.test_stringify_path_fspath`   s*    '$$Q'&&&r   c                    t        j                  d      }t        j                         5 }|j	                  d| d      5 }|t        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fsspeczfile://wbmode)pytestimportorskiptmensure_cleanopenr    r/   )r   r@   r   
fsspec_objs       r   !test_stringify_file_and_path_likez:TestCommonIOCapabilities.test_stringify_file_and_path_likee   s    $$X.__ 	E$wtf-D9 EZ!T%8%8%DDDDE	E 	EE E	E 	Es#   A:A.A:.A7	3A::B	path_typec                 `    |\  }} |d|z         }t        j                  |d      }||k(  sJ y )Nr;   infer)compression)r    infer_compression)r   compression_formatrK   	extensionexpectedr   rN   s          r    test_infer_compression_from_pathz9TestCommonIOCapabilities.test_infer_compression_from_pathl   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   rK   tmpr&   handless        r   test_get_handle_with_pathz2TestCommonIOCapabilities.test_get_handle_with_paths   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    r[   r\   closed)r   input_bufferr_   s      r   test_get_handle_with_bufferz4TestCommonIOCapabilities.test_get_handle_with_buffer|   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    r[   r   r\   readlenencode)r   datar_   r=   	chunksizechunks         r   )test_bytesiowrapper_returns_correct_byteszBTestCommonIOCapabilities.test_bytesiowrapper_returns_correct_bytes   s     __Xd^T5A 	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        j                  ||       |j                  rJ 	 d d d        y # 1 sw Y   y xY w)
Nzpyarrow.csvrg   )1   ©Look)2   ®za snake)3ry   u   🐍abcrh   Fri   )rD   rE   pd	DataFramer   r    r[   read_csvr\   	to_pandasrF   assert_frame_equalrc   )r   pa_csvrp   rR   sr_   dfs          r   test_get_handle_pyarrow_compatz7TestCommonIOCapabilities.test_get_handle_pyarrow_compat   s    $$]3 <<%,BI\]
 TN__Qe4 	 0::<B!!"h/xx<x	  	  	 s   AB22B;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   )rq   T)ignore_indexr   )	r   r   r   data1concatrF   r   nextiloc)r   readerr=   rR   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z#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)Nrp   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)rD   rE   r"   r   r0   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   rk   r{   rp   missing_folderr   z@Cannot save file into a non-existent directory: .*missing_folderr   )	rD   rE   r   r   r"   r   r0   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   r0   )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   )rD   rE   r"   r   r0   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)iorp   r   ziris.csv)r   rp   fixed_widthzfixed_width_format.txt)r   rp   excelz
test1.xlsx)r   rp   r   zfeather-0_3_1.feather)r   rp   
legacy_hdfzdatetimetz_object.h5)r   rp   statazstata10_115.dta)r   sasrp   ztest1.sas7bdat)r   r   rp   ztsframe_v012.json)r   rp   r   zcategorical.0.25.0.picklec                     t        j                  |        || }t        |      } ||      } ||      }|j                  d      rt	        j
                  ||       y t	        j                  ||       y )Nz.pickle)rD   rE   r
   endswithrF   assert_categorical_equalr   )r   r   r   r   datapathmypathr=   rR   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        j                  d      }t        j                  d      }t	        j
                  dddgi      }|5 }|5 }t        j                  |       t        |      }	t        ||      }
 |
|fi |  |
|	fi | t        |d      5 }t        |d      5 }|d	k(  rCt	        j                  |fi |}t	        j                  |fi |}t        j                  ||       n'|j                         }|j                         }||k(  sJ d d d        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   *xY w# 1 sw Y   y xY w)
N)r   jinja2stringfspathAr   r   rh   r   )rD   rE   rF   rG   r   r   r
   getattrrH   
read_excelr   rm   )r   writer_namewriter_kwargsr   p1p2r   r   r   r   writerf_strf_pathr=   rR   s                  r   test_write_fspath_allz.TestCommonIOCapabilities.test_write_fspath_allQ  sg    ,&)__X&__X&\\3A-( 	.62 	.'!&)FR-F6+]+6+]+fd# 
.ud64.@ 
.F*,  ]]5BMBF!}}VE}EH))&(;"ZZ\F%{{}H!X---
. 
.	. 	. 	.
. 
. 
. 
.	. 	. 	. 	.sV   E/"AE#-E:A0E	*E2E#:E/EEE E##E,	(E//E8c                    t        j                  d       t        j                  dddgi      }t	        j
                  d      }t	        j
                  d      }|5 }|5 }t        |      }|j                  |d       |j                  |d       t        j                  |d      }t        j                  |d      }d d d        d d d        t	        j                         y # 1 sw Y   (xY w# 1 sw Y   ,xY w)	Nr   r   r   r   r   r   r.   )key)
rD   rE   r   r   rF   rG   r
   to_hdfread_hdfr   )	r   r   r   r   r   r   r   r=   rR   s	            r   test_write_fspath_hdf5z/TestCommonIOCapabilities.test_write_fspath_hdf5x  s     	H%\\3A-(__X&__X& 	662 	6!&)FIIf%I(IIf%I([[U3F{{6u5H	6 	6 	fh/	6 	6 	6 	6s%   C1A C%>C1%C.	*C11C:N)6r   r   r   r   r(   r*   r3   td
skip_if_nor9   r>   rJ   rD   markparametrize
path_typesrS   strr
   r   r`   re   rs   r   r   r   r   FileNotFoundErrorread_fwfr   read_featherOSErrorr   
read_stataread_sas	read_jsonread_pickler   r   r   r   r   r   
to_parquetr   r   r   r   
read_tabler   r   to_datetimer   r   r   r   r   r   r   :   s   E==< R]]96 6'
E [[[*5' 6' [[[3d*CDK EK#2. "
D [[-[[$ 159[[$ 159]]F$5v>__i)<[[($5t<]]D"3U;[[$ 1:>\\4!2F;^^T#4h?
	
0 [[-\\  $7\\!!4&9\\""FGV<\\$$i)D\\$$i)D\\""D'59\\!!4&9\\##T7H=		
&& [[-[[$ 159]]D"3U;[[$ 159]]F$5v>__i)<[[($5t<]]D"3U;[[$ 1:>\\4!2F;^^T#4h?	
8 [[[[$ AB]]D"CDG
 ]]F$IJB D
 ]]D"LM[[$ GH\\4!LME-	
>4?>4 [[,r4 (J/<2y)D!D!T""d#,7I(JKTR		
..40r   r   c                      | dddd      S )Nr   rp   r   ztest_mmap.csvr   )r   s    r   	mmap_filer    s    D&%99r   c                       e Zd Zd Zd Zd Zd Zej                  j                  dddg      ej                  j                  dd	d
g      d               Z
y)TestMMapWrapperc                    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   Trl   encodingzI/O operation on closed file)r   filenor   r  mmaperrorrD   r   r    _maybe_memory_maprH   
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)Nrl   r  rb   T)rj   
memory_mapz^$r   )rH   	readlinesr    r[   r\   
isinstancebufferr  r   striprD   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                 4   t        j                         5 }t        j                  dt	        j
                  d      j                  d      z  t        j                  t        d      t              t        j                  t        d      D cg c]  }d| 	 c}t                    }|j                  |       t        j                  t        d	
      5  t        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)N皙?x      r   ABCDdtyper0  i-columnsindexzUnknown enginer   pyt)r   )rF   rG   r   r   nparangereshapeIndexlistobjectranger   rD   r   r  r   r   r   ir   s       r   test_unknown_enginez#TestMMapWrapper.test_unknown_engine  s    __ 	0$biin,,W55fV<hh%)<Q"QC<FKB
 IIdOz1AB 0D/0	0 	0  =0 0	0 	0s6   A5D
C=>DD,D=DD	DDc                     t        j                         5 }t        j                  dt	        j
                  d      j                  d      z  t        j                  t        d      t              t        j                  t        d      D cg c]  }d| 	 c}t                    }|j                  |d	
       t        j                  |t        j                  |d             ddd       yc c}w # 1 sw Y   yxY w)z\
        'encoding' shouldn't be passed to 'open' in binary mode.

        GH 35058
        r-  r.  r/  r1  r2  r0  r4  r5  zw+brB   r   	index_colN)rF   rG   r   r   r9  r:  r;  r<  r=  r>  r?  r   r   r   r@  s       r   test_binary_modez TestMMapWrapper.test_binary_mode  s     __ 	F$biin,,W55fV<hh%)<Q"QC<FKB
 IIdI'!!"bkk$!&DE	F 	F  =		F 	Fs   A5C4
C/AC4/C44C=r  zutf-16zutf-32compression_bz2xzc                    t        j                  dt        j                  d      j	                  d      z  t        j
                  t        d      t              t        j
                  t        d      D cg c]  }d| 	 c}t                    }t        j                         5 }t        j                  t              5  |j                  |||	       d
d
d
       d}t        j                  t         |      5  t        j"                  |||	       d
d
d
       d
d
d
       y
c c}w # 1 sw Y   UxY w# 1 sw Y   #x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
        r-  r.  r/  r1  r2  r0  r4  r5  )rN   r  NzHUTF-\d+ stream does not start with BOM|'utf-\d+' codec can't decode byter   )r   r   r9  r:  r;  r<  r=  r>  r?  rF   rG   assert_produces_warningUnicodeWarningr   rD   r   UnicodeErrorr   )r   r  rG  rA  r   r   r  s          r   test_warning_missing_utf_bomz,TestMMapWrapper.test_warning_missing_utf_bom  s    \\"))C.((11HHT&\8((eBi8bH8G

 __ 
	O$++N; M		$L8	LM
5  |37 ODlXNO
	O 
	O 9M MO O
	O 
	OsB   5D%'ED*%E;D6E*D3	/E6D?	;EEN)r   r   r   r  r+  rB  rF  rD   r   r   rN  r   r   r   r  r    s`    1,""	0F [[Z(H)=>[[^eT];O < ?Or   r  c                     t        j                  d      sJ t        j                  d      sJ t        j                  d      rJ t        j                  d      rJ t        j                  d      rJ t        j                  d      rJ t        j                  d      rJ t        j                  d      rJ t        j                  d	      sJ 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   r  rl   formatr   r   c                    t        j                  dt        j                  d      j	                  d      z  t        j
                  t        d      t              t        j
                  t        d      D cg c]  }d| 	 c}t                    }t        j                         5 }t        j                  |d	| 
      5 } t        |d|       |       d d d        t        j                  |d| 
      5 }|dk(  rt        j                  |d      }nt        j                  |      }d d d        d d d        t        j                   |       y c c}w # 1 sw Y   xY w# 1 sw Y   9xY w# 1 sw Y   =xY w)Nr-  r.  r/  r1  r2  r0  r4  r5  rV   )rC   r  to_rb   r   r   rD  )r   r   r9  r:  r;  r<  r=  r>  r?  rF   rG   codecsrH   r   r   r  r   )r  rR  rA  rR   r   r\   r   s          r   test_codecs_encodingrV    s&    ||biin$$W--fV4hh%)4Q"QC4FCH
 
	 *d[[C(; 	6v-GHF8n-f5	6[[C(; 	*v[[15\\&)		** (B' 5	6 	6	* 	** *sB   5E'E- E E-63E!)E-E	E-!E*	&E--E6c                  D   t        j                  dt        j                  d      j	                  d      z  t        j
                  t        d      t              t        j
                  t        d      D  cg c]  } d|  	 c} t                    }t        j                         5 }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        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   MxY w# 1 sw Y   QxY w# 1 sw Y   UxY w)Nr-  r.  r/  r1  r2  r0  r4  r5  rA   rl   rh   r   rD  )r   r   r9  r:  r;  r<  r=  r>  r?  rF   rG   rH   rU  	getwriterr   	getreaderr   r   )rA  rR   r   r\   encodedr   s         r   test_codecs_get_writer_readerr[    sR   ||biin$$W--fV4hh%)4Q"QC4FCH
 
	 7d$ 	)*!!'*62 )g()	) $ 	7*!!'*62 7g[[A67	7	7 (B' 5) )	) 	)7 7	7 	7	7 7sr   5E!'F4E2E&"E2*F>F
E>2F
:F&E/+E22E;	7F>FF

F	FFzio_class,mode,msgtz*a bytes-like object is required, not 'str'r}   z%string argument expected, got 'bytes'c                    t        j                  dt        j                  d      j	                  d      z  t        j
                  t        d      t              t        j
                  t        d      D cg c]  }d| 	 c}t                    } |        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)Nr-  r.  r/  r1  r2  r0  r4  r5  r   rV   rB   )r   r   r9  r:  r;  r<  r=  r>  r?  rD   r   	TypeErrorr   )io_classrC   r  rA  rR   r#  s         r   test_explicit_encodingr`  $  s     ||biin$$W--fV4hh%)4Q"QC4FCH
 
 5v]]9C0 	5OOF1TFO4	55 5 5	5 	55 5s*   5CC/6C#C/#C,	(C//C8encoding_errors)N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      }t	        j
                         5 }t        |      }|j                  |       | dk7  r/t        j                  t        |      5   |||        d d d        nP |||       }|j                  |       }	t        j                  |	|	gi|	dz  g      }
t	        j                  ||
       d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nz'utf-8' codec can't decode byte   r      ,   
r   r   rD  s   {"s   ": {"s   ":"s   "}}r7  )orientrc  r   )ra  errors)r7  )r   r   r   r  rF   rG   r   write_bytesrD   r   UnicodeDecodeErrordecoder   r   )ra  rR  r  bad_encodingcontentr   r   filer   decodedrR   s              r   test_encoding_errorsrr  9  sg    ,CL%-q0@@4G,V2 Q  	
   	 g6		 0dDz!i'1= >t_=> > o>B")))AG||Wwi$81NH!!"h/0 0
> >0 0s%    =D6=D*AD6*D3	/D66D?c                      t        j                         5 } t        j                  t        d      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)Nzunknown error handler namer   rV   badri  )rF   rG   rD   r   LookupErrorr    r[   r   s    r   test_bad_encdoing_errorsrv  \  s\    		 5d]];.JK 	5OOD#e4	55 5	5 	55 5s"   A'A
A'A$	 A''A0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)rD   r   r  r   r   errnoENOENT)r  s    r   test_errno_attributer{  c  sJ    	(	@ )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   rh   T)r   )rD   r   r   r   r    r[   )r#  s    r   test_fail_mmapr}  j  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.closes  s    &/!r   N)r   r   r   r  r   r   r   	TestErrorr  r  s    	"r   r  r  r   rh   )rD   r   r  r   r    r[   created_handlesappend)r  r#  r_   s      r   test_close_on_errorr  p  s    " " 
wf	- <Y 	<&. <'''..y{;<	<< << <	< 	<< <s:   BB!B)B1BBBB	BB#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)Hr   rU  ry  	functoolsr   r   r   r   r   r  r"   pathlibr   r   rW   numpyr9  rD   pandas.compatr   pandas.util._test_decoratorsutil_test_decoratorsr   pandasr   pandas._testing_testingrF   pandas.io.commoncommonr    r   filterwarnings
pytestmarkr
   r   r   py.pathr   r6   r  ImportErrorr   r5   dirname__file__r   r   fixturer  r  rQ  r   rV  r[  r`  rr  rv  r{  r}  r  r   r  r   r  r   r  r  r  r  r  r   r   r   <module>r     sP      
  	      - ) )    [[''C

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