1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
U
­ý°dÚ.ã@sødZddlmZmZddlZddlZddlmZddlZddl    Z    ddl
m Z m Z ddl mmZddlmZddlmZe    j d¡Ze    jjejdd    d
d d „ƒƒZe    jjd d„ƒZdd„Zdd„Zdd„Zej dd„ƒZ!e    jj"ddiedddggdddgddfd d!d"iedddggdddgddfd#iedddggdddgddfd$d!d"iedddggdddgddfd%d&d'giedddggdddgddfd d"d(d)œedddggdddgddfdd*d(ied+ddgd,ddggdddgddfd#d*d(iedddgdddggdddgddfd-d.d/idd0fd1d.d/idd2fd3d.d/idd2fg d4d5d6d7d8d5d9d:d;d<d=g d>d?d@„ƒZ#dAdB„Z$dCdD„Z%dEdF„Z&dGdH„Z'dIdJ„Z(dKdL„Z)dMdN„Z*dOdP„Z+e    j "dQeeg¡e    j "dRddSg¡dTdU„ƒƒZ,dVdW„Z-dXdY„Z.dZd[„Z/d\d]„Z0d^d_„Z1dS)`zy
Tests that work on both the Python and C engines but do not have a
specific classification into the other test modules.
é)ÚBytesIOÚStringION)ÚURLError)ÚEmptyDataErrorÚ ParserError)Ú    DataFrameZ pyarrow_skipúahttps://raw.githubusercontent.com/pandas-dev/pandas/main/pandas/tests/io/parser/data/salaries.csvT)ÚurlZcheck_before_testcCsJ|}ddi}d}|j|f|Ž}tj |d¡}|j|f|Ž}t ||¡dS)NÚsepú    rú salaries.csv)Úread_csvÚosÚpathÚjoinÚtmÚassert_frame_equal)Ú all_parsersÚ csv_dir_pathÚparserÚkwargsr    Ú
url_resultÚ
local_pathÚ local_result©rúid:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/io/parser/common/test_file_buffer_url.pyÚtest_urls    ÿrc
Cs€|}ddi}tj |d¡}|j|f|Ž}d|}z|j|f|Ž}t ||¡Wn,tk
rzt dd t     
¡¡¡YnXdS)Nr
r r zfile://localhost/z Failing on: ú ) rrrr rrrÚpytestÚskipÚplatformÚuname)rrrrrrr    rrrrÚtest_local_file5sr"cs2|‰t ¡}t |j‡fdd„¡}t ||¡dS)Ncsˆj|ddS©Nr)Z    index_col©r ©Úp©rrrÚ<lambda>Ióz$test_path_path_lib.<locals>.<lambda>)rÚ makeDataFrameZround_trip_pathlibÚto_csvr©rZdfÚresultrr'rÚtest_path_path_libFsr.cs2|‰t ¡}t |j‡fdd„¡}t ||¡dS)Ncsˆj|ddSr#r$r%r'rrr(Qr)z&test_path_local_path.<locals>.<lambda>)rr*Zround_trip_localpathr+rr,rr'rÚtest_path_local_pathMs
ÿr/c    CsN|}t ¡›d}d}tjt|d}| |¡W5QRX||jjksJt‚dS)Nz.csvz \[Errno 2\]©Úmatch)    ÚuuidÚuuid4rÚraisesÚFileNotFoundErrorr ÚvalueÚfilenameÚAssertionError)rrrÚmsgÚerrrÚtest_nonexistent_pathVs r;c
Cs˜|}d}t ¡~}t |d¡z"t|ƒW5QRXt d¡Wntk
rTYnXtjt|d}|     |¡W5QRX||j
j ksŠt ‚W5QRXdS)Nz \[Errno 13\]rzRunning as sudo.r0) rÚ ensure_cleanrÚchmodÚopenrrÚPermissionErrorr4r r6r7r8)rrr9rr:rrrÚtest_no_permissioncs
 
 
r@zdata,kwargs,expected,msgz a,b,c
4,5,6
 éééÚaÚbÚc©Úcolumnsza,b,c
4,5,6
#commentÚcommentú#z a,b,c
4,5,6
za,b,c
4,5,6#commentza,b,c
4,5,6
skipmeZskiprowséF)rIÚskip_blank_linesrLÚ4rz a,b,c
4,5,6
escapecharú\z9(EOF following escape character)|(unexpected end of data)za,b,c
4,5,6
"\z>(EOF inside string starting at row 2)|(unexpected end of data)z a,b,c
4,5,6
"zwhitespace-linezeat-line-commentz eat-crnl-nopz eat-commentz    skip-linezin-fieldzeat-crnlz escaped-charzescape-in-quoted-fieldzin-quoted-field)Úidsc    Cs\|}|dkr:tjt|d|jt|ƒf|ŽW5QRXn|jt|ƒf|Ž}t ||¡dS)Nr0)rr4rr rrr)rÚdatarÚexpectedr9rr-rrrÚtest_eof_statesys arSc    Csl|}d}tjdddL}| |¡| ¡| d¡|j|ddd}tddggƒ}t ||¡W5QRXdS)Nz0 0zw+T)ÚmodeZreturn_filelikerz\s+)r
Úheader)rr<ÚwriteÚflushÚseekr rr)rrrQZnew_filer-rRrrrÚtest_temporary_fileäs
 
