
    dW                     2   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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  G d d          ZeeegZ 	 dd	l!m"Z# e $                    e#           n# e%$ r Y nw xY we
j&        '                    e
j&        (                    e)                    Z* G d
 d          Z+ej,        d             Z- G d d          Z.d Z/ej0        1                    dddg          ej0        1                    dddg          d                         Z2d Z3ej0        1                    deddfeddfg          d             Z4ej0        1                    dg d          ej0        1                    dddg          d                         Z5d  Z6d! Z7d" Z8d# Z9ej0        1                    d$ej:        ej;        ej<        ej=        ej>        ej?        ej@        ejA        ejB        g	          d%             ZCdS )&z0
Tests for the pandas.io.common functionalities
    N)partial)BytesIOStringIOUnsupportedOperation)Path)is_platform_windowsc                        e Zd ZdZddZd ZdS )CustomFSPathz%For testing fspath on unknown objectsreturnNc                     || _         d S Npath)selfr   s     W/var/www/html/t/fyr/venv311/lib/python3.11/site-packages/pandas/tests/io/test_common.py__init__zCustomFSPath.__init__    s    			    c                     | j         S r   r   r   s    r   
__fspath__zCustomFSPath.__fspath__#   s
    yr   )r   N)__name__
__module____qualname____doc__r   r    r   r   r
   r
      s=        //       r   r
   )localc                   .   e Zd ZdZd Zd Zd Z ej        d          d             Z	d Z
d Zej                            d	e          d
             Zej                            d	eeeg          d             Zd Zd Z ej        d          d             Zd Zej                            dej        dedfej        dedfej        dedfej        dedfej         dedfej!        dedfej"        dedfej#        dedfej$        dedfg	          d             Z%ej                            dej&        j'        dedfej&        j(        ded fej&        j)        dedfej&        j*        dedfej&        j+        ded!fej&        j,        dedfej&        j-        dedfej&        j.        dedfg          d"             Z/ej                            dej        dedfej0        dedfej        dedfej        dedfej        dedfej         dedfej!        dedfej"        dedfej#        dedfej$        dedfg
          d#             Z1ej                            d$ej        dd%fej0        dd%fej        dd&fej        dd'fej        dd(fej         dd)fej!        dd*fej"        dd+fej#        dd,fej$        dd-fg
          d.             Z2ej                            d/d0i dfd1d2d3id3fd4i dfd5i dfd6i dfd7i dfd8i dfd9d: ej3        d;          idfg          d<             Z4d= Z5d>S )?TestCommonIOCapabilitiesziindex,A,B,C,D
