3
®yb]  ã               @   s  d dl Zd dlZd dlmZmZmZmZ d dlj	Z
d dlmZ eddgdejgddged	d
d�dœƒZejdd�jƒ Zejdd„ ƒZdd„ Zdd„ Zdd„ Zejdƒdd„ ƒZejdƒdd„ ƒZejjdddd gƒejdƒd!d"„ ƒƒZejdƒejdƒd#d$„ ƒƒZejd%ƒd&d'„ ƒZ dS )(é    N)Ú	DataFrameÚ
date_rangeÚread_csvÚread_parquet)Ú_test_decoratorsé   é   g       @ÚtÚsz
2018-06-18é   )Zperiods)ÚintÚfloatÚstrÚdtF)Úindexc              c   s(   t jdƒ} | jdƒ}|V  |jjƒ  d S )NÚfsspecZmemory)ÚpytestZimportorskipÚ
filesystemÚstoreÚclear)r   Zmemfs© r   ú?/tmp/pip-install-4cy230dp/pandas/pandas/tests/io/test_fsspec.pyÚ
cleared_fs   s    

r   c             C   s:   ddl m} |td�| jd< tddgd�}tjt|ƒ d S )Nr   )Ú
MemoryFile)Údataztest/test.csvzmemory://test/test.csvr   )Úparse_dates)Zfsspec.implementations.memoryr   Útextr   r   ÚtmÚassert_frame_equalÚdf1)r   r   Údf2r   r   r   Útest_read_csv   s    r!   c             C   sž   ddl m} ddlm} |jjƒ  tjtƒ� }t	dƒ dt
|jƒksHt‚W d Q R X d}| j|dd|d	œƒ tjtƒ� }t	d
ƒ |t
|jƒks�t‚W d Q R X d S )Nr   )Úregistry)Úknown_implementationsznosuchprotocol://test/test.csvZnosuchprotocolztest error messgaeZ
couldexistzunimportable.CouldExist)ÚclassÚerrzcouldexist://test/test.csv)r   r"   Zfsspec.registryr#   Útargetr   r   ÚraisesÚ
ValueErrorr   r   ÚvalueÚAssertionErrorÚsetitemÚImportError)Úmonkeypatchr   r"   r#   ÚeZerr_mgsr   r   r   Útest_reasonable_error'   s    
r/   c             C   s.   t jddd� tddgdd�}tjt |ƒ d S )Nzmemory://test/test.csvT)r   r   r   )r   Z	index_col)r   Úto_csvr   r   r   )r   r    r   r   r   Útest_to_csv:   s    r1   Úfastparquetc             C   s   t jddddd� dS )zCRegression test for writing to a not-yet-existent GCS Parquet file.zmemory://test/test.csvTr2   N)r   ÚengineÚcompression)r   Ú
to_parquet)r-   r   r   r   r   Útest_to_parquet_new_fileA   s    r6   Zs3fsc             C   s@   t jtdƒt|ƒƒ t jtdƒt|ƒƒ t jtdƒt|ƒƒ d S )Nzs3://pandas-test/tips.csvzs3://pandas-test/tips.csv.gzzs3://pandas-test/tips.csv.bz2)r   Úassert_equalr   )Ús3_resourceÚ	tips_filer   r   r   Útest_from_s3_csvI   s    r:   ÚprotocolZs3Zs3aZs3nc             C   s   t jtd| ƒt|ƒƒ d S )Nz%s://pandas-test/tips.csv)r   r7   r   )r8   r9   r;   r   r   r   Útest_s3_protocolsQ   s    r<   c             C   s2   d}t j|ddd d� t|dd�}tjt |ƒ d S )Nzs3://pandas-test/test.parquetFr2   )r   r3   r4   )r3   )r   r5   r   r   r7   )r8   Úfnr    r   r   r   Útest_s3_parquetY   s    r>   r   c           
   C   s4   t jtƒ� } tdƒ dt| jƒks&t‚W d Q R X d S )Nzmemory://test/test.csvzfsspec library is required)r   r'   r,   r   r   r)   r*   )r.   r   r   r   Útest_not_present_exceptionb   s    r?   )!ZnumpyÚnpr   Zpandasr   r   r   r   Zpandas._testingZ_testingr   Zpandas.utilr   ÚtdÚnanr   r0   Úencoder   Zfixturer   r!   r/   r1   Z
skip_if_nor6   r:   ÚmarkZparametrizer<   r>   Zskip_if_installedr?   r   r   r   r   Ú<module>   s*   
		