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
U
­ý°dÒã@sÄdZddlmZddlZddlmZddlZddlmZm    Z    m
Z
ddl m Z ddl mZddlmZddlmmmZejdd    gd
d „d d d„ƒZGdd„dƒZdd„Zdd„Zdd„ZdS)a
Tests that features that are currently unsupported in
either the Python or C parser are actually enforced
and are clearly communicated to the user.
 
Ultimately, the goal is to remove test cases from this
test suite as new feature support is added to the parsers.
é)ÚStringION)ÚPath)Úis_ci_environmentÚis_platform_macÚis_platform_windows)Ú ParserError)Úread_csvÚpythonz
python-fwfcCs|S©N©)Úvalr r ú^d:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/io/parser/test_unsupported.pyÚ<lambda>ór)ÚparamsÚidscCs|jSr
)Úparam)Úrequestr r r Ú python_enginesrc@s<eZdZdd„Zdd„Zdd„Zdd„Zd    d
„Zd d „Zd S)ÚTestUnsupportedFeaturesc
Cs>d}dD]0}tjtddtt|ƒ|ddW5QRXqdS)Nú a b c
1 2 3)Úcr    zunexpected keyword©ÚmatchT)ÚengineZmangle_dupe_cols)ÚpytestÚraisesÚ    TypeErrorrr)ÚselfÚdatarr r r Útest_mangle_dupe_cols_false"sz3TestUnsupportedFeatures.test_mangle_dupe_cols_falsec    CsXd}d}tjt|dtt|ƒddddW5QRXtjt|dtt|ƒdddW5QRXtjt|dtt|ƒdd    td
ƒd W5QRXtjt|dtt|ƒdd d W5QRXt tj    ¡tt|ƒdddW5QRXt tj    ¡tt|ƒddW5QRXt tj    ¡tt|ƒd    td
ƒdW5QRXt tj    ¡tt|ƒd dW5QRXd}d}tjt
|dtt|ƒddW5QRXtjt
|dtt|ƒdddW5QRXd}d}tjt|dtt|ƒddW5QRXtjt|dtt|ƒddW5QRXd}d}tjt|dtt|ƒddW5QRXdS)Nrzdoes not supportrrF)rÚsepÚdelim_whitespacez\s)rr!ú    é€)rr!Ú    quotecharé)rÚ
skipfooter)r!r")r!)r!r%)r'a                      A       B       C       D        E
one two three   four
a   b   10.0032 5    -0.5109 -2.3358 -0.4645  0.05076  0.3640
a   q   20      4     0.4473  1.4152  0.2834  1.00661  0.1744
x   q   30      3    -0.6662 -0.5243 -0.3580  0.89145  2.5838zError tokenizing dataz\s+z)Only length-1 thousands markers supportedzA|B|C
1|2,334|5
10|13|10.
z,,)Z    thousandsÚz(Only length-1 line terminators supportedza,b,c~~1,2,3~~4,5,6z~~)Úlineterminator) rrÚ
ValueErrorrrÚchrÚtmÚassert_produces_warningÚparsersZ ParserWarningr)rrÚmsgÚtextr r r Ú test_c_engine*sD" z%TestUnsupportedFeatures.test_c_enginec
Cstddlm}d}|D]Z}dt|ƒ›dt|ƒ›d}|tƒi}tjt|dtt|ƒfd|i|—ŽW5QRXqdS)    Nr)Ú_python_unsupportedz*1,2,3,,
1,2,3,4,
1,2,3,4,5
1,2,,,
1,2,3,4,úThe z" option is not supported with the z enginerr)    Úpandas.io.parsers.readersr2ÚreprÚobjectrrr*rr)rrZpy_unsupportedrÚdefaultr/Úkwargsr r r Útest_python_engine^s ÿ
z*TestUnsupportedFeatures.test_python_enginec    CsDGdd„dƒ}d}d}tjt|dt||ƒ|dW5QRXdS)Nc@s2eZdZddœdd„Zdd„Zdd„Zd    d
„ZdS) zMTestUnsupportedFeatures.test_python_engine_file_no_iter.<locals>.NoNextBufferN)ÚreturncSs
||_dSr
©r)rZcsv_datar r r Ú__init__tszVTestUnsupportedFeatures.test_python_engine_file_no_iter.<locals>.NoNextBuffer.__init__cSs
|j ¡Sr
)rÚ__next__©rr r r r=wszVTestUnsupportedFeatures.test_python_engine_file_no_iter.<locals>.NoNextBuffer.__next__cSs|jSr
r;r>r r r ÚreadzszRTestUnsupportedFeatures.test_python_engine_file_no_iter.<locals>.NoNextBuffer.readcSs|jSr
r;r>r r r Úreadline}szVTestUnsupportedFeatures.test_python_engine_file_no_iter.<locals>.NoNextBuffer.readline)Ú__name__Ú
__module__Ú __qualname__r<r=r?r@r r r r Ú NoNextBufferssrDza
1zD'NoNextBuffer' object is not iterable|argument 1 must be an iteratorr)r)rrrr)rrrDrr/r r r Útest_python_engine_file_no_iterqs
 z7TestUnsupportedFeatures.test_python_engine_file_no_iterc
