
    daf                        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 d dlm	Z	 g dZ
ej                  dk7  re
j                  g d       e j                  j                  s+ ej                         Z	 e
D ]  Zej%                  e        	  G d	 d
ej*                        Z G d de      Z G d de      Z G d de      Z G d de      Zedk(  r ej8                          yy# e$ r  ej(                  d      w xY w)    N	normalize)	os_helper)support)
1_abc2_asciiu   3_Grüß-Gottu   4_Γειά-σαςu   5_Здравствуйтеu   6_にぽんu   7_השקצץסu   8_曨曩曫u   9_曨שんдΓßu	   10_΅´darwin)	u	   11_΅ϓϔu   12_΅ϓϔu   13_ ̈́ΎΫu   14_ẛ῁῍῎῏῝῞῟῭u   15_΅´𣏕u   16_   Au   17_   Au   18_   Az19_   Az>only NT+ and systems with Unicode-friendly filesystem encodingc                   p   e Zd Z ee      ZdZd Zd Ze	dfdZ
d Zej                  dk(  ree	fZneZd Z ej$                  ej                  d	k(  d
       ej$                  ej(                  xs ej*                  d      d               Z ej$                  ej                  d	k(  d
      d        Zd Zd Zy)UnicodeFileTestsNc                 X   	 t        j                  t        j                         | j                  t        j                  t        j                         t               }| j                  D ]  }t         j                  j                  t        j                  | j                  |            }t        |d      5 }|j                  |dz   j                  d             d d d        t        j                  |       |j!                  |        || _        y # t        $ r Y w xY w# 1 sw Y   HxY wNwb
utf-8)osmkdirr   TESTFNFileExistsError
addCleanuprmtreesetfilespathjoinnormopenwriteencodestatadd)selfr   namefs       ;/root/Python-3.12.4/Lib/test/test_unicode_file_functions.pysetUpzUnicodeFileTests.setUpA   s    	HHY%%& 		(()*:*:;JJ 	D77<<	 0 0$))D/BDdD! 5Qd**7345GGDMIIdO	 
  		5 5s   #D 5$D 	DD D)	c                 J    | j                   rt        | j                   |      S |S N)normal_formr   )r!   ss     r$   r   zUnicodeFileTests.normQ   s#    T--q11    Tc           
          | j                  |      5 } ||       d d d        j                  j                  }|r'| j                  ||d|j                  d|d|       y y # 1 sw Y   IxY w)Nz
Function '(z-) failed with bad filename in the exception: )assertRaises	exceptionfilenameassertEqual__name__)r!   fnr/   expected_exceptioncheck_filenamecexc_filenames          r$   _apply_failurezUnicodeFileTests._apply_failureV   sl     12 	axL	{{++\8 kk8\6C D 	 	s   	A##A,c                    | j                   D ]  }d|z   }| j                  t        |       | j                  t        j                  |       | j                  t        j
                  |       | j                  t        j                  |       | j                  t        j                  |       | j                  t        j                  |        y )Nnot_)	r   r7   r   r   r   chdirrmdirremovelistdirr!   r"   s     r$   test_failureszUnicodeFileTests.test_failuresa   s    JJ 	2DD=Dd+.$/$/		40

D1	2r*   win32c                 $   | j                   D ]  }t        |d      }|j                  |dz   j                  d             |j	                          t        j                  |       | j                  t
        j                  || j                          y r   )
r   r   r   r   closer   r   r7   r=   _listdir_failure)r!   r"   r#   s      r$   	test_openzUnicodeFileTests.test_openr   sn    JJ 	IDT4 AGGT$Y&&w/0GGIGGDM

D$2G2GH	Ir*   r	   zirrelevant test on Mac OS Xz:test fails on Emscripten/WASI when host platform is macOS.c                    t        | j                        }t               }t        g d      D ]  |t        fd|D              z  } ||z  }|D ]  }| j                  t        |       | j                  t        j
                  |       | j                  t        j                  |       | j                  t        j                  |       | j                  t        j                  |       | j                  t        j                  |        y )N)NFCNFDNFKCNFKDc              3   6   K   | ]  }t        |        y wr'   r   ).0filenfs     r$   	<genexpr>z2UnicodeFileTests.test_normalize.<locals>.<genexpr>   s     @$)B-@s   )
