
    <e                        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k    re
                    g d           e j        j        sD ej                    Z	 e
D ]Ze                    e           n# e$ r  ej        d          w xY w 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j                     dS dS )    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                   N   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        pej        d          d                         Z ej        ej        d	k    d
          d             Zd Zd ZdS )UnicodeFileTestsNc                 j   	 t          j        t          j                   n# t          $ r Y nw xY w|                     t          j        t          j                   t                      }| j        D ]}t           j	        
                    t          j        |                     |                    }t          |d          5 }|                    |dz                       d                     d d d            n# 1 swxY w Y   t          j        |           |                    |           || _        d S Nwb
utf-8)osmkdirr   TESTFNFileExistsError
addCleanuprmtreesetfilespathjoinnormopenwriteencodestatadd)selfr   namefs       7/usr/lib/python3.11/test/test_unicode_file_functions.pysetUpzUnicodeFileTests.setUpA   sB   	HY%&&&& 	 	 	D		()*:;;;J 	 	D7<<	 0$))D//BBDdD!! 5Qd**7334445 5 5 5 5 5 5 5 5 5 5 5 5 5 5GDMMMIIdOOOO


s   ! 
..?,C77C;	>C;	c                 >    | j         rt          | j         |          S |S N)normal_formr   )r!   ss     r$   r   zUnicodeFileTests.normQ   s%     	2T-q111    Tc           
          |                      |          5 } ||           d d d            n# 1 swxY w Y   |j        j        }|r'|                     ||d|j        d|d|           d S d S )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   s     122 	aBxLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	{+ 	D\88 kkk888\\6C D D D D D	D 	Ds   .22c                    | j         D ]}d|z   }|                     t          |           |                     t          j        |           |                     t          j        |           |                     t          j        |           |                     t          j        |           |                     t          j        |           d S )Nnot_)	r   r7   r   r   r   chdirrmdirremovelistdirr!   r"   s     r$   test_failureszUnicodeFileTests.test_failuresa   s    J 	2 	2DD=Dd+++...$///$///	4000
D1111	2 	2r*   win32c                 ,   | j         D ]}t          |d          }|                    |dz                       d                     |                                 t          j        |           |                     t
          j        || j	                   d S r   )
r   r   r   r   closer   r   r7   r=   _listdir_failure)r!   r"   r#   s      r$   	test_openzUnicodeFileTests.test_openr   s    J 	I 	IDT4  AGGT$Y&&w//000GGIIIGDMMM
D$2GHHHH	I 	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 ]}|                     t          |           |                     t          j        |           |                     t          j        |           |                     t          j        |           |                     t          j        |           |                     t          j	        |           d S )N)NFCNFDNFKCNFKDc              3   8   K   | ]}t          |          V  d S r'   r   ).0filenfs     r$   	<genexpr>z2UnicodeFileTests.test_normalize.<locals>.<genexpr>   s-      @@$)B--@@@@@@r*   )
r   r   r7   r   r   r   r:   r;   r<   r=   )r!   r   othersr"   rM   s       @r$   test_normalizezUnicodeFileTests.test_normalize~   s    DJ44455 	A 	ABc@@@@%@@@@@@FF% 	2 	2Dd+++...$///$///	4000
D1111	2 	2r*   c                 B   t          | j                  }t          j                    5  t          j        dt
                     t          j        t          j	        
                    t          j                                        }d d d            n# 1 swxY w Y   t          j        t          j	                  }t          d |D                       }|                     |||d|           |                     t          |          t          |                     d S )Nignorec              3   j   K   | ].}t           j                            t          j        |          V  /d S r'   )r   r   r   r   r   )rK   r#   s     r$   rN   z0UnicodeFileTests.test_listdir.<locals>.<genexpr>   s5      @@"',,y/33@@@@@@r*   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   s4   $*oo$&& 	: 	:!(,>???I,335779 9 : :B	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: Z	())@@R@@@@@ccc#:;;;R#b''*****s   ABBBc                 n    | j         D ],}t          j        |d           t          j        d|           -d S )Ntmp)r   r   renamer>   s     r$   test_renamezUnicodeFileTests.test_rename   sD    J 	# 	#DIdE"""IeT""""	# 	#r*   c                    t           j                            t          j        d          }d}t          j        |          5  t          |d          5 }|                    |dz                       d                     d d d            n# 1 swxY w Y   t          j	        |t           j
                   t          j        |           d d d            d S # 1 swxY w Y   d S )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   sE   ',,y/>@ @,(( 	  	 h%% ;D0099:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ;Ihrw'''Ih		  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  	 s6   C,B
>C
B	CB	6C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   =   sX       C	NNEK      +<&*	D 	D 	D 	D	2 	2 	2 |w-/@@-I I I X_S\X-/LMMX_0D 2 2	  NM
2" X_S\X-/LMM	+ 	+ NM	+# # #
         r*   r   c                       e Zd ZdZdS )UnicodeNFCFileTestsrF   Nr1   rj   rk   r(   rt   r*   r$   rv   rv              KKKr*   rv   c                       e Zd ZdZdS )UnicodeNFDFileTestsrG   Nrw   rt   r*   r$   rz   rz      rx   r*   rz   c                       e Zd ZdZdS )UnicodeNFKCFileTestsrH   Nrw   rt   r*   r$   r|   r|              KKKr*   r|   c                       e Zd ZdZdS )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      $ 
w) H**,,JH 	$ 	$DKK
####	$ H H Hh !G H H 	HH
p  p  p  p  p x( p  p  p f    *       *       +       +    zHMOOOOO s   %B   B