rYcCs<|}d}tddggddgd}| t|ƒ¡}t ||¡dS)Nza,b
1,2z1rKrDrErG)rr rrr)rrrQrRr-rrrÚtest_internal_eof_byteôs
rZc
Cs~|}d}tddggddgd}dt ¡›d}t |¡<}t|d    ƒ}| |¡W5QRX| |¡}t ||¡W5QRXdS)
Nsc1,c2
"test     test", test
ztest     testz testZc1Úc2rGÚ__z__.csvÚwb)    rr2r3rr<r>rVr r)rrrQrRrÚfr-rrrÚtest_internal_eof_byte_to_fileþs  
r_cCs(|}d}t|ƒ}| |¡|jr$t‚dS)Núa,b
1,2)rr Úclosedr8)rrrQÚfhrrrÚtest_file_handle_string_io s
 
rcc
Cs<|}dD].}t||ƒ}| |¡|jr,t‚W5QRXqdS)N)ÚrÚrb)r>r rar8)rZcsv1rrTr^rrrÚtest_file_handles_with_opens
 
rfc    Cs@Gdd„dƒ}|}d}tjt|d| |ƒ¡W5QRXdS)Nc@s eZdZdS)z5test_invalid_file_buffer_class.<locals>.InvalidBufferN©Ú__name__Ú
__module__Ú __qualname__rrrrÚ InvalidBuffer'srkú'Invalid file path or buffer object typer0©rr4Ú
ValueErrorr )rrkrr9rrrÚtest_invalid_file_buffer_class%s
roc    Cs@|}d}Gdd„dƒ}tjt|d| |ƒ¡W5QRXdS)Nrlc@s eZdZdS)z*test_invalid_file_buffer_mock.<locals>.FooNrgrrrrÚFoo6srpr0rm)rrr9rprrrÚtest_invalid_file_buffer_mock1s
rqcCsDGdd„dtƒ}d}|}tddgiƒ}| ||ƒ¡}t ||¡dS)Nc@seZdZdd„Zddd„ZdS)z>test_valid_file_buffer_seems_invalid.<locals>.NoSeekTellBuffercSs tdƒ‚dS)NzNo tell method©ÚAttributeError)ÚselfrrrÚtellEszCtest_valid_file_buffer_seems_invalid.<locals>.NoSeekTellBuffer.tellrcSs tdƒ‚dS)NzNo seek methodrr)rtÚposÚwhencerrrrXHszCtest_valid_file_buffer_seems_invalid.<locals>.NoSeekTellBuffer.seekN)r)rhrirjrurXrrrrÚNoSeekTellBufferDsrxza
1rDé)rrr rr)rrxrQrrRr-rrrÚ$test_valid_file_buffer_seems_invalid=s rzÚio_classÚencodingúutf-8cCsX|}tdgdgdœƒ}d}||tkr.| d¡n|ƒ}t |j||d|¡|jrTt‚dS)zX
    Test whether read_csv does not close user-provided file handles.
 
    GH 36980
    ryrK©rDrEr`r})r|N)rrÚencoderrr rar8)rr{r|rrRÚcontentÚhandlerrrÚtest_read_csv_file_handleSs r‚c    CsV|}tdgdgdœƒ}t ¡.}|j|d|dt |j|d|d|¡W5QRXdS)    z@
    Support memory map for compressed files.
 
    GH 37621
    ryrKr~F)ÚindexÚ compressionT)Ú
memory_mapr„N)rrr<r+rr )rr„rrRrrrrÚtest_memory_map_compressiones
þr†c    Csz|}|ddddƒ}|j|dd}|jjjr.t‚z$|t|ƒdsFt‚W5QRXWn"tk
rt|jjjspt‚YnXdS©NÚiorQÚcsvziris.csvry)Ú    chunksizeF)r Úhandlesrrar8Únext©rÚdatapathrrÚreaderrrrÚtest_context_managerwsrc
CsŠ|}t|ddddƒƒj}|j|dd}|jjjr4t‚z$|t|ƒdsLt‚W5QRXWn"tk
rz|jjjrvt‚YnXW5QRXdSr‡)r>r r‹rrar8rŒrrrrÚ#test_context_manageri_user_provided‡sr‘c
Cs@|}t ¡*}tjtdd| |¡W5QRXW5QRXdS)NzNo columns to parse from filer0)rr<rr4rr )rZusing_copy_on_writerrrrrÚtest_file_descriptor_leak–s
r’cCsRtj |d¡}|}tdddgdddgdd    d
gd œƒ}|j|d d }t ||¡dS)Nz test_mmap.csvryrKéZoneZtwoZthreeÚIZIIZIII)rDrErFT)r…)rrrrr rr)rrZ    mmap_filerrRr-rrrÚtest_memory_mapžsÿr•)2Ú__doc__rˆrrrr Ú urllib.errorrr2rZ pandas.errorsrrZpandas.util._test_decoratorsÚutilZ_test_decoratorsÚtdZpandasrZpandas._testingZ_testingrÚmarkZ usefixturesZ
pytestmarkÚnetworkrZslowr"r.r/r;Zskip_if_windowsr@Z parametrizerSrYrZr_rcrfrorqrzr‚r†rr‘r’r•rrrrÚ<module>sà    û 
     
üüüüüü ü üüüü¸Põ¯_