o
    g                     @   s  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r2e
g d e jjsSe Zze
D ]Zee q=W n eyR   edw G d	d
 d
ejZG dd deZG dd deZG dd deZG dd deZdd Zedkre  dS dS )    N	normalize)support)	os_helper)
Z1_abcZ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                   @   s   e Zd ZeeZdZdd Zdd Ze	dfddZ
d	d
 Zejdkr'ee	fZneZdd Zeejdkddd Zeejdkddd Zdd Zdd ZdS )UnicodeFileTestsNc              	   C   s   zt tj W n	 ty   Y nw | tjtj t }| jD ]6}t j	
tj| |}t|d}||d d W d    n1 sGw   Y  t | || q || _d S Nwb
utf-8)osmkdirr   TESTFNFileExistsErrorZ
addCleanuprmtreesetfilespathjoinnormopenwriteencodestatadd)selfr   namef r   V/Users/admin/.pyenv/versions/3.10.0/lib/python3.10/test/test_unicode_file_functions.pysetUpA   s   


zUnicodeFileTests.setUpc                 C   s   | j r	t| j |S |S N)normal_formr   )r   sr   r   r   r   Q   s   zUnicodeFileTests.normTc                 C   s`   |  |}|| W d    n1 sw   Y  |jj}|r.| ||d|j||f  d S d S )Nz>Function '%s(%a) failed with bad filename in the exception: %a)ZassertRaises	exceptionfilenameassertEqual__name__)r   fnr%   Zexpected_exceptionZcheck_filenamecZexc_filenamer   r   r   _apply_failureV   s   



zUnicodeFileTests._apply_failurec                 C   sj   | j D ]/}d| }| t| | tj| | tj| | tj| | tj| | tj| qd S )Nnot_)	r   r*   r   r   r   chdirrmdirremovelistdirr   r   r   r   r   test_failuresa   s   
zUnicodeFileTests.test_failureswin32c                 C   sR   | j D ]#}t|d}||d d |  t| | tj|| j	 qd S r   )
r   r   r   r   closer   r   r*   r/   _listdir_failure)r   r   r   r   r   r   	test_openr   s   


zUnicodeFileTests.test_openr   zirrelevant test on Mac OS Xc                    s   t | j}t  }t g dD ] |t  fdd|D O }q||8 }|D ]+}| t| | tj| | tj| | tj| | tj| | tj	| q$d S )N)NFCNFDNFKCNFKDc                 3   s    | ]}t  |V  qd S r!   r   ).0fileZnfr   r   	<genexpr>   s    z2UnicodeFileTests.test_normalize.<locals>.<genexpr>)
r   r   r*   r   r   r   r,   r-   r.   r/   )r   r   Zothersr   r   r<   r   test_normalize~   s   
zUnicodeFileTests.test_normalizec                 C   s   t | j}t  tdt ttj	
t }W d    n1 s%w   Y  ttj	}t dd |D }| ||d||f  | t|t| d S )Nignorec                 s   s     | ]}t jtj|V  qd S r!   )r   r   r   r   r   )r:   r   r   r   r   r=      s    z0UnicodeFileTests.test_listdir.<locals>.<genexpr>z%a != %a)r   r   warningscatch_warningssimplefilterDeprecationWarningr   r/   r   r   r   sysgetfilesystemencodingr&   len)r   Zsf0f1f2Zsf2r   r   r   test_listdir   s   


zUnicodeFileTests.test_listdirc                 C   s(   | j D ]}t|d td| qd S )Ntmp)r   r   renamer0   r   r   r   test_rename   s   
zUnicodeFileTests.test_renamec              	   C   s   t jtjd}d}t|4 t|d}||d d W d    n1 s*w   Y  t 	|t j
 t | W d    d S 1 sFw   Y  d S )Nu   Grüß-曨曩曫u   ß-曨曩曫r	   r
   r   )r   r   r   r   r   Ztemp_cwdr   r   r   accessR_OKr.   )r   dirnamer%   r   r   r   r   test_directory   s   
"zUnicodeFileTests.test_directory)r'   
__module____qualname__r   	filenamesr   r"   r    r   FileNotFoundErrorr*   r1   rD   platformNotADirectoryErrorr4   r5   unittestZskipIfr>   rI   rL   rP   r   r   r   r   r   =   s&    




r   c                   @      e Zd ZdZdS )UnicodeNFCFileTestsr6   Nr'   rQ   rR   r"   r   r   r   r   rY          rY   c                   @   rX   )UnicodeNFDFileTestsr7   NrZ   r   r   r   r   r\      r[   r\   c                   @   rX   )UnicodeNFKCFileTestsr8   NrZ   r   r   r   r   r]      r[   r]   c                   @   rX   )UnicodeNFKDFileTestsr9   NrZ   r   r   r   r   r^      r[   r^   c                   C   s   t ttttt d S r!   )r   Zrun_unittestr   rY   r\   r]   r^   r   r   r   r   	test_main   s   r_   __main__)r   rD   rW   r@   unicodedatar   testr   Ztest.supportr   rS   rU   extendr   supports_unicode_filenamesrE   Z
fsencodingr   r   UnicodeEncodeErrorZSkipTestZTestCaser   rY   r\   r]   r^   r_   r'   r   r   r   r   <module>   s8   

o

