o
    թZh                     @   s  d dl Z d dlZd dlZd dlZd dlZd dlmZmZmZm	Z	 d dl
m  mZ d dlm  mZ d dlmZ ejdd Zejdd Zejdd	 Zejd
d Zejdd Zejdd Zejdd Zejdd Zejdd Zejdd Zejdd Zejdd Z ejdd Z!ddd d!d"d#d$d%d&d'ej"d(e#d)d*ej"d+e#d)d*gZ$eje$d,d d-d.d/ Z%eje$d-d0d1 Z&ejd2ej"d3e#d3d*gd-d4d5 Z'dS )6    N)is_ci_environmentis_platform_armis_platform_macis_platform_windowsread_csvc                   C   s   dd t j D S )Nc                 S   s   i | ]\}}||qS  r   ).0keyvaluer   r   O/var/www/html/lang_env/lib/python3.10/site-packages/pandas/tests/io/conftest.py
<dictcomp>   s    z,compression_to_extension.<locals>.<dictcomp>)icomZextension_to_compressionitemsr   r   r   r   compression_to_extension   s   r   c                 C      | ddddS )zPath to the tips datasetiodatacsvtips.csvr   datapathr   r   r   	tips_file      r   c                 C   r   )zPath to a JSONL datasetr   parserr   items.jsonlr   r   r   r   r   
jsonl_file   r   r   c                 C   s   t | ddddddS )z#DataFrame with the salaries datasetr   r   r   zsalaries.csv	)sepr   r   r   r   r   salaries_table%   s   r   c                 C   r   )Nr   r   Zfeatherzfeather-0_3_1.featherr   r   r   r   r   feather_file+      r    c                 C   r   )Nr   r   xml	books.xmlr   r   r   r   r   xml_file0   r!   r$   c              	   c   sN   t d t d |dd |dd t r/t s#t s#t r*t d dS dV  dS t d	}t d
 t d | dkrDdn| d} d|  }d| d}t	j
td| t	jt	jd9}d}|dkrz||}|jrvW nW n	 ty   Y nw |d8 }td |dksk|V  |  W d   dS 1 sw   Y  dS )z
    Fixture for mocking S3 interaction.

    Sets up moto server in separate process locally
    Return url for motoserver/moto CI service
    Zs3fsboto3ZAWS_ACCESS_KEY_IDZ
foobar_keyZAWS_SECRET_ACCESS_KEYZfoobar_secretzOS3 tests do not have a corresponding service in Windows, macOS or ARM platformszhttp://localhost:5000requestsZmotoZflaskZmaster5ZgwZ555zhttp://127.0.0.1:/zmoto_server s3 -p )stdoutstderr   r   g?N)pytestZimportorskipZsetenvr   r   r   r   skiplstrip
subprocessPopenshlexsplitDEVNULLgetok	Exceptiontimesleep	terminate)Z	worker_idZmonkeypatchr&   Zendpoint_portZendpoint_uriproctimeoutrr   r   r   s3_base5   sN   










"r=   c                 C   s   dd| iiS )NZclient_kwargsendpoint_urlr   )r=   r   r   r   s3sot   s   r?   c                 C   s   dd l }|jd| d}|S )Nr   s3)r>   )r%   resource)r=   r%   r@   r   r   r   s3_resourcey   s   rB   c                 c   s:    |  dt  }|  |V  |j  |  d S )Nzpandas-test-ZBucketuuiduuid4createobjectsdeleterB   Zbucketr   r   r   s3_public_bucket   s   
rJ   c           	   	   C      d|fd|fd|d fd|d fd|fd|fd	|fg}|D ] \}}t |d
}| j||d W d   n1 s8w   Y  q| S zw
    The following datasets
    are loaded.

    - tips.csv
    - tips.csv.gz
    - tips.csv.bz2
    - items.jsonl
    z
tips#1.csvr   ztips.csv.gz.gzztips.csv.bz2.bz2r   zsimple_dataset.featherr#   rb)KeyZBodyNopenZ
put_object)	rJ   r   r   r    r$   test_s3_filess3_key	file_namefr   r   r   s3_public_bucket_with_data      

	rW   c                 c   s>    |  dt  }|jdd |V  |j  |  d S )Nzcant_get_it-private)ZACLrC   rI   r   r   r   s3_private_bucket   s   
rZ   c           	   	   C   rK   rL   rQ   )	rZ   r   r   r    r$   rS   rT   rU   rV   r   r   r   s3_private_bucket_with_data   rX   r[   )z.no_compressN) N)rM   gzip)z.GZr]   )rN   bz2)z.BZ2r^   )z.zipzip)z.ZIPr_   )z.xzxz)z.XZr`   )z.zstzstdZ	zstandard)Zmarks)z.ZSTra      )paramsc                 C      | j S )Nparamrequestr   r   r   compression_format   s   ri   c                 C   s
   | j d S )Nr   re   rg   r   r   r   compression_ext   s   
rj   pythonZpyarrowc                 C   rd   )zb
    Parametrized fixture for pd.options.mode.string_storage.

    * 'python'
    * 'pyarrow'
    re   rg   r   r   r   string_storage   s   rl   )(r1   r/   r7   rD   r,   Zpandas.compatr   r   r   r   Zpandas.util._test_decoratorsutilZ_test_decoratorstdZpandas.io.commonr   commonr   Zpandas.io.parsersr   Zfixturer   r   r   r   r    r$   r=   r?   rB   rJ   rW   rZ   r[   rf   Z
skip_if_noZ_compression_formats_paramsri   rj   rl   r   r   r   r   <module>   st    






>