foo,2,3,4,5
bar,7,8,9,10
baz,12,13,14,15
qux,12,13,14,15
foo2,12,13,14,15
bar2,12,13,14,15
c                     d}t          j        |          }||k    sJ t          j                            |          sJ t          j                            |          |k    sJ d S )Nz
~/sometest)icom_expand_userosr   isabs
expanduserr   filenameexpanded_names      r   test_expand_userz)TestCommonIOCapabilities.test_expand_user?   si    )(33((((w}}]+++++w!!(++}<<<<<<r   c                     d}t          j        |          }||k    sJ t          j                            |          |k    sJ d S )Nz/somefolder/sometest)r    r!   r"   r   r$   r%   s      r   test_expand_user_normal_pathz5TestCommonIOCapabilities.test_expand_user_normal_pathG   sO    ))(33((((w!!(++}<<<<<<r   c                     t          j        t          d                    }|dk    sJ t          j        t          d                    }|t          j                            dd          k    sJ d S )N.zfoo//barfoobar)r    stringify_pathr   r"   r   join)r   rel_pathredundant_paths      r   test_stringify_path_pathlibz4TestCommonIOCapabilities.test_stringify_path_pathlibN   sd    &tCyy113,T*-=-=>>eU!;!;;;;;;;r   zpy.pathc                     t           j                            dd          }t           j                            |          }t	          |          }t          j        |          |k    sJ d S )Nr-   r.   )r"   r   r0   abspath	LocalPathr    r/   )r   r   abs_pathlpaths       r   test_stringify_path_localpathz6TestCommonIOCapabilities.test_stringify_path_localpathT   sW    w||E5))7??4(($"5))X555555r   c                 \    t          d          }t          j        |          }|dk    sJ d S )Nfoo/bar.csv)r
   r    r/   )r   presults      r   test_stringify_path_fspathz3TestCommonIOCapabilities.test_stringify_path_fspath[   s6    ''$Q''&&&&&&r   c                     t          j        d          }t          j                    5 }|                    d| d          5 }|t          j        |          k    sJ 	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )N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_like`   s4   $X.._ 	E$-t--D99 EZ!T%8%D%DDDDDDE E E E E E E E E E E E E E E	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	Es5   BA+B+A/	/B2A/	3BB
B	path_typec                 h    |\  }} |d|z             }t          j        |d          }||k    sJ d S )Nr;   infer)compression)r    infer_compression)r   compression_formatrK   	extensionexpectedr   rN   s          r    test_infer_compression_from_pathz9TestCommonIOCapabilities.test_infer_compression_from_pathg   sL    0	8y233,TwGGGh&&&&&&r   c                    t          j        t          j                              5 } |dt          |          j        z   dz             }t          j        |d          5 }t          |j        j                                                  sJ t          j
                            |          |j        j        k    sJ 	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )N)dirz~/z	/sometestw)tempfileTemporaryDirectoryr   homenamer    
get_handlehandleis_absoluter"   r   r$   )r   rK   tmpr&   handless        r   test_get_handle_with_pathz2TestCommonIOCapabilities.test_get_handle_with_pathn   su    (TY[[999 	KS yS		!6!DEEH3// K7GN/00<<>>>>>w))(33w~7JJJJJJK K K K K K K K K K K K K K K	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	K 	Ks6   9C" AC
>C"
C	C"C	C""C&)C&c                     t                      5 }t          j        |d          5 }|j        |k    sJ 	 d d d            n# 1 swxY w Y   |j        rJ 	 d d d            n# 1 swxY w Y   |j        sJ d S )Nr)r   r    r[   r\   closed)r   input_bufferr_   s      r   test_get_handle_with_bufferz4TestCommonIOCapabilities.test_get_handle_with_bufferw   s   ZZ 	+<s33 6w~555556 6 6 6 6 6 6 6 6 6 6 6 6 6 6#*****	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ """"""s3   A!A A! A	A!A	A!!A%(A%c                    d}t          j        t          |          dd          5 }d}d}	 |j                            |          }t          |          |k    sJ t          |          |k     r2t          |j                                                  dk    sJ ||z  }n||z  }z||                    d	          k    sJ 	 d d d            d S # 1 swxY w Y   d S )
N&   a,b,c
1,2,3
©,®,®
Look,a snake,🐍rbFis_textr      Tr   utf-8)r    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AA 	2WFI
 ++I665zzY....u::	)) w~224455::::eOF%
  T[[1111111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2s   BCCCpyarrowc                 f   ddl m} d}t          j        g dg dg dd          }t	          |          }t          j        |dd	
          5 }|                    |j                  	                                }t          j        ||           |j        rJ 	 d d d            d S # 1 swxY w Y   d S )Nr   )csvrg   )1   ©Look)2   ®za snake)3r{   u   🐍abcrh   Fri   )rt   rv   pd	DataFramer   r    r[   read_csvr\   	to_pandasrF   assert_frame_equalrc   )r   rv   rp   rR   sr_   dfs          r   test_get_handle_pyarrow_compatz7TestCommonIOCapabilities.test_get_handle_pyarrow_compat   s    <%%%,B,B,BI\I\I\]]
 
 TNN_Qe444 	 gn--7799B!"h///x	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s   AB&&B*-B*c                 r   t          j        t          | j                  d          5 }t          j        |d          }d d d            n# 1 swxY w Y   t          j        t          | j                            }t          j        ||           t          j        t          | j                  d          5 }t          |          }t          j        ||j        dg                    t          j        t          j        |          |j        dd                     d d d            d S # 1 swxY w Y   d S )N   )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YvD999F	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	:;x
3344
fh/// [$*--;;; 	DrHHE!%s);<<<!")B--qrr1BCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	Ds$   AAA:A%D,,D03D0z#reader, module, error_class, fn_extr"   rv   txtxlrdxlsxfeathertablesh5dtasas7bdatjsonpicklec                 z   t          j        |           t          j                            t
          dd|z             }d| d}d| d}d}d}	d	| d
| d}
d| d}d| d}d| }t          j        |d| d| d| d|	 d|
 d| d| d| d          5   ||           d d d            d S # 1 swxY w Y   d S )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###w||D&*;f*DEEHvHHHVVVVV)H-6 - -#)- - - 	 YvXXXXvXXX 	 GfFF]OtOOdOOTOODOO4OO$OOOOOOO
 
 
 	 	 F4LLL		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   B00B47B4z#method, module, error_class, fn_exthtmlparquetc                 4   t          j        |           t          j        g dg dg dd          }t          j                            t          ddd|z             }t          j        |d	          5   |||           d d d            d S # 1 swxY w Y   d S )
N)r         )r   r      )r   r   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   s     	F###l#S#STTw||D&*:<MPV<VWW]U
 
 
 	& 	& F;%%%		& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&s   3BBBc                    t          j        |           t          j                            dd|z             }|                    t          dd            d| d}d| d}d	}	d
}
d| d| d}d| d}d| d}d| }t          j        |d| d| d|	 d|
 d| d| d| d| d          5   ||           d d d            d S # 1 swxY w Y   d S )N~r   r!   c                 B    t           j                            d|           S )Nr-   )r"   r   r0   )xs    r   <lambda>zJTestCommonIOCapabilities.test_read_expands_user_home_dir.<locals>.<lambda>
  s    BGLLPQ<R<R r   r   r   r   r   z0Unexpected character found when decoding 'false'r   r   r   r   r   r   r   r   r   r   )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###w||C!2V!;<<D.2R2RSSSHvHHHVVVVVAH-6 - -#)- - - 	 YvXXXXvXXX 	 GfFF]OtOOdOOTOODOO4OO$OOOOOOO
 
 
 	 	 F4LLL		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   .CCCzreader, module, path)iorp   rv   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          |          } ||          } ||          }|                    d          rt	          j        ||           d S t	          j        ||           d S )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   s    @ 	F###xd##6$<<==## 	4'99999!&(33333r   z"writer_name, writer_kwargs, moduleto_csvto_excelengineopenpyxl
to_featherto_htmlto_jsonto_latex	to_pickleto_stata
time_stampz2019-01-01 00:00c           	      *   |dv rt          j        d           t          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    r:t	          j	        |fi |}t	          j	        |fi |}t          j
        ||           n0|                                }|                                }||k    sJ d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )
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_allM  s    ,&&)))_X&&_X&&\3A-(( 	.62 	.'''!&))FR--FF6++]+++F6++]+++fd## 
.ud64.@.@ 
.F*,,  ]5BBMBBF!}VEE}EEH)&(;;;;"ZZ\\F%{{}}H!X----
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
.	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   FAE04EA1E	6EEE	E
EE0EE0 E!E0$F0E4	4F7E4	8FFFc                    t          j        d           t          j        dddgi          }t	          j        d          }t	          j        d          }|5 }|5 }t          |          }|                    |d           |                    |d           t          j        |d          }t          j        |d          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t	          j	        ||           d S )	Nr   r   r   r   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_hdf5t  su    	H%%%\3A-((_X&&_X&& 	662 	6!&))FIIf%I(((IIf%I((([U333F{6u555H	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	fh/////s7   C'A*CC'C	C'C	C''C+.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   5   s       E= = == = =< < < R]96 6 6' ' '
E E E [[*55' ' 65' [[3d*CDDK K EDK# # #2 2 2. R]9     "
D 
D 
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? >4 [,r4 (J/<2y)D!D!T""d#,7I(J(JKTR		
 . . .40 0 0 0 0r   r   c                      | dddd          S )Nr   rp   rv   ztest_mmap.csvr   )r   s    r   	mmap_filer    s    8D&%999r   c                       e Zd Zd Zd Zd Zd Zej        	                    dddg          ej        	                    dd	d
g          d                         Z
dS )TestMMapWrapperc                    t          d          }d |_        t                      r
d}t          }nd}t          j        }t          j        ||          5  t          j	        |d           d d d            n# 1 swxY w Y   t          |          5 }	 d d d            n# 1 swxY w Y   d}t          j        t          |          5  t          j	        |d           d d d            d S # 1 swxY w Y   d S )NzI am not a filec                      dS )Nr   r   r   r   r   z;TestMMapWrapper.test_constructor_bad_file.<locals>.<lambda>  s    " r   zThe parameter is incorrectz
[Errno 22]r   Tz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CCC*C]3c*** 	3 	3"8T222	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 	3 )__ 		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 -]:S111 	1 	1"64000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s6   A66A:=A:BB"%B"C))C-0C-c                 <   t          |          5 }|                                }t          j        |ddd          5 }|j        }t          |j        j        t          j                  sJ |D ]=}t          |          }|	                                |	                                k    sJ >t          j        t          d          5  t          |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nrb   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   )__ 	"$$&&ETd   ""/!'."7CCCCC! = =D $WI$??,,

<<<<<]=>>> " "MMM" " " " " " " " " " " " " " "" " " " " " " " " " " " " " "	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"sY   -DB	C9C"C9"C&&C9)C&*C9-D9C=	=D C=	DDDc                 @   t          j                    5 }t          j                    }|                    |           t	          j        t          d          5  t          j        |d           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )NzUnknown enginer   pyt)r   )	rF   rG   makeDataFramer   rD   r   r  r   r   r   r   r   s      r   test_unknown_enginez#TestMMapWrapper.test_unknown_engine  s   _ 	0$!##BIIdOOOz1ABBB 0 0D////0 0 0 0 0 0 0 0 0 0 0 0 0 0 0	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0s6   ABA;/B;A?	?BA?	BBBc                    t          j                    5 }t          j                    }|                    |d           t          j        |t          j        |d                     ddd           dS # 1 swxY w Y   dS )z\
        'encoding' shouldn't be passed to 'open' in binary mode.

        GH 35058
        zw+brB   r   	index_colN)rF   rG   r+  r   r   r   r   r,  s      r   test_binary_modez TestMMapWrapper.test_binary_mode  s     _ 	F$!##BIIdI'''!"bk$!&D&D&DEEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	Fs   AA55A9<A9encodingzutf-16zutf-32compression_bz2xzc                    t          j                    }t          j                    5 }t          j        t                    5  |                    |||           ddd           n# 1 swxY w Y   d}t          j        t          |          5  t          j
        |||           ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )z
        bz2 and xz do not write the byte order mark (BOM) for utf-16/32.

        https://stackoverflow.com/questions/55171439

        GH 35681
        )rN   r2  Nz&UTF-\d+ stream does not start with BOMr   )rF   r+  rG   assert_produces_warningUnicodeWarningr   rD   r   UnicodeErrorr   r   )r   r2  r3  r   r   r  s         r   test_warning_missing_utf_bomz,TestMMapWrapper.test_warning_missing_utf_bom  s    _ 	O$+N;; M M		$L8	LLLM M M M M M M M M M M M M M M <C|3777 O ODlXNNNNO O O O O O O O O O O O O O O	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	O 	OsY   C
A&C
&A*	*C
-A*	. C
B2&C
2B6	6C
9B6	:C

CCN)r   r   r   r  r(  r-  r1  rD   r   r   r:  r   r   r   r  r    s        1 1 1," " ""0 0 0	F 	F 	F [Z(H)=>>[^eT];;O O <; ?>O 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 d S )
Nzgcs://pandas/somethingelse.comzgs://pandas/somethingelse.comzhttp://pandas/somethingelse.comzrandom:pandas/somethingelse.comz/local/pathzrelative/local/pathzthis is not fsspec://urlz({'url': 'gs://pandas/somethingelse.com'}z#RFC-3986+compliant.spec://something)r    is_fsspec_urlr   r   r   test_is_fsspec_urlr=    s    >?????=>>>>>!"CDDDDD!"CDDDDD!-00000!"788888!"<=====!"LMMMMMCDDDDDDDr   r2  rl   formatrv   r   c                    t          j                    }t          j                    5 }t          j        |d|           5 } t          |d|           |           d d d            n# 1 swxY w Y   t          j        |d|           5 }|dk    rt          j        |d          }nt          j        |          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j	        ||           d S )NrV   )rC   r2  to_rb   rv   r   r/  )
rF   r+  rG   codecsrH   r   r   r   r  r   )r2  r>  rR   r   r\   r   s         r   test_codecs_encodingrB    s    !!H			 *d[C(;;; 	6v-GHnFnn--f555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6[C(;;; 	*v[1555\&))		* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	** * * * * * * * * * * * * * * (B'''''sX   CA(C(A,	,C/A,	0C
2C<CC	CC	CC#&C#c                  v   t          j                    } t          j                    5 }t          |d          5 } t	          j        d          |          5 }|                     |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          |d          5 } t	          j        d          |          5 }t          j	        |d          }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j
        | |           d S )NrA   rl   rh   r   r/  )rF   r+  rG   rH   rA  	getwriterr   	getreaderr   r   r   )rR   r   r\   encodedr   s        r   test_codecs_get_writer_readerrG    sQ   !!H			 7d$ 	)*!'**622 )g((() ) ) ) ) ) ) ) ) ) ) ) ) ) )	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) $ 	7*!'**622 7g[A6667 7 7 7 7 7 7 7 7 7 7 7 7 7 7	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7	7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 (B'''''s   DBA8,B8A<<B?A< BDB	DB	D*DC+D+C//D2C/3D6DD	D	D	
DD Dzio_class,mode,msgtz*a bytes-like object is required, not 'str'r   z%string argument expected, got 'bytes'c                    t          j                    } |             5 }t          j        t          |          5  |                    |d|            d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   rV   rB   )rF   r+  rD   r   	TypeErrorr   )io_classrC   r  rR   r   s        r   test_explicit_encodingrL  	  s    !!H	 5v]9C000 	5 	5OOFTO444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	55 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s4   A9A!A9!A%	%A9(A%	)A99A= A=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          |          }|                    |           | dk    rAt          j	        t          |          5   |||            d d d            n# 1 swxY w Y   nU |||           }|                    |           }	t          j        |	|	gi|	dz  g          }
t	          j        ||
           d d d            d S # 1 swxY w Y   d S )Nz'utf-8' codec can't decode byte   rv      ,   
r   r   r/  s   {"s   ": {"s   ":"s   "}}index)orientrO  r   )rM  errors)rT  )r   r   r   r  rF   rG   r   write_bytesrD   r   UnicodeDecodeErrordecoder   r   )rM  r>  r  bad_encodingcontentr   r   filer   decodedrR   s              r   test_encoding_errorsr_    s'    ,CL%-q0@@4G,V222 Q  	
   	 g666			 0dDzz!!!i''1=== > >t_====> > > > > > > > > > > > > > > o>>>B")))AAG|Wwi$81NNNH!"h///0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0s8    AEC E C$	$E'C$	(AEEEc                      t          j                    5 } t          j        t          d          5  t          j        | dd           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nzunknown error handler namer   rV   badrV  )rF   rG   rD   r   LookupErrorr    r[   r   s    r   test_bad_encdoing_errorsrc  =  s    			 5d];.JKKK 	5 	5OD#e4444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	55 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s4   A,AA,A	A,A	A,,A03A0c                      t          j        t          d          5 } t          j        d           | j        t
          j        k    sJ 	 d d d            d S # 1 swxY w Y   d S )Nz\[Errno 2\]r   doesnt_exist)rD   r   r   r   r   errnoENOENT)r  s    r   test_errno_attributerh  D  s    	(	@	@	@ )C
N###yEL((((() ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) )s   ,AAAc                      t          j        t          d          5  t                      5 } t	          j        | dd           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr  r   rh   T)r  )rD   r   r   r   r    r[   )r   s    r   test_fail_mmaprj  K  s    	+8	<	<	< ; ;YY 	;&OFDT::::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;s4   A'AA'A	A'A	A''A+.A+c                  r    G d d          } t          j        t          d          5  t                      5 }t	          j        |d          5 }|j                             |                        d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nc                       e Zd Zd ZdS )&test_close_on_error.<locals>.TestErrorc                      t          d          )Ntest)r  r   s    r   closez,test_close_on_error.<locals>.TestError.closeT  s    &//!r   N)r   r   r   rp  r   r   r   	TestErrorrm  S  s#        	" 	" 	" 	" 	"r   rq  ro  r   rh   )rD   r   r  r   r    r[   created_handlesappend)rq  r   r_   s      r   test_close_on_errorrt  Q  s   " " " " " " " " 
wf	-	-	- < <YY 	<&.. <''..yy{{;;;< < < < < < < < < < < < < < <	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	< 	<< < < < < < < < < < < < < < < < < <sX   B,B#A=1B=BBBBB,B	B,B	B,,B03B0r   c                 ~    t                      5 }t          j        | |           d d d            d S # 1 swxY w Y   d S r   )r   r   dump)r   r   s     r   test_pickle_readerrw  ]  s      
 $fFF###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $s   266)Dr   rA  rf  	functoolsr   r   r   r   r   r  r"   pathlibr   r   rW   rD   pandas.compatr   pandas.util._test_decoratorsutil_test_decoratorsr   pandasr   pandas._testing_testingrF   pandas.io.commoncommonr    r
   r   r   py.pathr   r6   rs  ImportErrorr   r5   dirname__file__r   r   fixturer  r  r=  r   r   rB  rG  rL  r_  rc  rh  rj  rt  r   r  r   r  r   r  r  r  r  rw  r   r   r   <module>r     s                    
  				          - - - - - - ) ) ) ) ) ) ) ) )                           <&
	******i     	 	 	D	 
wrwx0011Q0 Q0 Q0 Q0 Q0 Q0 Q0 Q0h
 : : :LO LO LO LO LO LO LO LO^E E E dG_55E6?33( ( 43 65(
( 
( 
( 	#CD	3?@ 5 5 5 *,G,G,GHHE6?330 0 43 IH0B5 5 5) ) ); ; ;	< 	< 	< 









 $ $ $ $ $s   *B BB