
    c%                         d dl mZmZ d dlZd dlZd dlmZ d dlmZm	Z	 d Z
d Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )    )absolute_importprint_functionN)
unpack_zip)with_directory_contentswith_tmp_zipfilec                  H    d } t          t          d          |            d S )Nc                 V   t           j                            |d          }g }t          | ||           g |k    sJ t           j                            |          sJ t          j        t           j                            |d          dd                                          dk    sJ d S Nboofoorutf-8hello world
ospathjoinr   isdircodecsopenreadzipname
workingdirtarget_patherrorss       Llib/python3.11/site-packages/anaconda_project/internal/test/test_ziputils.pydo_testz6test_unzip_single_file_different_name.<locals>.do_test       gll:u557K000V|w}}[))))){27<<U;;S'JJOOQQUddddddd    r   r   r   dictr   s    r   %test_unzip_single_file_different_namer%      s7    e e e To...88888r    c                  H    d } t          t          d          |            d S )Nc                    t           j                            |d          }g }t          | ||           g |k    sJ t           j                            |          sJ t          j        |dd                                          dk    sJ d S )Nr   r   r   r   )r   r   r   r   isfiler   r   r   r   s       r   r   z1test_unzip_single_file_same_name.<locals>.do_test   s    gll:u557K000V|w~~k*****{;W55::<<OOOOOOr    r   r!   r"   r$   s    r    test_unzip_single_file_same_namer)      s7    P P P To...88888r    c                  J    d } t          t          dd          |            d S )Nc                    t           j                            |d          }g }t          | ||           g |k    sJ t           j                            |          sJ t          j        t           j                            |d          dd                                          dk    sJ t          j        t           j                            |d          dd                                          dk    sJ d S Nr   r   r   r   r   bargoodbye world
r   r   s       r   r   z%test_unzip_two_files.<locals>.do_test*   s    gll:u557K000V|w}}[))))){27<<U;;S'JJOOQQUddddd{27<<U;;S'JJOOQQUfffffffr    r   r.   r   r-   r"   r$   s    r   test_unzip_two_filesr0   )   s:    g g g To3DEEEwOOOOOr    c                  0    d } t          ddi|            d S )Nc                    t           j                            |d          }g }t          | ||           g |k    sJ t           j                            |          sJ t           j                            t           j                            |d                    sJ t          j        t           j                            |dd          dd                                          dk    sJ d S Nr   r   r-   r   r   r   r   r   s       r   r   z8test_unzip_one_directory_different_name.<locals>.do_test7   s    gll:u557K000V|w}}[)))))w}}RW\\+u==>>>>>{27<<UEBBCQQVVXX\kkkkkkkr    foo/barr   r   r$   s    r   'test_unzip_one_directory_different_namer6   6   s1    l l l i17;;;;;r    c                  0    d } t          ddi|            d S )Nc                 V   t           j                            |d          }g }t          | ||           g |k    sJ t           j                            |          sJ t          j        t           j                            |d          dd                                          dk    sJ d S Nr   r-   r   r   r   r   r   s       r   r   z3test_unzip_one_directory_same_name.<locals>.do_testD   r   r    r4   r   r5   r$   s    r   "test_unzip_one_directory_same_namer:   C   s1    e e e i17;;;;;r    c                  D    d } t          t                      |            d S )Nc                     t           j                            |d          }g }t          | ||           dg|k    sJ t           j                            |          rJ d S )Nr   zZip archive was empty.)r   r   r   r   r   r   s       r   r   z%test_unzip_empty_zip.<locals>.do_testP   sb    gll:u557K000()V33337==-------r    r"   r$   s    r   test_unzip_empty_zipr=   O   s-    . . . TVVW%%%%%r    c                  J    d } t          t          dd          |            d S )Nc                    t           j                            |d          }t          j        |           g }t	          | ||           g |k    sJ t           j                            |          sJ t          j        t           j                            |d          dd                                          dk    sJ t          j        t           j                            |d          dd                                          dk    sJ d S r,   	r   r   r   makedirsr   r   r   r   r   r   s       r   r   zBtest_unzip_target_already_exists_and_is_directory.<locals>.do_test\   s    gll:u55
K   7K000V|w}}[))))){27<<U;;S'JJOOQQUddddd{27<<U;;S'JJOOQQUfffffffr    r   r.   r/   r"   r$   s    r   1test_unzip_target_already_exists_and_is_directoryrB   [   s:    g g g To3DEEEwOOOOOr    c                  0    d } t          ddi|            d S )Nc                    t           j                            |d          }t          j        |           g }t	          | ||           g |k    sJ t           j                            |          sJ t           j                            t           j                            |d                    sJ t          j        t           j                            |dd          dd                                          dk    sJ d S r3   r@   r   s       r   r   zXtest_unzip_target_already_exists_and_is_directory_and_single_dir_in_zip.<locals>.do_testk   s    gll:u55
K   7K000V|w}}[)))))w}}RW\\+u==>>>>>{27<<UEBBCQQVVXX\kkkkkkkr    r4   r   r5   r$   s    r   Gtest_unzip_target_already_exists_and_is_directory_and_single_dir_in_ziprE   j   s1    l l l i17;;;;;r    c                  0    d } t          ddi|            d S )Nc                 ~   t           j                            |d          }t          j        |           g }t	          | ||           g |k    sJ t           j                            |          sJ t          j        t           j                            |d          dd                                          dk    sJ d S r9   r@   r   s       r   r   zbtest_unzip_target_already_exists_and_is_directory_and_single_dir_in_zip_same_name.<locals>.do_testz       gll:u55
K   7K000V|w}}[))))){27<<U;;S'JJOOQQUdddddddr    r4   r   r5   r$   s    r   Qtest_unzip_target_already_exists_and_is_directory_and_single_dir_in_zip_same_namerI   y   s1    e e e i17;;;;;r    c                  H    d } t          t          d          |            d S )Nc                     t           j                            |d          }t          j        |           g }t	          | ||           t           j                            |          sJ d|z  g|k    sJ d S )Nr   zA%s exists and is a directory, not unzipping a plain file over it.)r   r   r   rA   r   r   r   s       r   r   zctest_unzip_target_already_exists_and_is_directory_and_single_file_in_zip_same_name.<locals>.do_test   sy    gll:u55
K   7K000w}}[)))))SVaabflllllllr    r   r!   r"   r$   s    r   Rtest_unzip_target_already_exists_and_is_directory_and_single_file_in_zip_same_namerL      s7    m m m To...88888r    c                  H    d } t          t          d          |            d S )Nc                 ~   t           j                            |d          }t          j        |           g }t	          | ||           g |k    sJ t           j                            |          sJ t          j        t           j                            |d          dd                                          dk    sJ d S r
   r@   r   s       r   r   zhtest_unzip_target_already_exists_and_is_directory_and_single_file_in_zip_different_name.<locals>.do_test   rH   r    r   r!   r"   r$   s    r   Wtest_unzip_target_already_exists_and_is_directory_and_single_file_in_zip_different_namerO      s7    e e e To...88888r    c                  0    d } t          ddi|            d S )Nc                 L   t           j                            |d          }t          j        |dd          5 }|                    d           d d d            n# 1 swxY w Y   g }t          | ||           t           j                            |          sJ d|z  g|k    sJ d S Nr   wr   
