3
U้dฌ  ใ               @   sv   d Z ddlmZ ddlZddlmZ ddljZddl	jj
Z
ddl	mZ ejddgdd	 d
dd ZG dd dZdS )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)ฺParserError)ฺread_csvฺpythonz
python-fwfc             C   s   | S )Nฉ )ฺvalr   r   ๚[/var/www/html/virt/lib64/python3.6/site-packages/pandas/tests/io/parser/test_unsupported.pyฺ<lambda>   s    r	   )ฺparamsฺidsc             C   s   | j S )N)ฺparam)ฺrequestr   r   r   ฺpython_engine   s    r   c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
ฺTestUnsupportedFeaturesc             C   sF   d}d}x8dD ]0}t jt|d tt||dd W d Q R X qW d S )	Nza b c
1 2 3zis not supportedฺcr   )ฺmatchF)ฺengineZmangle_dupe_cols)r   r   )ฺpytestฺraisesฺ
ValueErrorr   r   )ฺselfฺdataฺmsgr   r   r   r   ฺtest_mangle_dupe_cols_false   s
    
z3TestUnsupportedFeatures.test_mangle_dupe_cols_falsec          _   C   sX  d}d}t jt|d tt|dd dd W d Q R X t jt|d tt|ddd W d Q R X t jt|d tt|dd	td
d W d Q R X t jt|d tt|ddd W d Q R X tjtj	 tt|d dd W d Q R X tjtj	 tt|dd W d Q R X tjtj	 tt|d	td
d W d Q R X tjtj	 tt|dd W d Q R X d}d}t jt
|d tt|dd W d Q R X t jt
|d tt|ddd W d Q R X d}d}t jt|d tt|dd W d Q R X t jt|d tt|dd W d Q R X d}d}t jt|d tt|dd W d Q R X d S )Nza b c
1 2 3zdoes not support)r   r   F)r   ฺsepฺdelim_whitespacez\s)r   r   ๚	้   )r   r   ฺ	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.5838zError tokenizing dataz\s+z)Only length-1 thousands markers supportedzA|B|C
1|2,334|5
10|13|10.
z,,)Z	thousandsฺ z(Only length-1 line terminators supportedza,b,c~~1,2,3~~4,5,6z~~)ฺlineterminator)r   r   r   r   r   ฺchrฺtmZassert_produces_warningฺparsersZParserWarningr   )r   r   r   ฺtextr   r   r   ฺtest_c_engine$   sD    " z%TestUnsupportedFeatures.test_c_enginec             C   sx   ddl m} d}xb|D ]Z}dt| dt| d}|t i}tjt|d tt|fd|i| W d Q R X qW d S )	Nr   )ฺ_python_unsupportedz*1,2,3,,
1,2,3,4,
1,2,3,4,5
1,2,,,
1,2,3,4,zThe z" option is not supported with the z engine)r   r   )	ฺpandas.io.parsersr(   ฺreprฺobjectr   r   r   r   r   )r   r   Zpy_unsupportedr   ฺdefaultr   ฺkwargsr   r   r   ฺtest_python_engineX   s    

z*TestUnsupportedFeatures.test_python_enginec             C   sD   G dd d}d}d}t jt|d t|||d W d Q R X d S )Nc               @   s$   e Zd Zdd Zdd Zdd ZdS )zMTestUnsupportedFeatures.test_python_engine_file_no_next.<locals>.NoNextBufferc             S   s
   || _ d S )N)r   )r   Zcsv_datar   r   r   ฺ__init__n   s    zVTestUnsupportedFeatures.test_python_engine_file_no_next.<locals>.NoNextBuffer.__init__c             S   s   | S )Nr   )r   r   r   r   ฺ__iter__q   s    zVTestUnsupportedFeatures.test_python_engine_file_no_next.<locals>.NoNextBuffer.__iter__c             S   s   | j S )N)r   )r   r   r   r   ฺreadt   s    zRTestUnsupportedFeatures.test_python_engine_file_no_next.<locals>.NoNextBuffer.readN)ฺ__name__ฺ
__module__ฺ__qualname__r/   r0   r1   r   r   r   r   ฺNoNextBufferm   s   r5   za
1z"The 'python' engine cannot iterate)r   )r   )r   r   r   r   )r   r   r5   r   r   r   r   r   ฺtest_python_engine_file_no_nextk   s
    
z7TestUnsupportedFeatures.test_python_engine_file_no_nextN)r2   r3   r4   r   r'   r.   r6   r   r   r   r   r      s   	4r   )ฺ__doc__ฺior   r   Zpandas.errorsr   Zpandas._testingZ_testingr$   r)   r%   r   Zfixturer   r   r   r   r   r   ฺ<module>   s   
