
    Oh]                        d Z ddlZddlZddlmZ ddlmZmZmZ ddl	Z	ddl
Z
ddlmZ ddlZddlZddlZddlZddlmZ ddlmZ ddlmc mZ ddlZddlmZ ddlmc m Z! ejD                  jG                  d      Z$ G d	 d
      Z%e&e%egZ'	 ddl(m)Z* e'jW                  e*       e
jZ                  j]                  e
jZ                  j_                  e0            Z1 G d d      Z2ejf                  d        Z4 G d d      Z5d Z6ejD                  jo                  dddg      ejD                  jo                  dddg      d               Z8d Z9ejD                  jo                  deddfeddfg      d        Z:ejD                  jo                  dg d       ejD                  jo                  dddg      d!               Z;d" Z<d# Z=d$ Z>d% Z?ejD                  jo                  d&ej                  ej                  ej                  ej                  ej                  ej                  ej                  ej                  ej                  g	      d'        ZIy# e,$ r Y w xY w)(z0
Tests for the pandas.io.common functionalities
    N)partial)BytesIOStringIOUnsupportedOperation)Path)is_platform_windows)pa_version_under19p0z=ignore:Passing a BlockManager to DataFrame:DeprecationWarningc                       e Zd ZdZddZd Zy)CustomFSPathz%For testing fspath on unknown objectsNc                     || _         y Npath)selfr   s     c/var/www/html/diagnosisapp-backend/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   )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jd                  ej@                  dd)ej                  jg                  d*d+,      -      ejB                  dd.fejD                  dd/fejF                  dd0fejH                  dd1fg
      d2        Z4ej                  j                  d3d4i dfd5d6d7id7fd8i dfd9i dfd:i dfd;i dfd<i dfd=d> ejj                  d?      idfg      d@        Z6dA Z7yB)CTestCommonIOCapabilitiesziindex,A,B,C,D
foo,2,3,4,5
bar,7,8,9,10
baz,12,13,14,15
qux,12,13,14,15
foo2,12,13,14,15
bar2,12,13,14,15
c                     d}t        j                  |      }||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_userE   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_pathM   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_pathlibT   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   r1   abspath	LocalPathr!   r0   )r   r   abs_pathlpaths       r   test_stringify_path_localpathz6TestCommonIOCapabilities.test_stringify_path_localpathZ   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!   r0   )r   presults      r   test_stringify_path_fspathz3TestCommonIOCapabilities.test_stringify_path_fspatha   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!   r0   )r   rA   r   
fsspec_objs       r   !test_stringify_file_and_path_likez:TestCommonIOCapabilities.test_stringify_file_and_path_likef   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_formatrL   	extensionexpectedr   rO   s          r    test_infer_compression_from_pathz9TestCommonIOCapabilities.test_infer_compression_from_pathm   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   rL   tmpr'   handless        r   test_get_handle_with_pathz2TestCommonIOCapabilities.test_get_handle_with_patht   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        r|j                  d
      }t        j                  ||       |j                  rJ 	 d d d        y # 1 sw Y   y xY w)Nzpyarrow.csvrh   )1   ©Look)2   ®za snake)3rz   u   🐍abcri   Frj   object)rE   rF   pd	DataFramer   r!   r\   read_csvr]   	to_pandasr	   astyperG   assert_frame_equalrd   )r   pa_csvrq   rS   sr`   dfs          r   test_get_handle_pyarrow_compatz7TestCommonIOCapabilities.test_get_handle_pyarrow_compat   s    $$]3 <<%,BI\]
 TN__Qe4 	 0::<B##??84!!"h/xx<x	  	  	 s   A%C		C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   )rr   T)ignore_indexr   )	r   r   r   data1concatrG   r   nextiloc)r   readerr>   rS   itfirsts         r   test_iteratorz&TestCommonIOCapabilities.test_iterator   s    [[$**-; 	:v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)Nrq   does_not_exist.File (b')?.+does_not_exist\.'? does not exist:\[Errno 2\] No such file or directory: '.+does_not_exist\.'zExpected object or value7path_or_buf needs to be a string file path or file-like#\[Errno 2\] File .+does_not_exist\.$ does not exist: '.+does_not_exist\.<   \[Errno 2\] 没有那个文件或目录: '.+does_not_exist\.?\[Errno 2\] File o directory non esistente: '.+does_not_exist\.+Failed to open local file.+does_not_exist\.(|)match)rE   rF   r#   r   r1   HEREraises)r   r   moduleerror_classfn_extr   msg1msg2msg3msg4msg5msg6msg7msg8s                 r   test_read_non_existentz/TestCommonIOCapabilities.test_read_non_existent   s    	F#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   rl   r|   rq   missing_folderr   z@Cannot save file into a non-existent directory: .*missing_folderr   )	rE   rF   r   r   r#   r   r1   r   r   )r   methodr   r   r   dummy_framer   s          r   #test_write_missing_parent_directoryz<TestCommonIOCapabilities.test_write_missing_parent_directory   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   )rE   rF   r#   r   r1   setattrr!   r   )r   r   r   r   r   monkeypatchr   r   r   r   r   r   r   r   r   s                  r   test_read_expands_user_home_dirz8TestCommonIOCapabilities.test_read_expands_user_home_dir   s   $ 	F#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)iorq   r   ziris.csv)r   rq   fixed_widthzfixed_width_format.txt)r   rq   excelz
