
    @g                         d dl Z d dlZd dlZd dlmZmZ ddlmZ  G d dej                        Z
 G d dej                        Zy)	    N)CompatibilityFiles	wrap_spec   )utilc                       e Zd Zed        Ze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y)CompatibilityFilesTestsc                 \    t        j                  d      }t        j                  |dd      S )N   Hello, world!	some_pathabc)filepathcontents)ioBytesIOr   create_package)self
bytes_datas     f/var/www/openai/venv/lib/python3.12/site-packages/importlib_resources/tests/test_compatibilty_files.pypackagezCompatibilityFilesTests.package   s-    ZZ 01
""$
 	
    c                 @    t        j                  | j                        S N	resourcesfilesr   r   s    r   r   zCompatibilityFilesTests.files       t||,,r   c                 |    | j                  t        d | j                  j                         D              g d       y )Nc              3   4   K   | ]  }|j                     y wr   )name).0r   s     r   	<genexpr>z>CompatibilityFilesTests.test_spec_path_iter.<locals>.<genexpr>   s     >)=499)=s   r   )assertEqualsortedr   iterdirr    s    r   test_spec_path_iterz+CompatibilityFilesTests.test_spec_path_iter   s.    >););)=>>	
r   c                 p    | j                  t        | j                  dz  j                               g        y Nr   r'   listr   r)   r    s    r   test_child_path_iterz,CompatibilityFilesTests.test_child_path_iter!   s)    tzzC/88:;R@r   c                     | j                  t        | j                  dz  dz  j                               g        | j                  t        | j                  dz  dz  dz  j                               g        y r,   r-   r    s    r   test_orphan_path_iterz-CompatibilityFilesTests.test_orphan_path_iter$   s_    tzzC/#5>>@A2FtzzC/#5;DDFGLr   c                     | j                  | j                  j                                | j                  | j                  j                                y r   assertFalser   is_fileis_dirr    s    r   test_spec_path_isz)CompatibilityFilesTests.test_spec_path_is(   s8    ++-.**,-r   c                     | j                  | j                  dz  j                                | j                  | j                  dz  j	                                y r,   )
assertTruer   r5   r4   r6   r    s    r   test_child_path_isz*CompatibilityFilesTests.test_child_path_is,   s@    c)2245$**s*2245r   c                    | j                  | j                  dz  dz  j                                | j                  | j                  dz  dz  j                                | j                  | j                  dz  dz  dz  j                                | j                  | j                  dz  dz  dz  j                                y r,   r3   r    s    r   test_orphan_path_isz+CompatibilityFilesTests.test_orphan_path_is0   s    $**s*S099;<$**s*S088:;$**s*S036??AB$**s*S036>>@Ar   c                 P    | j                  | j                  j                  d       y )Ntestingpackager'   r   r$   r    s    r   test_spec_path_namez+CompatibilityFilesTests.test_spec_path_name6   s    *:;r   c                 V    | j                  | j                  dz  j                  d       y r,   r?   r    s    r   test_child_path_namez,CompatibilityFilesTests.test_child_path_name9   s!    $**s*00#6r   c                     | j                  | j                  dz  dz  j                  d       | j                  | j                  dz  dz  dz  j                  d       y Nr   r   r   r?   r    s    r   test_orphan_path_namez-CompatibilityFilesTests.test_orphan_path_name<   sO    $**s*S066<$**s*S036<<cBr   c                     | j                  | j                  j                         d       | j                  | j                  j                  d      d       y )Nr
   utf-8encodingHello, world!r'   r   
read_bytes	read_textr    s    r   test_spec_path_openz+CompatibilityFilesTests.test_spec_path_open@   sB    ..02BC--w-?Qr   c                     | j                  | j                  dz  j                         d       | j                  | j                  dz  j                  d      d       y )Nr   r
   rG   rH   rJ   rK   r    s    r   test_child_path_openz,CompatibilityFilesTests.test_child_path_openD   sO    $**s*668:JKZZ#(('(:O	
r   c                 2   | j                  t              5  | j                  dz  dz  j                          d d d        | j                  t              5  | j                  dz  dz  dz  j                          d d d        y # 1 sw Y   KxY w# 1 sw Y   y xY wrD   )assertRaisesFileNotFoundErrorr   rL   r    s    r   test_orphan_path_openz-CompatibilityFilesTests.test_orphan_path_openJ   sv    01ZZ##//1 201ZZ##c)557 21 2111s   !B$BB
Bc                     | j                  t              5  | j                  j                  d       d d d        y # 1 sw Y   y xY w)N0)rR   
ValueErrorr   openr    s    r   test_open_invalid_modez.CompatibilityFilesTests.test_open_invalid_modeP   s,    z*JJOOC  +**s	   ;Ac                     | j                  t              5  t        j                          d d d        y # 1 sw Y   y xY wr   )rR   rW   r   
OrphanPathr    s    r   test_orphan_path_invalidz0CompatibilityFilesTests.test_orphan_path_invalidT   s(    z*))+ +**s   4=c                     t        | j                        }| j                  |j                  j	                  d       t
               y r   )r   r   assertIsInstanceloaderget_resource_readerr   )r   specs     r   test_wrap_specz&CompatibilityFilesTests.test_wrap_specX   s0    &dkk==dCEWXr   N)__name__
__module____qualname__propertyr   r   r*   r/   r1   r7   r:   r<   r@   rB   rE   rN   rP   rT   rY   r\   rb    r   r   r   r      sy    
 
 - -
AM.6B<7CR
8!,Yr   r   c                   2    e Zd Zed        Zed        Zd Zy)CompatibilityFilesNoReaderTestsc                 ,    t        j                  d       S r   )r   create_package_from_loaderr    s    r   r   z'CompatibilityFilesNoReaderTests.package^   s    ..t44r   c                 @    t        j                  | j                        S r   r   r    s    r   r   z%CompatibilityFilesNoReaderTests.filesb   r!   r   c                 ^    | j                  | j                  dz  t        j                         y r,   )r^   r   r   r[   r    s    r   test_spec_path_joinpathz7CompatibilityFilesNoReaderTests.test_spec_path_joinpathf   s"    djj3.0B0M0MNr   N)rc   rd   re   rf   r   r   rn   rg   r   r   ri   ri   ]   s.    5 5 - -Or   ri   )r   unittestimportlib_resourcesr   importlib_resources._adaptersr   r    r   TestCaser   ri   rg   r   r   <module>rt      sC    	  '
 MYh// MY`
Oh&7&7 
Or   