Cs¦ddlm}d}|D]Œ}dt|ƒ›d}|tƒi}ddh}|dkrLd    ||<n"||kr^d
||<n|d krnd ||<tjt|d tt|ƒfddi|—ŽW5QRXqdS)Nr)Ú_pyarrow_unsupportedzJ1,2,3,,
        1,2,3,4,
        1,2,3,4,5
        1,2,,,
        1,2,3,4,r3z2 option is not supported with the 'pyarrow' engineZwarn_bad_linesZerror_bad_linesÚdialectÚexcelTÚ on_bad_linesÚwarnrrÚpyarrow)    r4rFr5r6rrr*rr)rZpa_unsupportedrr7r/r8Zdefault_needs_boolr r r Útest_pyarrow_engine†s ÿ
 
 
z+TestUnsupportedFeatures.test_pyarrow_enginec    Cs^tdƒ}dd„}|}|jdkrLd}tjt|d|j||dW5QRXn|j||ddS)Nza,b
1,2cSs|Sr
r )Úxr r r r¢rzPTestUnsupportedFeatures.test_on_bad_lines_callable_python_only.<locals>.<lambda>r    z>on_bad_line can only be a callable function if engine='python'r)rI)rrrrr*r)rÚ all_parsersÚsioZbad_lines_funcÚparserr/r r r Ú&test_on_bad_lines_callable_python_onlyŸs
z>TestUnsupportedFeatures.test_on_bad_lines_callable_python_onlyN)    rArBrCr r1r9rErLrQr r r r r!s 4rc Cs¶|}t}|jdkr@t d¡}|jj}tƒr@tƒs6tƒr@t     d¡t
  d¡b}t |ƒ  d¡t
 d¡4tj|dd|j|dd    dgd
W5QRXW5QRXt |¡W5QRXdS) NrKz:GH#45547 causing timeouts on windows/mac builds 2022-01-22ztest.csvzcol1,col2
a,b
1,2FZcol3rZcol1Zcol2)Zusecols)r*rrZ importorskipÚlibZ ArrowKeyErrorrrrÚskipr,Z ensure_cleanrÚ
write_textr-rrÚosÚunlink)rNrPÚerrorrKÚfnamer r r Ú)test_close_file_handle_on_invalid_usecols¬s
 
 
  (rYc    CsT|}|jdkr,|j tjj|j›dd¡tjtdd| g¡W5QRXdS)Nr    z engine supports lists.)ÚreasonZInvalidr)    rÚnodeZ
add_markerrÚmarkZxfailrr*r)rrNrPr r r Útest_invalid_file_inputsÁs
ÿr]c    Cs4|}d}tjt|d|jdddW5QRXdS)NzPdtype_backend numpy is invalid, only 'numpy_nullable' and 'pyarrow' are allowed.rÚtestÚnumpy)Z dtype_backend)rrr*r)rNrPr/r r r Útest_invalid_dtype_backendÍs
ÿr`)Ú__doc__ÚiorrUÚpathlibrrZ pandas.compatrrrZ pandas.errorsrZpandas._testingZ_testingr,Zpandas.io.parsersrr4r.ZreadersZfixturerrrYr]r`r r r r Ú<module>s