
    Xj	                         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dS )	    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dS )CompatibilityFilesTestsc                 X    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     n/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/importlib_resources/tests/test_compatibilty_files.pypackagezCompatibilityFilesTests.package   s5    Z 011
"$
 
 
 	
    c                 4    t          j        | j                  S N	resourcesfilesr   r   s    r   r   zCompatibilityFilesTests.files       t|,,,r   c                 v    t          d | j                                        D                       g dk    sJ d S )Nc              3   $   K   | ]}|j         V  d S r   )name).0r   s     r   	<genexpr>z>CompatibilityFilesTests.test_spec_path_iter.<locals>.<genexpr>   s$      AADdiAAAAAAr   r   )sortedr   iterdirr    s    r   test_spec_path_iterz+CompatibilityFilesTests.test_spec_path_iter   sB    AADJ,>,>,@,@AAAAA___TTTTTTr   c                 d    t          | j        dz                                            g k    sJ d S Nr   listr   r(   r    s    r   test_child_path_iterz,CompatibilityFilesTests.test_child_path_iter   s4    TZ#%..0011R777777r   c                     t          | j        dz  dz                                            g k    sJ t          | j        dz  dz  dz                                            g k    sJ d S r+   r,   r    s    r   test_orphan_path_iterz-CompatibilityFilesTests.test_orphan_path_iter!   so    TZ#%+4466772====TZ#%+c1::<<==CCCCCCr   c                 r    | j                                         rJ | j                                         rJ d S r   r   is_fileis_dirr    s    r   test_spec_path_isz)CompatibilityFilesTests.test_spec_path_is%   s<    :%%''''':$$&&&&&&&r   c                 ~    | j         dz                                  sJ | j         dz                                  rJ d S r+   r2   r    s    r   test_child_path_isz*CompatibilityFilesTests.test_child_path_is)   sF    
S ))+++++J$,,.......r   c                    | j         dz  dz                                  rJ | j         dz  dz                                  rJ | j         dz  dz  dz                                  rJ | j         dz  dz  dz                                  rJ d S r+   r2   r    s    r   test_orphan_path_isz+CompatibilityFilesTests.test_orphan_path_is-   s    J$s*3355555J$s*2244444J$s*S099;;;;;J$s*S088:::::::r   c                 *    | j         j        dk    sJ d S )Ntestingpackager   r$   r    s    r   test_spec_path_namez+CompatibilityFilesTests.test_spec_path_name3   s    z"2222222r   c                 0    | j         dz  j        dk    sJ d S r+   r<   r    s    r   test_child_path_namez,CompatibilityFilesTests.test_child_path_name6   s#    
S &#------r   c                 l    | j         dz  dz  j        dk    sJ | j         dz  dz  dz  j        dk    sJ d S Nr   r   r   r<   r    s    r   test_orphan_path_namez-CompatibilityFilesTests.test_orphan_path_name9   sM    
S 3&,3333
S 3&,2c999999r   c                     | j                                         dk    sJ | j                             d          dk    sJ d S )Nr
   utf-8encodingHello, world!r   
read_bytes	read_textr    s    r   test_spec_path_openz+CompatibilityFilesTests.test_spec_path_open=   sL    z$$&&*:::::z##W#55HHHHHHr   c                     | j         dz                                  dk    sJ | j         dz                      d          dk    sJ d S )Nr   r
   rD   rE   rG   rH   r    s    r   test_child_path_openz,CompatibilityFilesTests.test_child_path_openA   sV    
S ,,..2BBBBB
S ++W+==PPPPPPr   c                 R   |                      t                    5  | j        dz  dz                                   d d d            n# 1 swxY w Y   |                      t                    5  | j        dz  dz  dz                                   d d d            d S # 1 swxY w Y   d S rA   )assertRaisesFileNotFoundErrorr   rI   r    s    r   test_orphan_path_openz-CompatibilityFilesTests.test_orphan_path_openE   s&   011 	2 	2Z##//111	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2 	2011 	8 	8Z##c)55777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s#    AAA,#BB #B c                     |                      t                    5  | j                            d           d d d            d S # 1 swxY w Y   d S )N0)rO   
ValueErrorr   openr    s    r   test_open_invalid_modez.CompatibilityFilesTests.test_open_invalid_modeK   s    z** 	! 	!JOOC   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!s   AA
Ac                     |                      t                    5  t          j                     d d d            d S # 1 swxY w Y   d S r   )rO   rT   r   
OrphanPathr    s    r   test_orphan_path_invalidz0CompatibilityFilesTests.test_orphan_path_invalidO   s    z** 	, 	,)+++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s   <A A c                     t          | j                  }t          |j                            d           t
                    sJ d S r   )r   r   
isinstanceloaderget_resource_readerr   )r   specs     r   test_wrap_specz&CompatibilityFilesTests.test_wrap_specS   s>    &&$+99$??ASTTTTTTTr   N)__name__
__module____qualname__propertyr   r   r)   r.   r0   r5   r7   r9   r=   r?   rB   rK   rM   rQ   rV   rY   r_    r   r   r   r      s:       
 
 X
 - - X-U U U8 8 8D D D' ' '/ / /; ; ;3 3 3. . .: : :I I IQ Q Q8 8 8! ! !, , ,U U U U Ur   r   c                   @    e Zd Zed             Zed             Zd ZdS )CompatibilityFilesNoReaderTestsc                 *    t          j        d           S r   )r   create_package_from_loaderr    s    r   r   z'CompatibilityFilesNoReaderTests.packageY   s    .t444r   c                 4    t          j        | j                  S r   r   r    s    r   r   z%CompatibilityFilesNoReaderTests.files]   r!   r   c                 N    t          | j        dz  t          j                  sJ d S r+   )r[   r   r   rX   r    s    r   test_spec_path_joinpathz7CompatibilityFilesNoReaderTests.test_spec_path_joinpatha   s)    $*s*,>,IJJJJJJJr   N)r`   ra   rb   rc   r   r   rk   rd   r   r   rf   rf   X   s\        5 5 X5 - - X-K K K K Kr   rf   )r   unittestimportlib_resourcesr   importlib_resources._adaptersr   r    r   TestCaser   rf   rd   r   r   <module>rq      s    				  ' ' ' '       
      HU HU HU HU HUh/ HU HU HUV
K 
K 
K 
K 
Kh&7 
K 
K 
K 
K 
Kr   