
    Owg              
          d dl mZmZ d dlZd dlmc mZ d dlZ	d dl
mZ d Zd Zej                  ej                   j"                  d               Zd Zd Zd Zd	 Zej                   j/                  d
d ej0                  d ej2                  d            g      ej                   j/                  dddg      ej                   j/                  dddg      d                      Zd Zy)    )BytesIOStringIONc                    t        j                  g dg dgddgg d      }t        j                         5 }|j	                  ||        t        j
                  |t        j                  ||              t        j                  ||       5 }|j                         j                  d      }t        |      }d d d        t        j
                  |t        j                               d d d        y # 1 sw Y   ;xY w# 1 sw Y   y xY w)	N)g~Ϛ?g9DܜJ?g>D)?)g.4i(@g33333@g̤AAB)XYZ)indexcolumnscompressionutf8)pd	DataFrametmensure_cleanto_jsonassert_frame_equal	read_jsondecompress_filereaddecoder   )r   dfpathfhresultdatas         \/var/www/horilla/myenv/lib/python3.12/site-packages/pandas/tests/io/json/test_compression.pytest_compression_roundtripr       s    		')GHCj
B 
	 6d


4[
1
b",,t"MN k2 	$bWWY%%f-FF#D	$ 	b",,t"456 6
	$ 	$6 6s$   AC=+C171C=1C:	6C==Dc                      | dddd      }t        j                  |      } | dddd      }t        j                  |d      }t        j                  ||       y )Niojsonr   ztsframe_v012.jsonztsframe_v012.json.zipzipr   )r   r   r   r   )datapathuncompressed_pathuncompressed_dfcompressed_pathcompressed_dfs        r   test_read_zipped_jsonr*       sT     vv7JKll#45OtVV5LMOLLeDM/=9    c                    t        j                  t        d            }t        j                         5 }|j                  ||        t        |d      5 }|j                  d|       d d d        d d d        t        j                  d|j                   d| |      }t        j                  ||       y # 1 sw Y   NxY w# 1 sw Y   RxY w)	N {"a": [1, 2, 3], "b": [4, 5, 6]}r   rbztest-1)KeyBodyzs3://z/test-1)r   storage_options)
r   r   r   r   r   r   open
put_objectnamer   )r   s3_public_buckets3sor   r   froundtripped_dfs          r   test_with_s3_urlr9   *   s     
hAB	CB		 >d


4[
1$ 	>''H1'=	>>
 ll
 %%&g.O
 "o.	> 	>> >s#    C B4'C 4B=	9C  C	c                    t        j                         5 }t        j                  t	        d            }|j                  |dd|        t        j                  |d|       }t        j                  ||       d d d        y # 1 sw Y   y xY w)Nr-   recordsTorientlinesr   )r>   r   )r   r   r   r   r   r   r   )r   r   r   r8   s       r   test_lines_with_compressionr?   =   sm    		 3d\\(#EFG


4	;
O,,t4[Q
b/2	3 3 3s   A"B  B	c                 n   t        j                         5 }t        j                  t	        d            }|j                  |dd|        t        j                  |dd|       5 }t        j                  |      }d d d        t        j                  |       d d d        y # 1 sw Y   (xY w# 1 sw Y   y xY w)Nz,{"a": ["foo", "bar", "baz"], "b": [4, 5, 6]}r;   Tr<      )r>   	chunksizer   )r   r   r   r   r   r   concatr   )r   r   r   resr8   s        r   test_chunksize_with_compressionrE   E   s    		 3d\\(#QRS


4	;
O\\{
 	- iinO	- 	b/23 3	- 	-	3 3s$   AB+"B8B+B(	$B++B4c                     t        j                  t        d            } t        j                         5 }d}t        j                  t        |      5  | j                  |d       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr-   *Unrecognized compression type: unsupportedmatchunsupportedr   )	r   r   r   r   r   pytestraises
ValueErrorr   )r   r   msgs      r   'test_write_unsupported_compression_typerO   Q   st    	hAB	CB		 8d:]]:S1 	8JJtJ7	88 8	8 	88 8s#   BA6%B6A?	;BBc                      t        j                         5 } d}t        j                  t        |      5  t        j                  | d       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)NrG   rH   rJ   r   )r   r   rK   rL   rM   r   r   )r   rN   s     r   &test_read_unsupported_compression_typerQ   Y   s^    		 :d:]]:S1 	:LL=9	:: :	: 	:: :s"   A(AA(A%	!A((A1infer_stringFTpyarrow)marksto_infer
read_inferc                    t        j                  d|      5  | }d}|||   z  }t        j                  ddgi      }|rdn|}|rdn|}	t        j                  |      5 }
|j                  |
|       t        j                  |
|	      }t        j                  ||       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nzfuture.infer_stringztest.r   rA   inferr   )r   option_contextr   r   r   r   r   r   )compression_onlyrV   rU   compression_to_extensionrR   r   filenamer   to_compressionread_compressionr   r   s               r   test_to_json_compressionr_   `   s     
		0,	? .& ,[99\\3*%$,+&07k__X& 	.$JJtJ8\\$4DEF!!&"-	.. .	. 	.. .s%   AB;AB/B;/B8	4B;;Cc                     t        j                  ddgi      }t               5 }|j                  ||        d d d        y # 1 sw Y   y xY w)Nr   rA   r   )r   r   r   r   )r   expectedbuffers      r   test_to_json_compression_moderc   {   sE    ||S1#J'H	 :f[9: : :s   A  A	)r"   r   r   rK   pandas.util._test_decoratorsutil_test_decoratorstdpandasr   pandas._testing_testingr   r    r*   skip_if_not_us_localemark
single_cpur9   r?   rE   rO   rQ   parametrizeparam
skip_if_nor_   rc    r+   r   <module>rr      s   
  ) )  6$: /  /"3	38: ULFLL]R]]95MNO dE]3e}5. 6 4
.,:r+   