
    daft                         d dl Zd dlZd dlZd dlZd dlmZ d dlmZm	Z	  G d dej                        Z G d dej                        Zedk(  r ej                          yy)	    N)import_module)MultiplexedPathNamespaceReaderc                   d    e Z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y)MultiplexedPathTestc                 p    t        j                  t              j                  dz  }t	        |      | _        y )Nnamespacedata01)pathlibPath__file__parentstrfolder)clspaths     D/root/Python-3.12.4/Lib/test/test_importlib/resources/test_reader.py
setUpClasszMultiplexedPathTest.setUpClass   s'    ||H%,,/@@Y
    c                 l    | j                  t              5  t                d d d        y # 1 sw Y   y xY wN)assertRaisesFileNotFoundErrorr   selfs    r   test_init_no_pathsz&MultiplexedPathTest.test_init_no_paths   s,    01 		 	 	s   *3c                     | j                  t              5  t        t        j                  j                  | j                  d             d d d        y # 1 sw Y   y xY w)Nbinary.file)r   NotADirectoryErrorr   osr   joinr   r   s    r   test_init_filez"MultiplexedPathTest.test_init_file   sE    12 	FBGGLLmDE	F 	F 	Fs   4A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__>   
utf-8.filer   utf-16.file)r   r   iterdirnameremoveKeyError
ValueErrorassertEqual)r   r   contentss      r   test_iterdirz MultiplexedPathTest.test_iterdir   sn    *9$++*F*N*N*PQ$DIIQQ	OOM* 	#OP R *% 		s   A"A' 'A98A9c                    t         j                  j                  t         j                  j                  t        dd            }t        | 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..data01)r#   z__init__.pyc>   __init__.pysubdirectoryr$   r   r%   )r   r   abspathr    r   r   r   r&   r'   r(   r)   r*   r+   )r   r0   r   r,   r(   s        r   test_iterdir_duplicatez*MultiplexedPathTest.test_iterdir_duplicate    s    hh!GH"1$++v"F"N"N"P
DII
 
 6 	F'	
 	W	

 j) s   )B,B11CCc                 j    | j                  t        | j                        j                         d       y )NT)r+   r   r   is_dirr   s    r   test_is_dirzMultiplexedPathTest.test_is_dir/   s$    5<<>Er   c                 j    | j                  t        | j                        j                         d       y )NF)r+   r   r   is_filer   s    r   test_is_filez MultiplexedPathTest.test_is_file2   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   r   s     r   test_open_filez"MultiplexedPathTest.test_open_file5   s    t{{+01 	OO	01 	NN	01 	IIK	 			 		 		 	s#   B!B-B9!B*-B69Cc                 <   t         j                  j                  t         j                  j                  t        d            }t         j                  j                  |d      }t        | j                  |      }| j                  t        |j                  d            t        |      dz   d  t         j                  j                  dd             | j                  t        |j                  d            t        |      dz   d  t         j                  j                  dd             | j                  t        |j                  d            t        |      dz   d  t         j                  j                  dd             | j                  |j                         |       y )Nr/   r0   r      r	   r2   	imaginary)r   r   r3   r    r   r   r   r+   r   joinpathlen)r   prefixr0   r   s       r   test_join_pathz"MultiplexedPathTest.test_join_path>   s(   h!=>fh/t{{F3m,-c&kAo.?@GGLL*M:	
 	n-.s6{Q/@AGGLL>2	
 	k*+CK!O,=>GGLL*K8	
 	$/r   c                 p    t        | j                        }|j                  d      j                         rJ y )Nzimaginary/foo.py)r   r   rD   existsr?   s     r   test_join_path_compoundz+MultiplexedPathTest.test_join_path_compoundP   s/    t{{+==!34;;====r   c                    t         j                  j                  t         j                  j                  t        d            }t         j                  j                  |d      }t         j                  j                  |d      }t        ||      }| j                  |j                  d      t
               | j                  t        |j                  dd            t        |      dz   d  t         j                  j                  ddd             y )Nr/   r0   data02r2   	subsubdirrB   )r   r   r3   r    r   r   assertIsInstancerD   r+   r   rE   )r   rF   r0   rL   r   s        r   test_join_path_common_subdirz0MultiplexedPathTest.test_join_path_common_subdirT   s    h!=>fh/fh/vv.dmmN;_Mnk:;CK!O<MNGGLL>;?	
r   c                 |    | j                  t        t        | j                              d| j                   d       y )NMultiplexedPath(''))r+   reprr   r   r   s    r   	test_reprzMultiplexedPathTest.test_repr_   s1    -.}B/	
r   c                     | j                  t        | j                        j                  t        j
                  j                  | j                               y r   )r+   r   r   r'   r   r   basenamer   s    r   	test_namezMultiplexedPathTest.test_namee   s8    DKK(--GGT[[)	
r   N)__name__
__module____qualname__classmethodr   r   r!   r-   r4   r7   r:   r@   rG   rJ   rO   rT   rW    r   r   r   r   
   sT     FQ
FH0$>	


r   r   c                       e Zd Z e ej
                  e      j                        Ze	d        Z
e	d        Zd Zd Zd Zy)NamespaceReaderTestc                 V    t         j                  j                  | j                         y r   )sysr   appendsite_dirr   s    r   r   zNamespaceReaderTest.setUpClasso       %r   c                 V    t         j                  j                  | j                         y r   )r`   r   r(   rb   rc   s    r   tearDownClassz!NamespaceReaderTest.tearDownClasss   rd   r   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_errorw   s2    z* 	0Wg./	0 	0 	0s   -6c                    t        d      }t        |j                  j                        }t        j
                  j                  t        j
                  j                  t        dd            }| j                  |j                  d      t        j
                  j                  |d             | j                  |j                  d      t        j
                  j                  |d             y )Nr	   r/   r   rC   )r   r   __spec__submodule_search_locationsr   r   r3   r    r   r+   resource_pathr   r	   readerroots       r   test_resource_pathz&NamespaceReaderTest.test_resource_path{   s    '(9: !9!9!T!TUwwrww||Hd<MNO  /dM1R	
 	  -rww||D+/N	
r   c                 ~   t        d      }t        |j                  j                        }t        j
                  j                  t        j
                  j                  t        dd            }| j                  |j                         t               | j                  t        |j                               d| d       y )Nr	   r/   rQ   rR   )r   r   rl   rm   r   r   r3   r    r   rN   filesr   r+   rS   ro   s       r   
test_fileszNamespaceReaderTest.test_files   s    '(9: !9!9!T!TUwwrww||Hd<MNOfllno>flln-1B4&/KLr   N)rX   rY   rZ   r   r
   r   r   r   rb   r[   r   rf   rj   rr   ru   r\   r   r   r^   r^   l   sS    <7<<)001H& & & &0

Mr   r^   __main__)os.pathr   r`   r
   unittest	importlibr   importlib.readersr   r   TestCaser   r^   rX   mainr\   r   r   <module>r}      s[     
   # >_
(++ _
D M(++  MF zHMMO r   