o
    JAf  ã                   @   sš   d 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	 ej
dkr'dndZe edu e¡G dd	„ d	ejejƒƒZd
d„ ZedkrKe	eƒ ƒ dS dS )z"Tests for distutils._msvccompiler.é    N)ÚDistutilsPlatformError)Úsupport)Úrun_unittestÚwin32zThese tests are only for win32c                   @   s,   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	S )
ÚmsvccompilerTestCasec                 C   sF   dd l m} dd„ }|j}||_z|  t|jd¡ W ||_d S ||_w )Nr   c                 S   s   dS )N)NN© )Z	plat_specr   r   ú8/usr/lib/python3.10/distutils/tests/test_msvccompiler.pyÚ_find_vcvarsall   s   z>msvccompilerTestCase.test_no_compiler.<locals>._find_vcvarsallzwont find this version)Údistutils._msvccompilerÚ_msvccompilerr	   ZassertRaisesr   Ú_get_vc_env)Úselfr   r	   Zold_find_vcvarsallr   r   r   Útest_no_compiler   s   þz%msvccompilerTestCase.test_no_compilerc              	   C   sœ   dd l m} d}d}tj dd ¡}|tj|< z)| d¡}|  | ¡ |¡ |  ||| ¡  ¡ W tj |¡ |r>|tjd< d S d S tj |¡ |rM|tjd< w )Nr   u   á¹°á¸–á¹¤á¹ªâ”…á¹¼áº¨á¹œu	   â‚ƒâ´â‚…ZDISTUTILS_USE_SDKZx86)	r
   r   ÚosÚenvironÚpopr   ZassertInÚlowerZassertEqual)r   r   Ztest_varZ
test_valueZold_distutils_use_sdkÚenvr   r   r   Útest_get_vc_env_unicode#   s    

ÿÿz,msvccompilerTestCase.test_get_vc_env_unicodec                 C   óH   dd l m} | ¡ \}}|r|  |d¡ |  tj |¡¡ d S t 	d¡‚)Nr   é   zVS 2017 is not installed)
r
   r   Z_find_vc2017ÚassertGreaterEqualÚ
assertTruer   ÚpathÚisdirÚunittestÚSkipTest©r   r   Úversionr   r   r   r   Útest_get_vc20175   ó   
z$msvccompilerTestCase.test_get_vc2017c                 C   r   )Nr   é   zVS 2015 is not installed)
r
   r   Z_find_vc2015r   r   r   r   r   r   r   r   r   r   r   Útest_get_vc2015A   r    z$msvccompilerTestCase.test_get_vc2015N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r"   r   r   r   r   r      s
    r   c                   C   s
   t  t¡S )N)r   Z	makeSuiter   r   r   r   r   Ú
test_suiteM   s   
r&   Ú__main__)Ú__doc__Úsysr   r   Zdistutils.errorsr   Zdistutils.testsr   Ztest.supportr   ÚplatformZSKIP_MESSAGEZ
skipUnlessZTempdirManagerZTestCaser   r&   r#   r   r   r   r   Ú<module>   s$    ÿÿ>ÿ