
    @g/                         d dl Zd dlZd dlZd dlmZ d dlmZmZ ddl	m
Z
  G d de
j                  ej                        Z G d d	e
j                  ej                        Zed
k(  r ej                           yy)    N)import_module)MultiplexedPathNamespaceReader   )utilc                   j     e Zd ZdZ f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 xZS )MultiplexedPathTestnamespacedata01c                 x   t         |           t        j                  | j                  j
                  d         | _        t        j                  | j                  d      j                        j                  | _
        t        j                  | j                  d      j                        j                  | _        y )Nr   data01data02)supersetUppathlibPathdata__path__folderload_fixture__file__parentr   r   )self	__class__s    Z/var/www/openai/venv/lib/python3.12/site-packages/importlib_resources/tests/test_reader.pyr   zMultiplexedPathTest.setUp   sy    ll499#5#5a#89ll4#4#4X#>#G#GHOOll4#4#4X#>#G#GHOO    c                 l    | j                  t              5  t                d d d        y # 1 sw Y   y xY wN)assertRaisesFileNotFoundErrorr   r   s    r   test_init_no_pathsz&MultiplexedPathTest.test_init_no_paths   s#    01 211s   *3c                     | j                  t              5  t        | j                  dz         d d d        y # 1 sw Y   y xY w)Nbinary.file)r   NotADirectoryErrorr   r   r    s    r   test_init_filez"MultiplexedPathTest.test_init_file   s.    12DKK-78 322s	   8Ac                     t        | j                        j                         D ch c]  }|j                   }}	 |j	                  d       | j                  |h d       y c c}w # t
        t        f$ r Y +w xY w)N__pycache__>   subdirectory
utf-8.filer#   utf-16.file)r   r   iterdirnameremoveKeyError
ValueErrorassertEqual)r   pathcontentss      r   test_iterdirz MultiplexedPathTest.test_iterdir   st    *9$++*F*N*N*PQ*P$DII*PQ	OOM* 	R	
 R *% 		s   A"A' 'A98A9c                    t        | j                  | j                        j                         D ch c]  }|j                   }}dD ]  }	 |j                  |        | j                  |h d       y c c}w # t        t        f$ r Y Bw xY w)N)r'   z__init__.pyc>   __init__.pyr(   r)   r#   r*   )	r   r   r   r+   r,   r-   r.   r/   r0   )r   r1   r2   r-   s       r   test_iterdir_duplicatez*MultiplexedPathTest.test_iterdir_duplicate&   s    "1$++t{{"K"S"S"U
"U$DII"U 	 
 6F' 6
 	W	

 j) s   A4A99B
Bc                 j    | j                  t        | j                        j                         d       y )NT)r0   r   r   is_dirr    s    r   test_is_dirzMultiplexedPathTest.test_is_dir4   s$    5<<>Er   c                 j    | j                  t        | j                        j                         d       y )NF)r0   r   r   is_filer    s    r   test_is_filez MultiplexedPathTest.test_is_file7   s$    5==?Gr   c                    t        | j                        }| j                  t              5  |j	                          d d d        | j                  t              5  |j                          d d d        | j                  t              5  |j                          d d d        y # 1 sw Y   fxY w# 1 sw Y   DxY w# 1 sw Y   y xY wr   )r   r   r   r   
read_bytes	read_textopenr   r1   s     r   test_open_filez"MultiplexedPathTest.test_open_file:   s    t{{+01OO 201NN 201IIK 21	 211111s#   B!B-B9!B*-B69Cc                    t        | j                  j                        }t        | j                  | j                        }| j                  t        |j                  d            t        |      dz   d  t        j                  j                  dd             |j                  d      }t        |t              sJ dt        |      v sJ dt        |      v sJ | j                  t        |j                  d            t        |      dz   d  t        j                  j                  dd             | j                  |j                         |       y )Nr#   r   r
   r(   r   	imaginary)strr   r   r   r   r0   joinpathlenosr1   join
isinstance)r   prefixr1   subs       r   test_join_pathz"MultiplexedPathTest.test_join_pathC   s
   T[[''(t{{DKK8m,-c&kAo.?@GGLL*M:	
 mmN+#/// CH,,,3s8###k*+CK!O,=>GGLL*K8	
 	$/r   c                 p    t        | j                        }|j                  d      j                         rJ y )Nzimaginary/foo.py)r   r   rF   existsrA   s     r   test_join_path_compoundz+MultiplexedPathTest.test_join_path_compoundT   s/    t{{+==!34;;====r   c                 ~   t        | j                  j                        }t        | j                  | j                        }| j                  |j                  d      t               | j                  t        |j                  dd            t        |      dz   d  t        j                  j                  ddd             y )Nr(   	subsubdirr   r   )rE   r   r   r   r   assertIsInstancerF   r0   rG   rH   r1   rI   )r   rK   r1   s      r   test_join_path_common_subdirz0MultiplexedPathTest.test_join_path_common_subdirX   s    T[[''(t{{DKK8dmmN;_Mnk:;CK!O<MNGGLL>;?	
r   c                 |    | j                  t        t        | j                              d| j                   d       y )NMultiplexedPath(''))r0   reprr   r   r    s    r   	test_reprzMultiplexedPathTest.test_repra   s1    -.}B/	
r   c                     | j                  t        | j                        j                  t        j
                  j                  | j                               y r   )r0   r   r   r,   rH   r1   basenamer    s    r   	test_namezMultiplexedPathTest.test_nameg   s8    DKK(--GGT[[)	
r   )__name__
__module____qualname__MODULEr   r!   r%   r3   r6   r9   r<   rB   rM   rP   rT   rY   r\   __classcell__)r   s   @r   r	   r	      sL    FP9

FH0">


r   r	   c                   "    e Zd ZdZd Zd Zd Zy)NamespaceReaderTestr
   c                 r    | j                  t              5  t        ddg       d d d        y # 1 sw Y   y xY w)Npath1path2)r   r/   r   r    s    r   test_init_errorz#NamespaceReaderTest.test_init_errorq   s)    z*Wg./ +**s   -6c                    t        d      }t        |j                  j                        }| j                  j
                  d   }| j                  |j                  d      t        j                  j                  |d             | j                  |j                  d      t        j                  j                  |d             y )Nr
   r   r#   rD   )r   r   __spec__submodule_search_locationsr   r   r0   resource_pathrH   r1   rI   )r   r
   readerroots       r   test_resource_pathz&NamespaceReaderTest.test_resource_pathu   s    '(9: !9!9!T!TUyy!!!$  /dM1R	
 	  -rww||D+/N	
r   c                 *   t        | j                  j                  j                        }| j                  j                  d   }| j                  |j                         t               | j                  t        |j                               d| d       y )Nr   rV   rW   )
r   r   ri   rj   r   rS   filesr   r0   rX   )r   rl   rm   s      r   
test_fileszNamespaceReaderTest.test_files   sk     !3!3!N!NOyy!!!$fllno>flln-1B4&/KLr   N)r]   r^   r_   r`   rg   rn   rq    r   r   rc   rc   n   s    F0

Mr   rc   __main__)os.pathrH   r   unittest	importlibr   importlib_resources.readersr   r    r   	DiskSetupTestCaser	   rc   r]   mainrr   r   r   <module>r|      sf       # H `
$..(*;*; `
FM$..(*;*; M4 zHMMO r   