
    @gn#                     D   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  G d d      Z	 G d d      Z
 G d	 d
      Z G d de	eej                  ej                        Z G d de
eej                  ej                        Z G d de	eej                   ej                        Zy)    N   )util)warnings_helperc                       e Zd ZdZdZy)StringAnchorMixindata01data02N)__name__
__module____qualname__anchor01anchor02     ^/var/www/openai/venv/lib/python3.12/site-packages/importlib_resources/tests/test_functional.pyr   r      s    HHr   r   c                   ,    e Zd Zed        Zed        Zy)ModuleAnchorMixinc                 ,    t        j                  d      S )Nr   	importlibimport_moduleselfs    r   r   zModuleAnchorMixin.anchor01       &&x00r   c                 ,    t        j                  d      S Nr	   r   r   s    r   r   zModuleAnchorMixin.anchor02   r   r   N)r
   r   r   propertyr   r   r   r   r   r   r      s(    1 1 1 1r   r   c                        e Zd Z fdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Z ej                  e      d        Zd Z xZS )FunctionalAPIBasec                 D    t         |           | j                  d       y r   )supersetUpload_fixture)r   	__class__s    r   r"   zFunctionalAPIBase.setUp   s    (#r   c              #   p   K   dD ]!  }| j                  |      5  | ddd       # y# 1 sw Y   .xY ww)zAYield various names of a text file in anchor02, each in a subTest))subdirectory	subsubdirresource.txt)z#subdirectory/subsubdir/resource.txt)zsubdirectory/subsubdirr(   )
path_partsN)subTestr   r)   s     r   _gen_resourcetxt_path_partsz-FunctionalAPIBase._gen_resourcetxt_path_parts   s8     
J
 4   54

 54s   6*63	6c                 B    | j                  |t        |       d |       y)zqAssert that `string` ends with `suffix`.

        Used to ignore an architecture-specific UTF-16 byte-order mark.N)assertEquallen)r   stringsuffixs      r   assertEndsWithz FunctionalAPIBase.assertEndsWith)   s!     	V/8r   c           	      R   | j                  t        j                  | j                  d      d       | j                  t        j                  | j                  dddd      d       | j                         D ]5  }| j                  t        j                  | j                  g|d	did       7 | j                  t              5  t        j                  | j                         d d d        | j                  t        t        j                  j                  f      5  t        j                  | j                  d
       d d d        | j                  t              5  t        j                  | j                  d       d d d        | j                  t        j                  | j                  dd      d       | j                  t        j                  | j                  dd      dj                  d      j                  d             y # 1 sw Y   $xY w# 1 sw Y   xY w# 1 sw Y   xY w)N
utf-8.fileHello, UTF-8 world!
r&   r'   r(   utf-8encoding
a resourcer8   no-such-fileutf-16.filebinary.filelatin1 backslashreplaceerrorsHello, UTF-16 world!
	utf-16-le)r.   	resources	read_textr   r   r,   assertRaisesOSErrorabcTraversalErrorUnicodeDecodeErrorr2   encodedecoder+   s     r   test_read_textz FunctionalAPIBase.test_read_text/   s   |<#	
 	  		
 ::<J##MM %
  = w'. ()E)EFG~> H12}= 3!
 	
 	)
 %++K8??) @ 		
 ('GG22s$    H!H!HHHH&c                     | j                  t        j                  | j                  d      d       | j	                         D ]2  }| j                  t        j                  | j
                  g| d       4 y Nr4   s   Hello, UTF-8 world!
s
   a resource)r.   rD   read_binaryr   r,   r   r+   s     r   test_read_binaryz"FunctionalAPIBase.test_read_binaryb   sd    !!$-->$	
 ::<J%%dmmAjA =r   c                 b   t        j                  | j                  d      5 }| j                  |j	                         d       d d d        | j                         D ]N  }t        j                  | j                  g|ddi5 }| j                  |j	                         d       d d d        P | j                  t              5  t        j                  | j                         d d d        | j                  t        t         j                  j                  f      5  t        j                  | j                  d       d d d        t        j                  | j                  d      5 }| j                  t              5  |j	                          d d d        d d d        t        j                  | j                  dd	
      5 }| j                  |j	                         d       d d d        t        j                  | j                  dd      5 }| j                  |j	                         dj                  d      j                  d             d d d        y # 1 sw Y   xY w# 1 sw Y   