r   r   r7   r   r   r   r:   r;   r<   r=   )r!   r   othersr"   rM   s       @r$   test_normalizezUnicodeFileTests.test_normalize~   s     DJJ45 	ABc@%@@@F	A% 	2Dd+.$/$/		40

D1	2r*   c                    t        | j                        }t        j                         5  t        j                  dt
               t        j                  t        j                  j                  t        j                                     }d d d        t        j                  t        j                        }t        d |D              }| j                  |||d|       | j                  t              t        |             y # 1 sw Y   {xY w)Nignorec              3   x   K   | ]2  }t         j                  j                  t        j                  |       4 y wr'   )r   r   r   r   r   )rK   r#   s     r$   rN   z0UnicodeFileTests.test_listdir.<locals>.<genexpr>   s%     @"'',,y//3@s   8:z != )r   r   warningscatch_warningssimplefilterDeprecationWarningr   r=   r   r   r   sysgetfilesystemencodingr0   len)r!   sf0f1f2sf2s        r$   test_listdirzUnicodeFileTests.test_listdir   s    $**o$$& 	:!!(,>?I,,335579 :B	: ZZ	(()@R@@cc#:;R#b'*	: 	:s   ADDc                 ~    | j                   D ].  }t        j                  |d       t        j                  d|       0 y )Ntmp)r   r   renamer>   s     r$   test_renamezUnicodeFileTests.test_rename   s1    JJ 	#DIIdE"IIeT"	#r*   c                    t         j                  j                  t        j                  d      }d}t        j
                  |      5  t        |d      5 }|j                  |dz   j                  d             d d d        t        j                  |t         j                         t        j                  |       d d d        y # 1 sw Y   KxY w# 1 sw Y   y xY w)Nu   Grüß-曨曩曫u   ß-曨曩曫r   r   r   )r   r   r   r   r   temp_cwdr   r   r   accessR_OKr<   )r!   dirnamer/   r#   s       r$   test_directoryzUnicodeFileTests.test_directory   s    '',,y//>@,( 	 h% ;D009:;IIhrww'IIh		  	 ; ;	  	 s%   C$C7ACC
	CC)r1   
__module____qualname__r   	filenamesr   r(   r%   r   FileNotFoundErrorr7   r?   rX   platformNotADirectoryErrorrC   rD   unittestskipIfr   is_emscriptenis_wasirP   r_   rc   ri    r*   r$   r   r   =   s    	NEK  +<&*	D	2 ||w-/@@-I X__S\\X-/LMX__0D2	 N
2" X__S\\X-/LM	+ N	+#
 r*   r   c                       e Zd ZdZy)UnicodeNFCFileTestsrF   Nr1   rj   rk   r(   rt   r*   r$   rv   rv          Kr*   rv   c                       e Zd ZdZy)UnicodeNFDFileTestsrG   Nrw   rt   r*   r$   rz   rz      rx   r*   rz   c                       e Zd ZdZy)UnicodeNFKCFileTestsrH   Nrw   rt   r*   r$   r|   r|          Kr*   r|   c                       e Zd ZdZy)UnicodeNFKDFileTestsrI   Nrw   rt   r*   r$   r   r      r}   r*   r   __main__)r   rX   rp   rT   unicodedatar   test.supportr   testr   rl   rn   extendr   supports_unicode_filenamesrY   
fsencodingr"   r   UnicodeEncodeErrorSkipTestTestCaser   rv   rz   r|   r   r1   mainrt   r*   r$   <module>r      s   
 
   ! " 	( <<8  $ 
ww))***,JH 	$DKK
#	$p x(( p f* * + +  zHMMO Q  Hh !G H 	HHs   1C# #C;