o
    ҷh                     @   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e rpdndddd Zeje rdndd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#d0e$d.d/gZ%eje%d1d d2d3d4 Z&eje%d2d5d6 Z'ejd7ej#d8e$d8d/gd2d9d: Z(dS );    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   K/var/www/html/venv/lib/python3.10/site-packages/pandas/tests/io/conftest.py
<dictcomp>   s    z,compression_to_extension.<locals>.<dictcomp>)icom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   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   s:   t  rd}n| dkrdn| d} d|  d}dd|iiS )	Nzhttp://localhost:5000/master5gwzhttp://127.0.0.1:555/client_kwargsendpoint_url)r   lstrip)	worker_idurlr   r   r   s3so5   s
   r0   functionsession)scopec                  c   s8    t j } | V  W d    d S 1 sw   Y  d S N)pytestMonkeyPatchcontext)mpr   r   r   monkeysession?   s   "r9   c              	   c   sR   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 jd
dd t d | dkrFdn| d} d|  }d| d}t	j
td| t	jt	jd9}d}|dkrz||}|jrxW nW n	 ty   Y nw |d8 }td |dksm|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
    s3fsboto3AWS_ACCESS_KEY_ID
foobar_keyAWS_SECRET_ACCESS_KEYfoobar_secretzOS3 tests do not have a corresponding service in Windows, macOS or ARM platformszhttp://localhost:5000requestsmotoz1.3.14)
minversionflaskr'   r(   r)   555zhttp://127.0.0.1:r*   zmoto_server s3 -p )stdoutstderr   r   g?N)r5   importorskipsetenvr   r   r   r   skipr-   
subprocessPopenshlexsplitDEVNULLgetok	Exceptiontimesleep	terminate)r.   r9   r@   endpoint_portendpoint_uriproctimeoutrr   r   r   s3_baseE   sN   









"r[   c                 C   s   dd l }|jd| d}|S )Nr   s3)r,   )r;   resource)r[   r;   r\   r   r   r   s3_resource   s   r^   c                 c   s:    |  dt  }|  |V  |j  |  d S )Nzpandas-test-Bucketuuiduuid4createobjectsdeleter^   bucketr   r   r   s3_public_bucket   s   
rh   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)KeyBodyNopen
put_object)	rh   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)ACLr_   rf   r   r   r   s3_private_bucket   s   
r{   c           	   	   C   ri   rj   rp   )	r{   r   r   r"   r&   rs   rt   ru   rv   r   r   r   s3_private_bucket_with_data   rx   r|   )z.no_compressN) N)rk   gzip)z.GZr~   )rl   bz2)z.BZ2r   )z.zipzip)z.ZIPr   )z.xzxz)z.XZr   )z.zstzstd	zstandard)marks)z.ZSTr      )paramsc                 C      | j S r4   paramrequestr   r   r   compression_format   s   r   c                 C   s
   | j d S )Nr   r   r   r   r   r   compression_ext   s   
r   pythonpyarrowc                 C   r   )zb
    Parametrized fixture for pd.options.mode.string_storage.

    * 'python'
    * 'pyarrow'
    r   r   r   r   r   string_storage   s   r   ))rM   rK   rS   ra   r5   pandas.compatr   r   r   r   pandas.util._test_decoratorsutil_test_decoratorstdpandas.io.commonr   commonr   pandas.io.parsersr   fixturer   r   r   r    r"   r&   r0   r9   r[   r^   rh   rw   r{   r|   r   
skip_if_no_compression_formats_paramsr   r   r   r   r   r   r   <module>   sx    






	

=







