
    I jI                         S r SSKJr  SSKrSSKJr  SSKrSSKJr  SSK	J
r  SSKJr  SSKJs  Js  Jr  \R"                  R%                  S5      r\R(                  " SS	/S
 S9S 5       r " S S5      rS rS rS rg)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)ParserError)read_csvz=ignore:Passing a BlockManager to DataFrame:DeprecationWarningpythonz
python-fwfc                     U $ N )vals    x/root/GenerationalWealth/GenerationalWealth/venv/lib/python3.13/site-packages/pandas/tests/io/parser/test_unsupported.py<lambda>r      s        )paramsidsc                     U R                   $ r	   )param)requests    r   python_enginer      s    ==r   c                   8    \ rS rSrS rS rS rS rS rS r	Sr
g	)
TestUnsupportedFeatures!   c                     SnS H9  n[         R                  " [        SS9   [        [	        U5      USS9  S S S 5        M;     g ! , (       d  f       MM  = f)Na b c
1 2 3)cr   zunexpected keywordmatchT)enginemangle_dupe_cols)pytestraises	TypeErrorr   r   )selfdatar   s      r   test_mangle_dupe_cols_false3TestUnsupportedFeatures.test_mangle_dupe_cols_false"   s@    %Fy0DE$N FE &EEs   A
A	c           	         SnSn[         R                  " [        US9   [        [	        U5      SSS9  S S S 5        [         R                  " [        US9   [        [	        U5      SS[        S5      S	9  S S S 5        [         R                  " [        US9   [        [	        U5      SS
S9  S S S 5        [        R                  " [        R                  5         [        [	        U5      SS9  S S S 5        [        R                  " [        R                  5         [        [	        U5      S[        S5      S9  S S S 5        [        R                  " [        R                  5         [        [	        U5      S
S9  S S S 5        SnSn[         R                  " [        US9   [        [	        U5      SS9  S S S 5        [         R                  " [        US9   [        [	        U5      SSS9  S S S 5        SnSn[         R                  " [        US9   [        [	        U5      SS9  S S S 5        [         R                  " [        US9   [        [	        U5      SS9  S S S 5        SnSn[         R                  " [        US9   [        [	        U5      SS9  S S S 5        g ! , (       d  f       GNf= f! , (       d  f       GN8= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GNY= f! , (       d  f       GN5= f! , (       d  f       GN= f! , (       d  f       N= f! , (       d  f       g = f)Nr   zdoes not supportr   r   z\s)r   sep	   )r   r'   	quotechar   )r   
skipfooter)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.5838zError tokenizing dataz\s+z)Only length-1 thousands markers supportedzA|B|C
1|2,334|5
10|13|10.
z,,)	thousands z(Only length-1 line terminators supportedza,b,c~~1,2,3~~4,5,6z~~)lineterminator)r   r    
ValueErrorr   r   chrtmassert_produces_warningparsersParserWarningr   )r"   r#   msgtexts       r   test_c_engine%TestUnsupportedFeatures.test_c_engine*   s'     ]]:S1Xd^CU; 2]]:S1Xd^CTSXN 2]]:S1Xd^CA> 2 ''(=(=>Xd^/ ?''(=(=>Xd^SB ?''(=(=>Xd^2 ?A
 &]];c2Xd^0 3]];c2Xd^CV< 3 : ]]:S1Xd^t4 2]]:S1Xd^r2 2 9$]]:S1Xd^D9 21O 211111 ?>>>>> 3222 2111
 21s   JJ$J6KKK,K>LL"<L45M
J!$
J36
K
K
K),
K;>
L
L"
L14
M
Mc                     SSK Jn  SnU HS  nSU< SU< S3nU[        5       0n[        R                  " [
        US9   [        [        U5      4SU0UD6  S S S 5        MU     g ! , (       d  f       Mg  = f)	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 enginer   r   )pandas.io.parsers.readersr;   objectr   r    r0   r   r   )r"   r   py_unsupportedr#   defaultr6   kwargss          r   test_python_engine*TestUnsupportedFeatures.test_python_engineZ   sy    S &Gwk "&&3%6g? 
 vx(Fz5$HHH 65 & 65s   A##
A2	c                      " S S5      nSnSn[         R                  " [        US9   [        U" U5      US9  S S S 5        g ! , (       d  f       g = f)Nc                   0    \ rS rSrSS jrS rS rS rSrg)	MTestUnsupportedFeatures.test_python_engine_file_no_iter.<locals>.NoNextBuffero   Nc                     Xl         g r	   r#   )r"   csv_datas     r   __init__VTestUnsupportedFeatures.test_python_engine_file_no_iter.<locals>.NoNextBuffer.__init__p   s    $	r   c                 6    U R                   R                  5       $ r	   )r#   __next__r"   s    r   rN   VTestUnsupportedFeatures.test_python_engine_file_no_iter.<locals>.NoNextBuffer.__next__s   s    yy))++r   c                     U R                   $ r	   rI   rO   s    r   readRTestUnsupportedFeatures.test_python_engine_file_no_iter.<locals>.NoNextBuffer.readv       yy r   c                     U R                   $ r	   rI   rO   s    r   readlineVTestUnsupportedFeatures.test_python_engine_file_no_iter.<locals>.NoNextBuffer.readliney   rT   r   rI   )returnN)	__name__
__module____qualname____firstlineno__rK   rN   rR   rV   __static_attributes__r
   r   r   NoNextBufferrF   o   s    %,!!r   r^   za
1zD'NoNextBuffer' object is not iterable|argument 1 must be an iteratorr   )r   )r   r    r!   r   )r"   r   r^   r#   r6   s        r   test_python_engine_file_no_iter7TestUnsupportedFeatures.test_python_engine_file_no_iterm   sA    	! 	! T]]9C0\$'> 100s   A
Ac                 (   SSK Jn  SnU Hr  nSU< S3nU[        5       0nSS1nUS:X  a  S	XS'   OX6;   a  S
XS'   O
US:X  a  SXS'   [        R                  " [
        US9   [        [        U5      4SS0UD6  S S S 5        Mt     g ! , (       d  f       M  = f)Nr   )_pyarrow_unsupportedzJ1,2,3,,
        1,2,3,4,
        1,2,3,4,5
        1,2,,,
        1,2,3,4,r<   z2 option is not supported with the 'pyarrow' enginewarn_bad_lineserror_bad_linesdialectexcelTon_bad_lineswarnr   r   pyarrow)r=   rb   r>   r   r    r0   r   r   )r"   pa_unsupportedr#   r@   r6   rA   default_needs_bools          r   test_pyarrow_engine+TestUnsupportedFeatures.test_pyarrow_engine   s    T &G#UVCvx(F"24E!F)#")."&N*"(z5$D	DVD 65 & 65s   B
B	c                     [        S5      nS nUnUR                  S;  a4  Sn[        R                  " [        US9   UR                  X#S9  S S S 5        g UR                  X#S9  g ! , (       d  f       g = f)Nza,b
1,2c                     U $ r	   r
   )xs    r   r   VTestUnsupportedFeatures.test_on_bad_lines_callable_python_or_pyarrow.<locals>.<lambda>   s    1r   )r   ri   zKon_bad_line can only be a callable function if engine='python' or 'pyarrow'r   )rg   )r   r   r   r    r0   r   )r"   all_parserssiobad_lines_funcparserr6   s         r   ,test_on_bad_lines_callable_python_or_pyarrowDTestUnsupportedFeatures.test_on_bad_lines_callable_python_or_pyarrow   sp     z"$%::;  z5A 65 OOCO= 65s   A%%
A3r
   N)rY   rZ   r[   r\   r$   r8   rB   r_   rl   rv   r]   r
   r   r   r   r   !   s$    O.:`I&?*E.>r   r   c                    U n[         nUR                  S:X  a  [        R                  " SS9  Un[	        U5      R                  SSS9  [        R                  " S5         [        R                  " USS	9   UR                  U/ S
QS9  S S S 5        S S S 5        [        R                  " U5        g ! , (       d  f       N-= f! , (       d  f       N6= f)Nri   z,https://github.com/apache/arrow/issues/38676reasonzcol1,col2
a,b
1,2zutf-8)encodingFcol3r   )col1col2r|   )usecols)r0   r   r   skipr   
write_textr2   r3   r    r   osunlink)rr   	temp_fileru   errorfnames        r   )test_close_file_handle_on_invalid_usecolsr      s    FE}}	!IJEK07C		#	#E	*]]5/OOE+COD 0 
+ IIe 0/ 
+	*s$   B?4B.B?.
B<	8B??
Cc                 "   UnUR                   S:X  a9  U R                  [        R                  R	                  UR                    S3S95        [        R
                  " [        SS9   UR                  / 5        S S S 5        g ! , (       d  f       g = f)Nr   z engine supports lists.ry   Invalidr   )r   applymarkerr   markxfailr    r0   r   )r   rr   ru   s      r   test_invalid_file_inputsr      sj    F}} KK6M%NO	
 
z	3 
4	3	3s   %B  
Bc                     U nSn[         R                  " [        US9   UR                  SSS9  S S S 5        g ! , (       d  f       g = f)NzPdtype_backend numpy is invalid, only 'numpy_nullable' and 'pyarrow' are allowed.r   testnumpy)dtype_backend)r   r    r0   r   )rr   ru   r6   s      r   test_invalid_dtype_backendr      s=    F	!  
z	-g6 
.	-	-s	   8
A)__doc__ior   r   pathlibr   r   pandas.errorsr   pandas._testing_testingr2   pandas.io.parsersr   r=   r4   readersr   filterwarnings
pytestmarkfixturer   r   r   r   r   r
   r   r   <module>r      s     	   %  & + +[[''C

 ,/_E FF> F>R$	7r   