C%s exists and isn't a directory, not unzipping a directory over it.)r   r   r   r   r   writer   r(   r   r   r   fr   s        r   r   zStest_unzip_target_already_exists_and_is_file_and_single_dir_in_zip.<locals>.do_test   s    gll:u55[c733 	qGGDMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	7K000w~~k*****VYddfjppppppp   AA Ar4   r   r5   r$   s    r   Btest_unzip_target_already_exists_and_is_file_and_single_dir_in_ziprZ      s1    q q q i17;;;;;r    c                  J    d } t          t          dd          |            d S )Nc                 
   t           j                            |d          }t          j        |dd          5 }|                    d           d d d            n# 1 swxY w Y   g }t          | ||           d|z  g|k    sJ d S rR   )r   r   r   r   r   rV   r   rW   s        r   r   z=test_unzip_target_already_exists_and_is_file.<locals>.do_test   s    gll:u55[c733 	qGGDMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	7K000VYddfjppppppprY   r   r.   r/   r"   r$   s    r   ,test_unzip_target_already_exists_and_is_filer]      s:    q q q To3DEEEwOOOOOr    c                  H    d } t          t          d          |            d S )Nc                    t           j                            |d          }t          j        |dd          5 }|                    d           d d d            n# 1 swxY w Y   g }t          | ||           g |k    sJ t           j                            |          sJ t          j        |dd                                          dk    sJ d S )Nr   rS   r   rT   r   r   	r   r   r   r   r   rV   r   r(   r   rW   s        r   r   z^test_unzip_target_already_exists_and_is_file_and_single_file_in_zip_same_name.<locals>.do_test   s    gll:u55[c733 	qGGDMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	7K000V|w~~k*****{;W55::<<OOOOOOrY   r   r!   r"   r$   s    r   Mtest_unzip_target_already_exists_and_is_file_and_single_file_in_zip_same_namera      s7    P P P To...88888r    c                  H    d } t          t          d          |            d S )Nc                    t           j                            |d          }t          j        |dd          5 }|                    d           d d d            n# 1 swxY w Y   g }t          | ||           d|z  g|k    sJ t           j                            |          sJ t          j        |dd                                          dk    sJ d S )Nr   rS   r   z	original
rU   r   r`   rW   s        r   r   zctest_unzip_target_already_exists_and_is_file_and_single_file_in_zip_different_name.<locals>.do_test   s   gll:u55[c733 	"qGGL!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"7K000VYddfjpppppw~~k*****{;W55::<<LLLLLLrY   r   r!   r"   r$   s    r   Rtest_unzip_target_already_exists_and_is_file_and_single_file_in_zip_different_namerd      s7    M M M To...88888r    c                  H    d } t          t          d          |            d S )Nc                     t           j                            | d          }t           j                            | d          }g }t          |||           d|z  g|k    sJ d S )Nr   r   z*Failed to unzip %s: File is not a zip file)r   r   r   r   )r   r   r   r   s       r   r   z'test_unzip_bad_zipfile.<locals>.do_test   sb    ',,z511gll:u557K000=GIVSSSSSSr    znot a zip file
r!   )r   r#   r$   s    r   test_unzip_bad_zipfilerg      s8    T T T D%7888'BBBBBr    )
__future__r   r   r   r   "anaconda_project.internal.ziputilsr   ,anaconda_project.internal.test.tmpfile_utilsr   r   r%   r)   r0   r6   r:   r=   rB   rE   rI   rL   rO   rZ   r]   ra   rd   rg    r    r   <module>rl      sc   7 6 6 6 6 6 6 6  				 9 9 9 9 9 9 d d d d d d d d	9 	9 	9	9 	9 	9
P 
P 
P
< 
< 
<	< 	< 	<& & &P P P< < <
< 
< 
<	9 	9 	9
9 
9 
9
< 
< 
<	P 	P 	P9 9 99 9 9C C C C Cr    