
    ϶vg4                     H   d Z ddlZddlZddlZddlZ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mZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZmZ ddlZ ej        d          d	             Zej         !                    d
           G d d                      Z"dS )zTests for distutils.util.    N)copy)	sysconfigutil)DistutilsByteCompileErrorDistutilsPlatformError)
byte_compilechange_rootcheck_environconvert_pathget_host_platformget_platformgrok_environment_errorrfc822_escapesplit_quoted	strtoboolT)autousec                    |                      t          dt          j                   |                      t          dt          j                   |                      t          dt          j                   |                      t          dt          j                   |                      t          j        dt          j        j                   |                      t          j        dt          j        j	                   |                      t          j        dt          j        j
                   |                      t          dt          t          j                             d S )	Nnameplatformversionsepjoinisabs
splitdrive_config_vars)setattrosr   sysr   r   r   pathr   r   r   r   r   r   )monkeypatchs    b/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/setuptools/_distutils/tests/test_util.pyenvironmentr"      s    FBG,,,Z666Y444E26***666"'-888rw/ABBB	>4	8N3O3OPPPPP    save_envc                      e Zd Zd Zd Zd Zd Zd Zej	        
                    d          d             Zd Zd	 Zd
Zej	                            ddde de de fdde dfddde de de de fg          d             Zd Zd ZdS )TestUtilc                    t          j        dd          5  t          j        dd          5  t                      dk    sJ 	 d d d            n# 1 swxY w Y   t          j        dd          5  t                      dk    sJ 	 d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j        dd	          5  t                      t          j                    k    sJ 	 d d d            d S # 1 swxY w Y   d S )
Nos.namentzsys.versionz... [... (ARM64)]	win-arm64z... [... (ARM)]	win-arm32zsys.version_info)   	   r   finalr   )mockpatchr   stdlib_sysconfigr   selfs    r!   test_get_host_platformzTestUtil.test_get_host_platform-   s   Z	4(( 	: 	:M+>?? : :(**k99999: : : : : : : : : : : : : : :M+<== : :(**k99999: : : : : : : : : : : : : : :	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: 	: Z*,ABB 	J 	J$&&*:*G*I*IIIIII	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	J 	Jsj   B'AB'A	B'A	B'.BB'B	B'B	B''B+.B+&C;;C?C?c                    t          j        dd          5  t           j                            dddi          5  t                      dk    sJ 	 d d d            n# 1 swxY w Y   t           j                            dddi          5  t                      dk    sJ 	 d d d            n# 1 swxY w Y   t           j                            ddd	i          5  t                      d
k    sJ 	 d d d            n# 1 swxY w Y   t           j                            dddi          5  t                      dk    sJ 	 d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr(   r)   z
os.environVSCMD_ARG_TGT_ARCHx86win32x64z	win-amd64armr+   arm64r*   )r/   r0   dictr   r2   s    r!   test_get_platformzTestUtil.test_get_platform7   s   Z	4(( 	5 	50De/LMM 1 1#~~000001 1 1 1 1 1 1 1 1 1 1 1 1 1 10De/LMM 5 5#~~444445 5 5 5 5 5 5 5 5 5 5 5 5 5 50De/LMM 5 5#~~444445 5 5 5 5 5 5 5 5 5 5 5 5 5 50Dg/NOO 5 5#~~444445 5 5 5 5 5 5 5 5 5 5 5 5 5 5	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s   #E AE A	E "A	#%E B*E *B.	.E 1B.	2%E C9-E 9C=	=E  C=	%E &E<E E	E E	E  E$'E$c                     t           j                            d          }t          d          |k    sJ t          t	          j        d                    |k    sJ t          d          t           j        k    sJ d S )N) hometomystuffz/home/to/my/stuff.)r   r   r   r   pathlibPathcurdir)r3   expecteds     r!   test_convert_pathzTestUtil.test_convert_pathB   su    6;;@AA/00H<<<<GL)<==>>(JJJJC  BI------r#   c                 b   dt           _        d }|t           j        _        d }|t           j        _        t          dd          dk    sJ t          dd          dk    sJ d	t           _        d
t           _        d }|t           j        _        d }|t           j        _        d }|t           j        _        t          dd          dk    sJ t          dd          dk    sJ dt           _        t          j	        t                    5  t          dd           d d d            d S # 1 swxY w Y   d S )Nposixc                     | d         dk    S )Nr   / r   s    r!   _isabsz)TestUtil.test_change_root.<locals>._isabsL   s    7c>!r#   c                  ,    d                     |           S )NrM   r   rO   s    r!   _joinz(TestUtil.test_change_root.<locals>._joinQ   s    88D>>!r#   z/rootz/old/its/herez/root/old/its/herezits/herez/root/its/herer)   \c                 ,    |                      d          S )Nzc:\)
startswithrO   s    r!   rP   z)TestUtil.test_change_root.<locals>._isabs]   s    ??6***r#   c                 d    |                      d          rd|                     dd          fS d| fS )Nzc:r?   )rV   replacerO   s    r!   _splitdrivez.TestUtil.test_change_root.<locals>._splitdriveb   s9    t$$ 4DLLr2233:r#   c                  ,    d                     |           S )NrT   rR   rO   s    r!   rS   z(TestUtil.test_change_root.<locals>._joini   s    99T??"r#   zc:\rootzc:\old\its\herezc:\root\old\its\herezits\herezc:\root\its\here	BugsBunny)r   r   r   r   r   r	   r   r   pytestraisesr   )r3   rP   rS   rY   s       r!   test_change_rootzTestUtil.test_change_rootH   s   	" 	" 	" 	" 	" 	" 7O448LLLLL7J//3CCCCC 	+ 	+ 	+ 	 	 	
 )	# 	# 	#  