xY w# 1 sw Y   xY w# 1 sw Y   >xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nr4   r5   r8   r6   r9   r:   r;   r<   r=   r7   r>   r?   r@   rB   rC   )rD   	open_textr   r.   readr,   r   rF   rG   rH   rI   rJ   r2   rK   rL   r   fr)   s      r   test_open_textz FunctionalAPIBase.test_open_textm   s     =QVVX'>? >::<J$$ !   <8  = w'. ()E)EFG~> H  >!""#56 7 ?   MM
 QVVX'9:
   MM%
 (//<CC- D 
 
1 >=  ('GG 76 ?>
 

 
sl   !I !I  I'!I4 J6JJ9!JA J%II$	'I14I>J
	JJJ"%J.c                    t        j                  | j                  d      5 }| j                  |j	                         d       d d d        | j                         D ]K  }t        j                  | j                  g| 5 }| j                  |j	                         d       d d d        M y # 1 sw Y   hxY w# 1 sw Y   dxY wrO   )rD   open_binaryr   r.   rT   r,   r   rU   s      r   test_open_binaryz"FunctionalAPIBase.test_open_binary   s    ""4==,?1QVVX'?@ @::<J&&   =9	  = @? s   !B)=!B5)B25B>	c                 ,   t        j                  | j                  d      5 }t        t	        |      d      5 }| j                  |j                         d       d d d        d d d        t        j                  | j                        5 }t        t        j                  j                  |d      d      5 }| j                  |j                         d       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   *xY w# 1 sw Y   y xY w)Nr4   r6   r7   r5   )	rD   pathr   openstrr.   rT   osjoin)r   r\   rV   s      r   	test_pathzFunctionalAPIBase.test_path   s    ^^DMM<8Dc$i'2a  +BC 3 9 ^^DMM*dbggll46IQ  +BC J +* 32 98 JI +*sF   C2!C&C2,D
4!C>D
&C/	+C22C;>D	D

Dc                    t         j                  }| j                   || j                  d             | j	                   || j                  d             | j	                   || j                               | j	                   || j                  d             | j                         D ]$  }| j                   || j                  g|        & y )Nr4   no_such_filer&   )rD   is_resource
assertTruer   assertFalser,   r   )r   rd   r)   s      r   test_is_resourcez"FunctionalAPIBase.test_is_resource   s    ++DMM<@AT]]NCDT]]34T]]NCD::<JOOKC
CD =r   c           	      &   t        j                  dt        f      5  t        j                  | j
                        }d d d        | j                  t              h d       | j                  t              5  t        j                  dt        f      5  t        t        j                  | j
                  d             d d d        d d d        | j                         D ]  }| j                  t        t        j                  j                  f      5  t        j                  dt        f      5  t        t        j                  | j
                  g|        d d d        d d d         t        j                  dt        f      5  t        j                  | j
                  d      }d d d        | j                  t        |      dh       y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   (xY w# 1 sw Y   fxY w)Nz.*contents.*>   r&   r4   r<   r;   r4   r&   r<   )r   check_warningsDeprecationWarningrD   contentsr   assertGreaterEqualsetrF   rG   listr,   rH   rI   )r   cr)   s      r   test_contentszFunctionalAPIBase.test_contents   s   ++^=O,PQ""4==1A RFH	

 g&**", 
 ##DMM<@A ' ::<J!!7IMM,H,H"IJ.."&0 
 Y''C
CD KJ = ++^=O,PQ""4==.AA RFO	
5 RQ  '&  KJ RQs_    G6G!*G<G!G:**G.G:!HGG	G!!G+.G73G::H	H)categoryc                 j   t         j                  t         j                  t         j                  t         j                  t         j
                  t         j                  t         j                  fD ]  }| j                  |      5  | j                  t              5   |d        d d d        | j                  t        t        f      5   |d       d d d        | j                  t              5   |d       d d d        d d d         y # 1 sw Y   fxY w# 1 sw Y   FxY w# 1 sw Y   ,xY w# 1 sw Y   xY w)Nfunci  z$missing module$)rD   rE   rP   rS   rY   r\   rd   rk   r*   rF   	TypeErrorAttributeErrorModuleNotFoundErrorr   rt   s     r   test_common_errorsz$FunctionalAPIBase.test_common_errors   s     !!!!NN!!
D 4(&&y1J 2 &&	>'BCJ D &&':;+, < )(
 21 DC <; )(sT   D)	D #D)	DD))	D2D)D
D)DD)D&"D))D2	c           	         t         j                  t         j                  fD ]P  }| j                  |      5  | j	                  t
              5   || j                  ddd       d d d        d d d        R y # 1 sw Y   xY w# 1 sw Y   ixY w)Nrs   r&   r'   r(   )rD   rE   rS   r*   rF   ru   r   rx   s     r   test_text_errorsz"FunctionalAPIBase.test_text_errors   su    
D 4(&&y1&#&	 2 )(	
 21 )(s#   BA5"B5A>:BB
	)r
   r   r   r"   r,   r2   rM   rQ   rW   rZ   ra   rg   rp   r   ignore_warningsrj   ry   r{   __classcell__)r$   s   @r   r   r      sb    $!91
f	#J:DE
@ %_$$.@A- B-*r   r   c                       e Zd Zy)#FunctionalAPITest_StringAnchor_DiskNr
   r   r   r   r   r   r   r           	r   r   c                       e Zd Zy)#FunctionalAPITest_ModuleAnchor_DiskNr   r   r   r   r   r      r   r   r   c                       e Zd Zy)%FunctionalAPITest_StringAnchor_MemoryNr   r   r   r   r   r     r   r   r   )r   r_   unittestimportlib_resourcesrD    r   compat.py39r   r   r   r   	DiskSetupTestCaser   r   MemorySetupr   r   r   r   <module>r      s     	  '  ( 
1 1V Vr	NN			NN					r   