test1.xlsx)r   rq   r   zfeather-0_3_1.feather)r   rq   
legacy_hdfzdatetimetz_object.h5zTODO(infer_string)F)reasonstrict)marks)r   rq   statazstata10_115.dta)r   sasrq   ztest1.sas7bdat)r   r   rq   ztsframe_v012.json)r   rq   r   zcategorical.0.25.0.picklec                     t        j                  |        || }t        |      } ||      } ||      }|j                  d      rt	        j
                  ||       y t	        j                  ||       y )Nz.pickle)rE   rF   r   endswithrG   assert_categorical_equalr   )r   r   r   r   datapathmypathr>   rS   s           r   test_read_fspath_allz-TestCommonIOCapabilities.test_read_fspath_all'  sd    D 	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   ri   r   )rE   rF   rG   rH   r   r   r   getattrrI   
read_excelr   rn   )r   writer_namewriter_kwargsr   p1p2r   r   r   r   writerf_strf_pathr>   rS   s                  r   test_write_fspath_allz.TestCommonIOCapabilities.test_write_fspath_allV  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)
rE   rF   r   r   rG   rH   r   to_hdfread_hdfr   )	r   r   r   r   r   r   r   r>   rS   s	            r   test_write_fspath_hdf5z/TestCommonIOCapabilities.test_write_fspath_hdf5}  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)8r   r   r   r   r)   r+   r4   td
skip_if_nor:   r?   rK   rE   markparametrize
path_typesrT   strr   r   ra   rf   rt   r   r   r   r   FileNotFoundErrorread_fwfr   read_featherOSErrorr   
read_stataread_sas	read_jsonread_pickler   r   r   r   r   r   
to_parquetr   r   r   r   
read_tabler   paramxfailr   to_datetimer   r   r   r   r   r   r   ;   s   E==< R]]96 6'
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
 FLLDkk''/CE'R ]]D"LM[[$ GH\\4!LME1	
 B4C B4 [[,r4 (J/<2y)D!D!T""d#,7I(JKTR		
..40r   r   c                      | dddd      S )Nr   rq   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   Trm   encodingzI/O operation on closed file)r   filenor   r
  mmaperrorrE   r   r!   _maybe_memory_maprI   
ValueError)r   r  non_filemsgerrtargets         r   test_constructor_bad_filez)TestMMapWrapper.test_constructor_bad_file  s    -.$  .C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)Nrm   r  rc   T)rk   
memory_mapz^$r   )rI   	readlinesr!   r\   r]   
isinstancebufferr  r   striprE   r   StopIteration)r   r  r%  lineswrapperswrapperline	next_lines           r   	test_nextzTestMMapWrapper.test_next  s    )g. 	"&$$&ETd ""//!'.."7"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                         5 }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        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   ABCDr8  i-columnsindexzUnknown enginer   pyt)r   )rG   rH   r   r   nparangereshapeIndexlistranger   rE   r   r!  r   r   r   ir   s       r   test_unknown_enginez#TestMMapWrapper.test_unknown_engine  s    __ 	0$biin,,W55f.hh%)<Q"QC<=B
 IIdOz1AB 0D/0	0 	0  =0 0	0 	0s6   A/DC18DC6 D1D6C?	;DDc                    t        j                         5 }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
             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
        r5  r6  r7  r9  r8  r:  r;  zw+brC   r   	index_colN)rG   rH   r   r   r?  r@  rA  rB  rC  rD  r   r   r   rE  s       r   test_binary_modez TestMMapWrapper.test_binary_mode  s     __ 	F$biin,,W55f.hh%)<Q"QC<=B
 IIdI'!!"bkk$!&DE	F 	F  =		F 	Fs   A/C(C#A