$899=WWWWW:{337LLLLL ]122 	1 	1
K000	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1s   D$$D(+D(c                     t           j                                         t          j                            dd            t                       t          j        d         t                      k    sJ d S )NHOMEPLAT)r   r
   cache_clearr   environpopr   r2   s    r!   test_check_environzTestUtil.test_check_environz   sX    &&(((

vt$$$z&!\^^333333r#   zos.name != 'posix'c                    t           j                                         t          j                            dd            dd l}|                    d          }t          j	        
                    |d|          5  t                       t          j        d         dk    sJ 	 d d d            n# 1 swxY w Y   t           j                                         t          j                            dd            t          j	        
                    |dt                    5  t                       dt          j        vsJ 	 d d d            d S # 1 swxY w Y   d S )Nr`   r   )NNNNN/home/distutilsNgetpwuid)return_valuerg   )side_effect)r   r
   rb   r   rc   rd   pwdstruct_passwdr/   r0   objectKeyError)r3   rk   results      r!   test_check_environ_getpwuidz$TestUtil.test_check_environ_getpwuid   s   &&(((

vt$$$


 "" $
   ZsJVDD 	; 	;OOO:f%)::::::	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	; 	&&(((

vt$$$ ZsJHEE 	, 	,OOO+++++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,s$   :'B..B25B2EEEc                 4    t          d          g dk    sJ d S )Nz""one"" "two" 'three' \four)onetwothreefour)r   r2   s    r!   test_split_quotedzTestUtil.test_split_quoted   s>    <== B
 B
 B
 
 
 
 
 
 
r#   c                 f    d}d}|D ]}t          |          sJ |D ]}t          |          rJ d S )N)
yYyesTruettruer{   Onon1)	nnoffalseoff0OffNoN)r   )r3   rz   r   rx   r   s        r!   test_strtoboolzTestUtil.test_strtobool   s^    MD 	  	 AQ<< 	$ 	$A ||####	$ 	$r#   z        zgiven,wantedzhello
world
zhello
zworld
zhelloworldzhelloworld)r?   r?   zI am a
poor
lonesome
header
zI am a
zpoor
z	lonesome
zheader
c                    t          |          }t          j                            ddd          }t	          j                    5 }d| d}t          j        |          }t          j                            ||          	                    |           |
                    d           t          j        |          }ddd           n# 1 swxY w Y   ||fD ]v}	|	                                d	k    sJ |	d
         dk    sJ t          |	d                                                   t          |                                          k    sJ w||k    sJ dS )a{  
        We want to ensure a multi-line header parses correctly.

        For interoperability, the escaped value should also "round-trip" over
        `email.generator.Generator.flatten` and `email.message_from_*`
        (see pypa/setuptools#4033).

        The main issue is that internally `email.policy.EmailPolicy` uses
        `splitlines` which will split on some control chars. If all the new lines
        are not prefixed with spaces, the parser will interrupt reading
        the current header and produce an incomplete value, while
        incorrectly interpreting the rest of the headers as part of the payload.
        TFr   )utf8mangle_from_max_line_lengthzheader: z
other-header: 42

payload
)policyNzpayload
zother-header42header)r   emailr   EmailPolicyioStringIOmessage_from_string	generator	Generatorflattenseekmessage_from_fileget_payloadset
splitlines)
r3   givenwantedresr   bufferraworigregenmsgs
             r!   test_rfc822_escapezTestUtil.test_rfc822_escape   s   6 E"")) * 
 

 []] 	4fASAAAC,S11DO%%fV%<<DDTJJJKKNNN+F33E	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 %= 	L 	LC??$$3333~&$....s8}//1122c#..:J:J6K6KKKKKKf}}}}}}s   A8C		CCc                     t           j        }dt           _        	 t          j        t                    5  t          g            d d d            n# 1 swxY w Y   |t           _        d S # |t           _        w xY w)NT)r   dont_write_bytecoder\   r]   r   r   )r3   old_dont_write_bytecodes     r!   test_dont_write_bytecodez!TestUtil.test_dont_write_bytecode   s     #&"9"&	>899 ! !R   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! '>C###&=C#====s.   A( AA( AA( AA( (A6c                 R    t          d          }t          |          }|dk    sJ d S )NzUnable to find batch filez error: Unable to find batch file)OSErrorr   )r3   excr   s      r!   test_grok_environment_errorz$TestUtil.test_grok_environment_error   s5    122$S))8888888r#   N)__name__
__module____qualname__r4   r=   rI   r^   re   r\   markskipifrp   rv   r   indentparametrizer   r   r   rN   r#   r!   r&   r&   +   so       J J J	5 	5 	5. . ..1 .1 .1d4 4 4 [,--, , .-,8
 
 
$ $ $ F[ "#Pv#P#P#P#P#P#PQ8688892S6SSSS6SS6SS		
 " " "H	> 	> 	>9 9 9 9 9r#   r&   )#__doc__r   email.generatoremail.policyr   r   rE   r   r   r1   unittest.mockr/   r   	distutilsr   distutils.errorsr   r   distutils.utilr   r	   r
   r   r   r   r   r   r   r   r\   fixturer"   r   usefixturesr&   rN   r#   r!   <module>r      s              				 				  



 $ $ $ $             % % % % % % % % N N N N N N N N                         Q Q Q $$G9 G9 G9 G9 G9 G9 G9 %$G9 G9 G9r#   