o
    d<                     @   sB  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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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#d&d' ZdS )(    N)is_ci_environmentis_platform_armis_platform_macis_platform_windowsread_csvc                 C      | ddddS )zPath to the tips datasetiodatacsvtips.csv datapathr   r   L/app/.heroku/python/lib/python3.10/site-packages/pandas/tests/io/conftest.py	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'   s   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   s3so,   s
   r#   session)scopec              
   c   s   t d t d t  tjdd tjdd t r4t s*t	 s*t
 r0t d ndV  nt d	}t jd
dd t d | dkrKdn| d} d|  }d| d}tjtd| tjtjd8}d}|dkrz||}|jr}W nW n	 ty   Y nw |d8 }td |dksr|V  |  W d   n 1 sw   Y  W d   dS W d   dS W d   dS 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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1.3.14)Z
minversionZflaskr   r   r   Z555zhttp://127.0.0.1:r   zmoto_server s3 -p )stdoutstderr   r   皙?N)pytestZimportorskiptmZ!ensure_safe_environment_variablesosenviron
setdefaultr   r   r   r   skipr    
subprocessPopenshlexsplitDEVNULLgetok	Exceptiontimesleep	terminate)r!   r(   Zendpoint_portZendpoint_uriproctimeoutrr   r   r   s3_base6   s^   









"rA   c                 #   s   ddl }ddl}d|fd|fd|d fd|d fd	|fd
|fg fdd}d}|jd| d}|jd| d z j|d W n	 tyI   Y nw z	 jddd W n	 ty\   Y nw d}	  d s||	dkr|td |	d8 }	  d s||	dksi|| |d |j	
  |V  |j	d| id}
z	|
j|dd W n	 ty   Y nw z	|
jddd W n	 ty   Y nw d}	  d r|	dkrtd |	d8 }	  d r|	dksdS dS dS dS )a0  
    Sets up S3 bucket with contents

    The primary bucket name is "pandas-test". The following datasets
    are loaded.

    - tips.csv
    - tips.csv.gz
    - tips.csv.bz2
    - items.jsonl

    A private bucket "cant_get_it" is also created. The boto3 s3 resource
    is yielded by the fixture.
    r   Nz
tips#1.csvr   ztips.csv.gz.gzztips.csv.bz2.bz2r   zsimple_dataset.featherc              	      sL   D ]!\}}t |d} j| ||d W d    n1 sw   Y  qd S )Nrb)BucketKeyZBody)openZ
put_object)Zbucket_nameZs3_key	file_namefcliZtest_s3_filesr   r   add_tips_files   s   z#s3_resource.<locals>.add_tips_fileszpandas-tests3)r   )rE   Zcant_get_itprivate)rE   ZACL   ZBucketsr,   r   )r   T)	recursive)r'   r&   resourceclientZcreate_bucketr:   Zlist_bucketsr;   r<   ZS3FileSystemZclear_instance_cacheZrm)rA   r   r   r   r'   r&   rL   Zbucketconnr?   rM   r   rJ   r   s3_resourceu   sb   

	


$rT   )z.no_compressN) N)rB   gzip)z.GZrV   )rC   bz2)z.BZ2rW   )z.zipzip)z.ZIPrX   )z.xzxz)z.XZrY   )z.zstzstdZ	zstandard)Zmarks)z.ZSTrZ      )paramsc                 C   s   | j S )Nparamrequestr   r   r   compression_format   s   ra   c                 C   s
   | j d S )Nr   r]   r_   r   r   r   compression_ext   s   
rb   ) r/   r5   r3   r;   r-   Zpandas.compatr   r   r   r   Zpandas.util._test_decoratorsutilZ_test_decoratorstdZpandas._testingZ_testingr.   Zpandas.io.parsersr   Zfixturer   r   r   r   r#   rA   rT   r^   Z
skip_if_noZ_compression_formats_paramsra   rb   r   r   r   r   <module>   sP    





	
>
I