C(#C((C1r  zutf-16zutf-32compression_bz2xzc                    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                         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
        r5  r6  r7  r9  r8  r:  r;  )rO   r  NzHUTF-\d+ stream does not start with BOM|'utf-\d+' codec can't decode byter   )r   r   r?  r@  rA  rB  rC  rD  rG   rH   assert_produces_warningUnicodeWarningr   rE   r   UnicodeErrorr   )r   r  rL  rF  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$++N; M		$L8	LM
5  |37 ODlXNO
	O 
	O 9M MO O
	O 
	OsB   /DD65D
%D6/D*D6D'	#D6*D3	/D66D?N)r   r   r   r&  r3  rG  rK  rE   r  r  rS  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_urlrV    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  rm   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        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)Nr5  r6  r7  r9  r8  r:  r;  rW   )rD   r  to_rc   r   r   rI  )r   r   r?  r@  rA  rB  rC  rD  rG   rH   codecsrI   r   r   r  r   )r  rW  rF  rS   r   r]   r   s          r   test_codecs_encodingr[    s"    ||biin$$W--f&hh%)4Q"QC45H
 
	 *d[[C(; 	6v-GHF8n-f5	6[[C(; 	*v[[15\\&)		** (B' 5	6 	6	* 	** *sB   /EE!4E	
 E!*3EE!	E	E!E	E!!E*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        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)Nr5  r6  r7  r9  r8  r:  r;  rB   rm   ri   r   rI  )r   r   r?  r@  rA  rB  rC  rD  rG   rH   rI   rZ  	getwriterr   	getreaderr   r   )rF  rS   r   r]   encodedr   s         r   test_codecs_get_writer_readerr`    sN   ||biin$$W--f&hh%)4Q"QC45H
 
	 7d$ 	)*!!'*62 )g()	) $ 	7*!!'*62 7g[[A67	7	7 (B' 5) )	) 	)7 7	7 	7	7 7sr   /EF
(E&EE&F
2E>E2&E>.F
E#E&&E/	+F
2E;7E>>F	F

Fzio_class,mode,msgtz*a bytes-like object is required, not 'str'r~   z%string argument expected, got 'bytes'c                    t        j                  dt        j                  d      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)Nr5  r6  r7  r9  r8  r:  r;  r   rW   rC   )r   r   r?  r@  rA  rB  rC  rD  rE   r   	TypeErrorr   )io_classrD   r#  rF  rS   r+  s         r   test_explicit_encodingre  )  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)Nr   replacec                    d}d}|dk(  r0d|z   dz   |dz  z   dz   |z   }t        t        j                  d      }n2d	|dz  z   d
z   |z   dz   |z   dz   }t        t        j                  d      }t	        j
                         5 }t        |      }|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   rI  s   {"s   ": {"s   ":"s   "}}r=  )orientrg  r   )rf  errors)r=  )r   r   r   r  rG   rH   r   write_bytesrE   r   UnicodeDecodeErrordecoder   r   )rf  rW  r#  bad_encodingcontentr   r   filer   decodedrS   s              r   test_encoding_errorsrv  >  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   rW   badrm  )rG   rH   rE   r   LookupErrorr!   r\   r   s    r   test_bad_encdoing_errorsrz  a  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)rE   r   r  r   r   errnoENOENT)r$  s    r   test_errno_attributer  h  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   ri   T)r(  )rE   r   r   r   r!   r\   )r+  s    r   test_fail_mmapr  o  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.closex  s    &/!r   N)r   r   r   r  r   r   r   	TestErrorr  w  s    	"r   r  r  r   ri   )rE   r   r
  r   r!   r\   created_handlesappend)r  r+  r`   s      r   test_close_on_errorr  u  s    " " 
wf	- <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)Jr   rZ  r}  	functoolsr   r   r   r   r   r  r#   pathlibr   r   rX   numpyr?  rE   pandas.compatr   pandas.compat.pyarrowr	   pandas.util._test_decoratorsutil_test_decoratorsr  pandasr   pandas._testing_testingrG   pandas.io.commoncommonr!   r  filterwarnings
pytestmarkr   r  r  py.pathr   r7   r  ImportErrorr   r6   dirname__file__r   r   fixturer  r  rV  r  r[  r`  re  rv  rz  r  r  r  r   r  r   r	  r   r  r  r  r  r  r   r   r   <module>r     sS      
  	      - 6 ) )    [[''C

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